google_dfareporting3d2/
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    /// Manage DoubleClick Digital Marketing conversions
17    Ddmconversion,
18
19    /// View and manage DoubleClick for Advertisers reports
20    Full,
21
22    /// View and manage your DoubleClick Campaign Manager's (DCM) display ad campaigns
23    Dfatrafficking,
24}
25
26impl AsRef<str> for Scope {
27    fn as_ref(&self) -> &str {
28        match *self {
29            Scope::Ddmconversion => "https://www.googleapis.com/auth/ddmconversions",
30            Scope::Full => "https://www.googleapis.com/auth/dfareporting",
31            Scope::Dfatrafficking => "https://www.googleapis.com/auth/dfatrafficking",
32        }
33    }
34}
35
36#[allow(clippy::derivable_impls)]
37impl Default for Scope {
38    fn default() -> Scope {
39        Scope::Full
40    }
41}
42
43// ########
44// HUB ###
45// ######
46
47/// Central instance to access all Dfareporting related resource activities
48///
49/// # Examples
50///
51/// Instantiate a new hub
52///
53/// ```test_harness,no_run
54/// extern crate hyper;
55/// extern crate hyper_rustls;
56/// extern crate google_dfareporting3d2 as dfareporting3d2;
57/// use dfareporting3d2::{Result, Error};
58/// # async fn dox() {
59/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60///
61/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
62/// // `client_secret`, among other things.
63/// let secret: yup_oauth2::ApplicationSecret = Default::default();
64/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
65/// // unless you replace  `None` with the desired Flow.
66/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
67/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
68/// // retrieve them from storage.
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72/// ).build().await.unwrap();
73///
74/// let client = hyper_util::client::legacy::Client::builder(
75///     hyper_util::rt::TokioExecutor::new()
76/// )
77/// .build(
78///     hyper_rustls::HttpsConnectorBuilder::new()
79///         .with_native_roots()
80///         .unwrap()
81///         .https_or_http()
82///         .enable_http1()
83///         .build()
84/// );
85/// let mut hub = Dfareporting::new(client, auth);
86/// // You can configure optional parameters by calling the respective setters at will, and
87/// // execute the final call using `doit()`.
88/// // Values shown here are possibly random and not representative !
89/// let result = hub.reports().files_list(-55, -62)
90///              .sort_order("Lorem")
91///              .sort_field("gubergren")
92///              .page_token("eos")
93///              .max_results(-4)
94///              .doit().await;
95///
96/// match result {
97///     Err(e) => match e {
98///         // The Error enum provides details about what exactly happened.
99///         // You can also just use its `Debug`, `Display` or `Error` traits
100///          Error::HttpError(_)
101///         |Error::Io(_)
102///         |Error::MissingAPIKey
103///         |Error::MissingToken(_)
104///         |Error::Cancelled
105///         |Error::UploadSizeLimitExceeded(_, _)
106///         |Error::Failure(_)
107///         |Error::BadRequest(_)
108///         |Error::FieldClash(_)
109///         |Error::JsonDecodeError(_, _) => println!("{}", e),
110///     },
111///     Ok(res) => println!("Success: {:?}", res),
112/// }
113/// # }
114/// ```
115#[derive(Clone)]
116pub struct Dfareporting<C> {
117    pub client: common::Client<C>,
118    pub auth: Box<dyn common::GetToken>,
119    _user_agent: String,
120    _base_url: String,
121    _root_url: String,
122}
123
124impl<C> common::Hub for Dfareporting<C> {}
125
126impl<'a, C> Dfareporting<C> {
127    pub fn new<A: 'static + common::GetToken>(
128        client: common::Client<C>,
129        auth: A,
130    ) -> Dfareporting<C> {
131        Dfareporting {
132            client,
133            auth: Box::new(auth),
134            _user_agent: "google-api-rust-client/6.0.0".to_string(),
135            _base_url: "https://www.googleapis.com/dfareporting/v3.2/".to_string(),
136            _root_url: "https://www.googleapis.com/".to_string(),
137        }
138    }
139
140    pub fn account_active_ad_summaries(&'a self) -> AccountActiveAdSummaryMethods<'a, C> {
141        AccountActiveAdSummaryMethods { hub: self }
142    }
143    pub fn account_permission_groups(&'a self) -> AccountPermissionGroupMethods<'a, C> {
144        AccountPermissionGroupMethods { hub: self }
145    }
146    pub fn account_permissions(&'a self) -> AccountPermissionMethods<'a, C> {
147        AccountPermissionMethods { hub: self }
148    }
149    pub fn account_user_profiles(&'a self) -> AccountUserProfileMethods<'a, C> {
150        AccountUserProfileMethods { hub: self }
151    }
152    pub fn accounts(&'a self) -> AccountMethods<'a, C> {
153        AccountMethods { hub: self }
154    }
155    pub fn ads(&'a self) -> AdMethods<'a, C> {
156        AdMethods { hub: self }
157    }
158    pub fn advertiser_groups(&'a self) -> AdvertiserGroupMethods<'a, C> {
159        AdvertiserGroupMethods { hub: self }
160    }
161    pub fn advertiser_landing_pages(&'a self) -> AdvertiserLandingPageMethods<'a, C> {
162        AdvertiserLandingPageMethods { hub: self }
163    }
164    pub fn advertisers(&'a self) -> AdvertiserMethods<'a, C> {
165        AdvertiserMethods { hub: self }
166    }
167    pub fn browsers(&'a self) -> BrowserMethods<'a, C> {
168        BrowserMethods { hub: self }
169    }
170    pub fn campaign_creative_associations(&'a self) -> CampaignCreativeAssociationMethods<'a, C> {
171        CampaignCreativeAssociationMethods { hub: self }
172    }
173    pub fn campaigns(&'a self) -> CampaignMethods<'a, C> {
174        CampaignMethods { hub: self }
175    }
176    pub fn change_logs(&'a self) -> ChangeLogMethods<'a, C> {
177        ChangeLogMethods { hub: self }
178    }
179    pub fn cities(&'a self) -> CityMethods<'a, C> {
180        CityMethods { hub: self }
181    }
182    pub fn connection_types(&'a self) -> ConnectionTypeMethods<'a, C> {
183        ConnectionTypeMethods { hub: self }
184    }
185    pub fn content_categories(&'a self) -> ContentCategoryMethods<'a, C> {
186        ContentCategoryMethods { hub: self }
187    }
188    pub fn conversions(&'a self) -> ConversionMethods<'a, C> {
189        ConversionMethods { hub: self }
190    }
191    pub fn countries(&'a self) -> CountryMethods<'a, C> {
192        CountryMethods { hub: self }
193    }
194    pub fn creative_assets(&'a self) -> CreativeAssetMethods<'a, C> {
195        CreativeAssetMethods { hub: self }
196    }
197    pub fn creative_field_values(&'a self) -> CreativeFieldValueMethods<'a, C> {
198        CreativeFieldValueMethods { hub: self }
199    }
200    pub fn creative_fields(&'a self) -> CreativeFieldMethods<'a, C> {
201        CreativeFieldMethods { hub: self }
202    }
203    pub fn creative_groups(&'a self) -> CreativeGroupMethods<'a, C> {
204        CreativeGroupMethods { hub: self }
205    }
206    pub fn creatives(&'a self) -> CreativeMethods<'a, C> {
207        CreativeMethods { hub: self }
208    }
209    pub fn dimension_values(&'a self) -> DimensionValueMethods<'a, C> {
210        DimensionValueMethods { hub: self }
211    }
212    pub fn directory_site_contacts(&'a self) -> DirectorySiteContactMethods<'a, C> {
213        DirectorySiteContactMethods { hub: self }
214    }
215    pub fn directory_sites(&'a self) -> DirectorySiteMethods<'a, C> {
216        DirectorySiteMethods { hub: self }
217    }
218    pub fn dynamic_targeting_keys(&'a self) -> DynamicTargetingKeyMethods<'a, C> {
219        DynamicTargetingKeyMethods { hub: self }
220    }
221    pub fn event_tags(&'a self) -> EventTagMethods<'a, C> {
222        EventTagMethods { hub: self }
223    }
224    pub fn files(&'a self) -> FileMethods<'a, C> {
225        FileMethods { hub: self }
226    }
227    pub fn floodlight_activities(&'a self) -> FloodlightActivityMethods<'a, C> {
228        FloodlightActivityMethods { hub: self }
229    }
230    pub fn floodlight_activity_groups(&'a self) -> FloodlightActivityGroupMethods<'a, C> {
231        FloodlightActivityGroupMethods { hub: self }
232    }
233    pub fn floodlight_configurations(&'a self) -> FloodlightConfigurationMethods<'a, C> {
234        FloodlightConfigurationMethods { hub: self }
235    }
236    pub fn inventory_items(&'a self) -> InventoryItemMethods<'a, C> {
237        InventoryItemMethods { hub: self }
238    }
239    pub fn languages(&'a self) -> LanguageMethods<'a, C> {
240        LanguageMethods { hub: self }
241    }
242    pub fn metros(&'a self) -> MetroMethods<'a, C> {
243        MetroMethods { hub: self }
244    }
245    pub fn mobile_apps(&'a self) -> MobileAppMethods<'a, C> {
246        MobileAppMethods { hub: self }
247    }
248    pub fn mobile_carriers(&'a self) -> MobileCarrierMethods<'a, C> {
249        MobileCarrierMethods { hub: self }
250    }
251    pub fn operating_system_versions(&'a self) -> OperatingSystemVersionMethods<'a, C> {
252        OperatingSystemVersionMethods { hub: self }
253    }
254    pub fn operating_systems(&'a self) -> OperatingSystemMethods<'a, C> {
255        OperatingSystemMethods { hub: self }
256    }
257    pub fn order_documents(&'a self) -> OrderDocumentMethods<'a, C> {
258        OrderDocumentMethods { hub: self }
259    }
260    pub fn orders(&'a self) -> OrderMethods<'a, C> {
261        OrderMethods { hub: self }
262    }
263    pub fn placement_groups(&'a self) -> PlacementGroupMethods<'a, C> {
264        PlacementGroupMethods { hub: self }
265    }
266    pub fn placement_strategies(&'a self) -> PlacementStrategyMethods<'a, C> {
267        PlacementStrategyMethods { hub: self }
268    }
269    pub fn placements(&'a self) -> PlacementMethods<'a, C> {
270        PlacementMethods { hub: self }
271    }
272    pub fn platform_types(&'a self) -> PlatformTypeMethods<'a, C> {
273        PlatformTypeMethods { hub: self }
274    }
275    pub fn postal_codes(&'a self) -> PostalCodeMethods<'a, C> {
276        PostalCodeMethods { hub: self }
277    }
278    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
279        ProjectMethods { hub: self }
280    }
281    pub fn regions(&'a self) -> RegionMethods<'a, C> {
282        RegionMethods { hub: self }
283    }
284    pub fn remarketing_list_shares(&'a self) -> RemarketingListShareMethods<'a, C> {
285        RemarketingListShareMethods { hub: self }
286    }
287    pub fn remarketing_lists(&'a self) -> RemarketingListMethods<'a, C> {
288        RemarketingListMethods { hub: self }
289    }
290    pub fn reports(&'a self) -> ReportMethods<'a, C> {
291        ReportMethods { hub: self }
292    }
293    pub fn sites(&'a self) -> SiteMethods<'a, C> {
294        SiteMethods { hub: self }
295    }
296    pub fn sizes(&'a self) -> SizeMethods<'a, C> {
297        SizeMethods { hub: self }
298    }
299    pub fn subaccounts(&'a self) -> SubaccountMethods<'a, C> {
300        SubaccountMethods { hub: self }
301    }
302    pub fn targetable_remarketing_lists(&'a self) -> TargetableRemarketingListMethods<'a, C> {
303        TargetableRemarketingListMethods { hub: self }
304    }
305    pub fn targeting_templates(&'a self) -> TargetingTemplateMethods<'a, C> {
306        TargetingTemplateMethods { hub: self }
307    }
308    pub fn user_profiles(&'a self) -> UserProfileMethods<'a, C> {
309        UserProfileMethods { hub: self }
310    }
311    pub fn user_role_permission_groups(&'a self) -> UserRolePermissionGroupMethods<'a, C> {
312        UserRolePermissionGroupMethods { hub: self }
313    }
314    pub fn user_role_permissions(&'a self) -> UserRolePermissionMethods<'a, C> {
315        UserRolePermissionMethods { hub: self }
316    }
317    pub fn user_roles(&'a self) -> UserRoleMethods<'a, C> {
318        UserRoleMethods { hub: self }
319    }
320    pub fn video_formats(&'a self) -> VideoFormatMethods<'a, C> {
321        VideoFormatMethods { hub: self }
322    }
323
324    /// Set the user-agent header field to use in all requests to the server.
325    /// It defaults to `google-api-rust-client/6.0.0`.
326    ///
327    /// Returns the previously set user-agent.
328    pub fn user_agent(&mut self, agent_name: String) -> String {
329        std::mem::replace(&mut self._user_agent, agent_name)
330    }
331
332    /// Set the base url to use in all requests to the server.
333    /// It defaults to `https://www.googleapis.com/dfareporting/v3.2/`.
334    ///
335    /// Returns the previously set base url.
336    pub fn base_url(&mut self, new_base_url: String) -> String {
337        std::mem::replace(&mut self._base_url, new_base_url)
338    }
339
340    /// Set the root url to use in all requests to the server.
341    /// It defaults to `https://www.googleapis.com/`.
342    ///
343    /// Returns the previously set root url.
344    pub fn root_url(&mut self, new_root_url: String) -> String {
345        std::mem::replace(&mut self._root_url, new_root_url)
346    }
347}
348
349// ############
350// SCHEMAS ###
351// ##########
352/// Contains properties of a Campaign Manager account.
353///
354/// # Activities
355///
356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
358///
359/// * [get accounts](AccountGetCall) (response)
360/// * [list accounts](AccountListCall) (none)
361/// * [patch accounts](AccountPatchCall) (request|response)
362/// * [update accounts](AccountUpdateCall) (request|response)
363#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
364#[serde_with::serde_as]
365#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
366pub struct Account {
367    /// Account permissions assigned to this account.
368    #[serde(rename = "accountPermissionIds")]
369    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
370    pub account_permission_ids: Option<Vec<i64>>,
371    /// Profile for this account. This is a read-only field that can be left blank.
372    #[serde(rename = "accountProfile")]
373    pub account_profile: Option<String>,
374    /// Whether this account is active.
375    pub active: Option<bool>,
376    /// Maximum number of active ads allowed for this account.
377    #[serde(rename = "activeAdsLimitTier")]
378    pub active_ads_limit_tier: Option<String>,
379    /// Whether to serve creatives with Active View tags. If disabled, viewability data will not be available for any impressions.
380    #[serde(rename = "activeViewOptOut")]
381    pub active_view_opt_out: Option<bool>,
382    /// User role permissions available to the user roles of this account.
383    #[serde(rename = "availablePermissionIds")]
384    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
385    pub available_permission_ids: Option<Vec<i64>>,
386    /// ID of the country associated with this account.
387    #[serde(rename = "countryId")]
388    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
389    pub country_id: Option<i64>,
390    /// ID of currency associated with this account. This is a required field.
391    /// Acceptable values are:
392    /// - "1" for USD
393    /// - "2" for GBP
394    /// - "3" for ESP
395    /// - "4" for SEK
396    /// - "5" for CAD
397    /// - "6" for JPY
398    /// - "7" for DEM
399    /// - "8" for AUD
400    /// - "9" for FRF
401    /// - "10" for ITL
402    /// - "11" for DKK
403    /// - "12" for NOK
404    /// - "13" for FIM
405    /// - "14" for ZAR
406    /// - "15" for IEP
407    /// - "16" for NLG
408    /// - "17" for EUR
409    /// - "18" for KRW
410    /// - "19" for TWD
411    /// - "20" for SGD
412    /// - "21" for CNY
413    /// - "22" for HKD
414    /// - "23" for NZD
415    /// - "24" for MYR
416    /// - "25" for BRL
417    /// - "26" for PTE
418    /// - "27" for MXP
419    /// - "28" for CLP
420    /// - "29" for TRY
421    /// - "30" for ARS
422    /// - "31" for PEN
423    /// - "32" for ILS
424    /// - "33" for CHF
425    /// - "34" for VEF
426    /// - "35" for COP
427    /// - "36" for GTQ
428    /// - "37" for PLN
429    /// - "39" for INR
430    /// - "40" for THB
431    /// - "41" for IDR
432    /// - "42" for CZK
433    /// - "43" for RON
434    /// - "44" for HUF
435    /// - "45" for RUB
436    /// - "46" for AED
437    /// - "47" for BGN
438    /// - "48" for HRK
439    /// - "49" for MXN
440    /// - "50" for NGN
441    #[serde(rename = "currencyId")]
442    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
443    pub currency_id: Option<i64>,
444    /// Default placement dimensions for this account.
445    #[serde(rename = "defaultCreativeSizeId")]
446    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
447    pub default_creative_size_id: Option<i64>,
448    /// Description of this account.
449    pub description: Option<String>,
450    /// ID of this account. This is a read-only, auto-generated field.
451    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
452    pub id: Option<i64>,
453    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#account".
454    pub kind: Option<String>,
455    /// Locale of this account.
456    /// Acceptable values are:
457    /// - "cs" (Czech)
458    /// - "de" (German)
459    /// - "en" (English)
460    /// - "en-GB" (English United Kingdom)
461    /// - "es" (Spanish)
462    /// - "fr" (French)
463    /// - "it" (Italian)
464    /// - "ja" (Japanese)
465    /// - "ko" (Korean)
466    /// - "pl" (Polish)
467    /// - "pt-BR" (Portuguese Brazil)
468    /// - "ru" (Russian)
469    /// - "sv" (Swedish)
470    /// - "tr" (Turkish)
471    /// - "zh-CN" (Chinese Simplified)
472    /// - "zh-TW" (Chinese Traditional)
473    pub locale: Option<String>,
474    /// Maximum image size allowed for this account, in kilobytes. Value must be greater than or equal to 1.
475    #[serde(rename = "maximumImageSize")]
476    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
477    pub maximum_image_size: Option<i64>,
478    /// Name of this account. This is a required field, and must be less than 128 characters long and be globally unique.
479    pub name: Option<String>,
480    /// Whether campaigns created in this account will be enabled for Nielsen OCR reach ratings by default.
481    #[serde(rename = "nielsenOcrEnabled")]
482    pub nielsen_ocr_enabled: Option<bool>,
483    /// Reporting configuration of this account.
484    #[serde(rename = "reportsConfiguration")]
485    pub reports_configuration: Option<ReportsConfiguration>,
486    /// Share Path to Conversion reports with Twitter.
487    #[serde(rename = "shareReportsWithTwitter")]
488    pub share_reports_with_twitter: Option<bool>,
489    /// File size limit in kilobytes of Rich Media teaser creatives. Acceptable values are 1 to 10240, inclusive.
490    #[serde(rename = "teaserSizeLimit")]
491    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
492    pub teaser_size_limit: Option<i64>,
493}
494
495impl common::RequestValue for Account {}
496impl common::Resource for Account {}
497impl common::ResponseResult for Account {}
498
499/// Gets a summary of active ads in an account.
500///
501/// # Activities
502///
503/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
504/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
505///
506/// * [get account active ad summaries](AccountActiveAdSummaryGetCall) (response)
507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
508#[serde_with::serde_as]
509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
510pub struct AccountActiveAdSummary {
511    /// ID of the account.
512    #[serde(rename = "accountId")]
513    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
514    pub account_id: Option<i64>,
515    /// Ads that have been activated for the account
516    #[serde(rename = "activeAds")]
517    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
518    pub active_ads: Option<i64>,
519    /// Maximum number of active ads allowed for the account.
520    #[serde(rename = "activeAdsLimitTier")]
521    pub active_ads_limit_tier: Option<String>,
522    /// Ads that can be activated for the account.
523    #[serde(rename = "availableAds")]
524    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
525    pub available_ads: Option<i64>,
526    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountActiveAdSummary".
527    pub kind: Option<String>,
528}
529
530impl common::ResponseResult for AccountActiveAdSummary {}
531
532/// AccountPermissions contains information about a particular account permission. Some features of Campaign Manager require an account permission to be present in the account.
533///
534/// # Activities
535///
536/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
537/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
538///
539/// * [get account permissions](AccountPermissionGetCall) (response)
540/// * [list account permissions](AccountPermissionListCall) (none)
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct AccountPermission {
545    /// Account profiles associated with this account permission.
546    ///
547    /// Possible values are:
548    /// - "ACCOUNT_PROFILE_BASIC"
549    /// - "ACCOUNT_PROFILE_STANDARD"
550    #[serde(rename = "accountProfiles")]
551    pub account_profiles: Option<Vec<String>>,
552    /// ID of this account permission.
553    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
554    pub id: Option<i64>,
555    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermission".
556    pub kind: Option<String>,
557    /// Administrative level required to enable this account permission.
558    pub level: Option<String>,
559    /// Name of this account permission.
560    pub name: Option<String>,
561    /// Permission group of this account permission.
562    #[serde(rename = "permissionGroupId")]
563    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
564    pub permission_group_id: Option<i64>,
565}
566
567impl common::Resource for AccountPermission {}
568impl common::ResponseResult for AccountPermission {}
569
570/// AccountPermissionGroups contains a mapping of permission group IDs to names. A permission group is a grouping of account permissions.
571///
572/// # Activities
573///
574/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
575/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
576///
577/// * [get account permission groups](AccountPermissionGroupGetCall) (response)
578/// * [list account permission groups](AccountPermissionGroupListCall) (none)
579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
580#[serde_with::serde_as]
581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
582pub struct AccountPermissionGroup {
583    /// ID of this account permission group.
584    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
585    pub id: Option<i64>,
586    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroup".
587    pub kind: Option<String>,
588    /// Name of this account permission group.
589    pub name: Option<String>,
590}
591
592impl common::Resource for AccountPermissionGroup {}
593impl common::ResponseResult for AccountPermissionGroup {}
594
595/// Account Permission Group List Response
596///
597/// # Activities
598///
599/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
600/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
601///
602/// * [list account permission groups](AccountPermissionGroupListCall) (response)
603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
604#[serde_with::serde_as]
605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
606pub struct AccountPermissionGroupsListResponse {
607    /// Account permission group collection.
608    #[serde(rename = "accountPermissionGroups")]
609    pub account_permission_groups: Option<Vec<AccountPermissionGroup>>,
610    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroupsListResponse".
611    pub kind: Option<String>,
612}
613
614impl common::ResponseResult for AccountPermissionGroupsListResponse {}
615
616/// Account Permission List Response
617///
618/// # Activities
619///
620/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
621/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
622///
623/// * [list account permissions](AccountPermissionListCall) (response)
624#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
625#[serde_with::serde_as]
626#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
627pub struct AccountPermissionsListResponse {
628    /// Account permission collection.
629    #[serde(rename = "accountPermissions")]
630    pub account_permissions: Option<Vec<AccountPermission>>,
631    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionsListResponse".
632    pub kind: Option<String>,
633}
634
635impl common::ResponseResult for AccountPermissionsListResponse {}
636
637/// AccountUserProfiles contains properties of a Campaign Manager user profile. This resource is specifically for managing user profiles, whereas UserProfiles is for accessing the API.
638///
639/// # Activities
640///
641/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
642/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
643///
644/// * [get account user profiles](AccountUserProfileGetCall) (response)
645/// * [insert account user profiles](AccountUserProfileInsertCall) (request|response)
646/// * [list account user profiles](AccountUserProfileListCall) (none)
647/// * [patch account user profiles](AccountUserProfilePatchCall) (request|response)
648/// * [update account user profiles](AccountUserProfileUpdateCall) (request|response)
649#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
650#[serde_with::serde_as]
651#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
652pub struct AccountUserProfile {
653    /// Account ID of the user profile. This is a read-only field that can be left blank.
654    #[serde(rename = "accountId")]
655    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
656    pub account_id: Option<i64>,
657    /// Whether this user profile is active. This defaults to false, and must be set true on insert for the user profile to be usable.
658    pub active: Option<bool>,
659    /// Filter that describes which advertisers are visible to the user profile.
660    #[serde(rename = "advertiserFilter")]
661    pub advertiser_filter: Option<ObjectFilter>,
662    /// Filter that describes which campaigns are visible to the user profile.
663    #[serde(rename = "campaignFilter")]
664    pub campaign_filter: Option<ObjectFilter>,
665    /// Comments for this user profile.
666    pub comments: Option<String>,
667    /// Email of the user profile. The email addresss must be linked to a Google Account. This field is required on insertion and is read-only after insertion.
668    pub email: Option<String>,
669    /// ID of the user profile. This is a read-only, auto-generated field.
670    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
671    pub id: Option<i64>,
672    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfile".
673    pub kind: Option<String>,
674    /// Locale of the user profile. This is a required field.
675    /// Acceptable values are:  
676    /// - "cs" (Czech)
677    /// - "de" (German)
678    /// - "en" (English)
679    /// - "en-GB" (English United Kingdom)
680    /// - "es" (Spanish)
681    /// - "fr" (French)
682    /// - "it" (Italian)
683    /// - "ja" (Japanese)
684    /// - "ko" (Korean)
685    /// - "pl" (Polish)
686    /// - "pt-BR" (Portuguese Brazil)
687    /// - "ru" (Russian)
688    /// - "sv" (Swedish)
689    /// - "tr" (Turkish)
690    /// - "zh-CN" (Chinese Simplified)
691    /// - "zh-TW" (Chinese Traditional)
692    pub locale: Option<String>,
693    /// Name of the user profile. This is a required field. Must be less than 64 characters long, must be globally unique, and cannot contain whitespace or any of the following characters: "&;"#%,".
694    pub name: Option<String>,
695    /// Filter that describes which sites are visible to the user profile.
696    #[serde(rename = "siteFilter")]
697    pub site_filter: Option<ObjectFilter>,
698    /// Subaccount ID of the user profile. This is a read-only field that can be left blank.
699    #[serde(rename = "subaccountId")]
700    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
701    pub subaccount_id: Option<i64>,
702    /// Trafficker type of this user profile. This is a read-only field.
703    #[serde(rename = "traffickerType")]
704    pub trafficker_type: Option<String>,
705    /// User type of the user profile. This is a read-only field that can be left blank.
706    #[serde(rename = "userAccessType")]
707    pub user_access_type: Option<String>,
708    /// Filter that describes which user roles are visible to the user profile.
709    #[serde(rename = "userRoleFilter")]
710    pub user_role_filter: Option<ObjectFilter>,
711    /// User role ID of the user profile. This is a required field.
712    #[serde(rename = "userRoleId")]
713    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
714    pub user_role_id: Option<i64>,
715}
716
717impl common::RequestValue for AccountUserProfile {}
718impl common::Resource for AccountUserProfile {}
719impl common::ResponseResult for AccountUserProfile {}
720
721/// Account User Profile List Response
722///
723/// # Activities
724///
725/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
726/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
727///
728/// * [list account user profiles](AccountUserProfileListCall) (response)
729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
730#[serde_with::serde_as]
731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
732pub struct AccountUserProfilesListResponse {
733    /// Account user profile collection.
734    #[serde(rename = "accountUserProfiles")]
735    pub account_user_profiles: Option<Vec<AccountUserProfile>>,
736    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfilesListResponse".
737    pub kind: Option<String>,
738    /// Pagination token to be used for the next list operation.
739    #[serde(rename = "nextPageToken")]
740    pub next_page_token: Option<String>,
741}
742
743impl common::ResponseResult for AccountUserProfilesListResponse {}
744
745/// Account List Response
746///
747/// # Activities
748///
749/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
750/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
751///
752/// * [list accounts](AccountListCall) (response)
753#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
754#[serde_with::serde_as]
755#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
756pub struct AccountsListResponse {
757    /// Account collection.
758    pub accounts: Option<Vec<Account>>,
759    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountsListResponse".
760    pub kind: Option<String>,
761    /// Pagination token to be used for the next list operation.
762    #[serde(rename = "nextPageToken")]
763    pub next_page_token: Option<String>,
764}
765
766impl common::ResponseResult for AccountsListResponse {}
767
768/// Represents an activity group.
769///
770/// This type is not used in any activity, and only used as *part* of another schema.
771///
772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
773#[serde_with::serde_as]
774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
775pub struct Activities {
776    /// List of activity filters. The dimension values need to be all either of type "dfa:activity" or "dfa:activityGroup".
777    pub filters: Option<Vec<DimensionValue>>,
778    /// The kind of resource this is, in this case dfareporting#activities.
779    pub kind: Option<String>,
780    /// List of names of floodlight activity metrics.
781    #[serde(rename = "metricNames")]
782    pub metric_names: Option<Vec<String>>,
783}
784
785impl common::Part for Activities {}
786
787/// Contains properties of a Campaign Manager ad.
788///
789/// # Activities
790///
791/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
792/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
793///
794/// * [get ads](AdGetCall) (response)
795/// * [insert ads](AdInsertCall) (request|response)
796/// * [list ads](AdListCall) (none)
797/// * [patch ads](AdPatchCall) (request|response)
798/// * [update ads](AdUpdateCall) (request|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 Ad {
803    /// Account ID of this ad. This is a read-only field that can be left blank.
804    #[serde(rename = "accountId")]
805    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
806    pub account_id: Option<i64>,
807    /// Whether this ad is active. When true, archived must be false.
808    pub active: Option<bool>,
809    /// Advertiser ID of this ad. This is a required field on insertion.
810    #[serde(rename = "advertiserId")]
811    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
812    pub advertiser_id: Option<i64>,
813    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
814    #[serde(rename = "advertiserIdDimensionValue")]
815    pub advertiser_id_dimension_value: Option<DimensionValue>,
816    /// Whether this ad is archived. When true, active must be false.
817    pub archived: Option<bool>,
818    /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD.
819    #[serde(rename = "audienceSegmentId")]
820    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
821    pub audience_segment_id: Option<i64>,
822    /// Campaign ID of this ad. This is a required field on insertion.
823    #[serde(rename = "campaignId")]
824    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
825    pub campaign_id: Option<i64>,
826    /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field.
827    #[serde(rename = "campaignIdDimensionValue")]
828    pub campaign_id_dimension_value: Option<DimensionValue>,
829    /// Click-through URL for this ad. This is a required field on insertion. Applicable when type is AD_SERVING_CLICK_TRACKER.
830    #[serde(rename = "clickThroughUrl")]
831    pub click_through_url: Option<ClickThroughUrl>,
832    /// Click-through URL suffix properties for this ad. Applies to the URL in the ad or (if overriding ad properties) the URL in the creative.
833    #[serde(rename = "clickThroughUrlSuffixProperties")]
834    pub click_through_url_suffix_properties: Option<ClickThroughUrlSuffixProperties>,
835    /// Comments for this ad.
836    pub comments: Option<String>,
837    /// Compatibility of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to either rendering on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are only used for existing default ads. New mobile placements must be assigned DISPLAY or DISPLAY_INTERSTITIAL and default ads created for those placements will be limited to those compatibility types. IN_STREAM_VIDEO refers to rendering in-stream video ads developed with the VAST standard.
838    pub compatibility: Option<String>,
839    /// Information about the creation of this ad. This is a read-only field.
840    #[serde(rename = "createInfo")]
841    pub create_info: Option<LastModifiedInfo>,
842    /// Creative group assignments for this ad. Applicable when type is AD_SERVING_CLICK_TRACKER. Only one assignment per creative group number is allowed for a maximum of two assignments.
843    #[serde(rename = "creativeGroupAssignments")]
844    pub creative_group_assignments: Option<Vec<CreativeGroupAssignment>>,
845    /// Creative rotation for this ad. Applicable when type is AD_SERVING_DEFAULT_AD, AD_SERVING_STANDARD_AD, or AD_SERVING_TRACKING. When type is AD_SERVING_DEFAULT_AD, this field should have exactly one creativeAssignment.
846    #[serde(rename = "creativeRotation")]
847    pub creative_rotation: Option<CreativeRotation>,
848    /// Time and day targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
849    #[serde(rename = "dayPartTargeting")]
850    pub day_part_targeting: Option<DayPartTargeting>,
851    /// Default click-through event tag properties for this ad.
852    #[serde(rename = "defaultClickThroughEventTagProperties")]
853    pub default_click_through_event_tag_properties: Option<DefaultClickThroughEventTagProperties>,
854    /// Delivery schedule information for this ad. Applicable when type is AD_SERVING_STANDARD_AD or AD_SERVING_TRACKING. This field along with subfields priority and impressionRatio are required on insertion when type is AD_SERVING_STANDARD_AD.
855    #[serde(rename = "deliverySchedule")]
856    pub delivery_schedule: Option<DeliverySchedule>,
857    /// Whether this ad is a dynamic click tracker. Applicable when type is AD_SERVING_CLICK_TRACKER. This is a required field on insert, and is read-only after insert.
858    #[serde(rename = "dynamicClickTracker")]
859    pub dynamic_click_tracker: Option<bool>,
860    /// Date and time that this ad should stop serving. Must be later than the start time. This is a required field on insertion.
861    #[serde(rename = "endTime")]
862    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
863    /// Event tag overrides for this ad.
864    #[serde(rename = "eventTagOverrides")]
865    pub event_tag_overrides: Option<Vec<EventTagOverride>>,
866    /// Geographical targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
867    #[serde(rename = "geoTargeting")]
868    pub geo_targeting: Option<GeoTargeting>,
869    /// ID of this ad. This is a read-only, auto-generated field.
870    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
871    pub id: Option<i64>,
872    /// Dimension value for the ID of this ad. This is a read-only, auto-generated field.
873    #[serde(rename = "idDimensionValue")]
874    pub id_dimension_value: Option<DimensionValue>,
875    /// Key-value targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
876    #[serde(rename = "keyValueTargetingExpression")]
877    pub key_value_targeting_expression: Option<KeyValueTargetingExpression>,
878    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ad".
879    pub kind: Option<String>,
880    /// Language targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
881    #[serde(rename = "languageTargeting")]
882    pub language_targeting: Option<LanguageTargeting>,
883    /// Information about the most recent modification of this ad. This is a read-only field.
884    #[serde(rename = "lastModifiedInfo")]
885    pub last_modified_info: Option<LastModifiedInfo>,
886    /// Name of this ad. This is a required field and must be less than 256 characters long.
887    pub name: Option<String>,
888    /// Placement assignments for this ad.
889    #[serde(rename = "placementAssignments")]
890    pub placement_assignments: Option<Vec<PlacementAssignment>>,
891    /// Remarketing list targeting expression for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
892    #[serde(rename = "remarketingListExpression")]
893    pub remarketing_list_expression: Option<ListTargetingExpression>,
894    /// Size of this ad. Applicable when type is AD_SERVING_DEFAULT_AD.
895    pub size: Option<Size>,
896    /// Whether this ad is ssl compliant. This is a read-only field that is auto-generated when the ad is inserted or updated.
897    #[serde(rename = "sslCompliant")]
898    pub ssl_compliant: Option<bool>,
899    /// Whether this ad requires ssl. This is a read-only field that is auto-generated when the ad is inserted or updated.
900    #[serde(rename = "sslRequired")]
901    pub ssl_required: Option<bool>,
902    /// Date and time that this ad should start serving. If creating an ad, this field must be a time in the future. This is a required field on insertion.
903    #[serde(rename = "startTime")]
904    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
905    /// Subaccount ID of this ad. This is a read-only field that can be left blank.
906    #[serde(rename = "subaccountId")]
907    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
908    pub subaccount_id: Option<i64>,
909    /// Targeting template ID, used to apply preconfigured targeting information to this ad. This cannot be set while any of dayPartTargeting, geoTargeting, keyValueTargetingExpression, languageTargeting, remarketingListExpression, or technologyTargeting are set. Applicable when type is AD_SERVING_STANDARD_AD.
910    #[serde(rename = "targetingTemplateId")]
911    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
912    pub targeting_template_id: Option<i64>,
913    /// Technology platform targeting information for this ad. This field must be left blank if the ad is using a targeting template. Applicable when type is AD_SERVING_STANDARD_AD.
914    #[serde(rename = "technologyTargeting")]
915    pub technology_targeting: Option<TechnologyTargeting>,
916    /// Type of ad. This is a required field on insertion. Note that default ads (AD_SERVING_DEFAULT_AD) cannot be created directly (see Creative resource).
917    #[serde(rename = "type")]
918    pub type_: Option<String>,
919}
920
921impl common::RequestValue for Ad {}
922impl common::Resource for Ad {}
923impl common::ResponseResult for Ad {}
924
925/// Campaign ad blocking settings.
926///
927/// This type is not used in any activity, and only used as *part* of another schema.
928///
929#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
930#[serde_with::serde_as]
931#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
932pub struct AdBlockingConfiguration {
933    /// Click-through URL used by brand-neutral ads. This is a required field when overrideClickThroughUrl is set to true.
934    #[serde(rename = "clickThroughUrl")]
935    pub click_through_url: Option<String>,
936    /// ID of a creative bundle to use for this campaign. If set, brand-neutral ads will select creatives from this bundle. Otherwise, a default transparent pixel will be used.
937    #[serde(rename = "creativeBundleId")]
938    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
939    pub creative_bundle_id: Option<i64>,
940    /// Whether this campaign has enabled ad blocking. When true, ad blocking is enabled for placements in the campaign, but this may be overridden by site and placement settings. When false, ad blocking is disabled for all placements under the campaign, regardless of site and placement settings.
941    pub enabled: Option<bool>,
942    /// Whether the brand-neutral ad's click-through URL comes from the campaign's creative bundle or the override URL. Must be set to true if ad blocking is enabled and no creative bundle is configured.
943    #[serde(rename = "overrideClickThroughUrl")]
944    pub override_click_through_url: Option<bool>,
945}
946
947impl common::Part for AdBlockingConfiguration {}
948
949/// Ad Slot
950///
951/// This type is not used in any activity, and only used as *part* of another schema.
952///
953#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
954#[serde_with::serde_as]
955#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
956pub struct AdSlot {
957    /// Comment for this ad slot.
958    pub comment: Option<String>,
959    /// Ad slot compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop, mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard.
960    pub compatibility: Option<String>,
961    /// Height of this ad slot.
962    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
963    pub height: Option<i64>,
964    /// ID of the placement from an external platform that is linked to this ad slot.
965    #[serde(rename = "linkedPlacementId")]
966    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
967    pub linked_placement_id: Option<i64>,
968    /// Name of this ad slot.
969    pub name: Option<String>,
970    /// Payment source type of this ad slot.
971    #[serde(rename = "paymentSourceType")]
972    pub payment_source_type: Option<String>,
973    /// Primary ad slot of a roadblock inventory item.
974    pub primary: Option<bool>,
975    /// Width of this ad slot.
976    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
977    pub width: Option<i64>,
978}
979
980impl common::Part for AdSlot {}
981
982/// Ad List Response
983///
984/// # Activities
985///
986/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
987/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
988///
989/// * [list ads](AdListCall) (response)
990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
991#[serde_with::serde_as]
992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
993pub struct AdsListResponse {
994    /// Ad collection.
995    pub ads: Option<Vec<Ad>>,
996    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#adsListResponse".
997    pub kind: Option<String>,
998    /// Pagination token to be used for the next list operation.
999    #[serde(rename = "nextPageToken")]
1000    pub next_page_token: Option<String>,
1001}
1002
1003impl common::ResponseResult for AdsListResponse {}
1004
1005/// Contains properties of a Campaign Manager advertiser.
1006///
1007/// # Activities
1008///
1009/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1010/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1011///
1012/// * [get advertisers](AdvertiserGetCall) (response)
1013/// * [insert advertisers](AdvertiserInsertCall) (request|response)
1014/// * [list advertisers](AdvertiserListCall) (none)
1015/// * [patch advertisers](AdvertiserPatchCall) (request|response)
1016/// * [update advertisers](AdvertiserUpdateCall) (request|response)
1017#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1018#[serde_with::serde_as]
1019#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1020pub struct Advertiser {
1021    /// Account ID of this advertiser.This is a read-only field that can be left blank.
1022    #[serde(rename = "accountId")]
1023    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1024    pub account_id: Option<i64>,
1025    /// ID of the advertiser group this advertiser belongs to. You can group advertisers for reporting purposes, allowing you to see aggregated information for all advertisers in each group.
1026    #[serde(rename = "advertiserGroupId")]
1027    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1028    pub advertiser_group_id: Option<i64>,
1029    /// Suffix added to click-through URL of ad creative associations under this advertiser. Must be less than 129 characters long.
1030    #[serde(rename = "clickThroughUrlSuffix")]
1031    pub click_through_url_suffix: Option<String>,
1032    /// ID of the click-through event tag to apply by default to the landing pages of this advertiser's campaigns.
1033    #[serde(rename = "defaultClickThroughEventTagId")]
1034    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1035    pub default_click_through_event_tag_id: Option<i64>,
1036    /// Default email address used in sender field for tag emails.
1037    #[serde(rename = "defaultEmail")]
1038    pub default_email: Option<String>,
1039    /// Floodlight configuration ID of this advertiser. The floodlight configuration ID will be created automatically, so on insert this field should be left blank. This field can be set to another advertiser's floodlight configuration ID in order to share that advertiser's floodlight configuration with this advertiser, so long as:
1040    /// - This advertiser's original floodlight configuration is not already associated with floodlight activities or floodlight activity groups.
1041    /// - This advertiser's original floodlight configuration is not already shared with another advertiser.
1042    #[serde(rename = "floodlightConfigurationId")]
1043    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1044    pub floodlight_configuration_id: Option<i64>,
1045    /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field.
1046    #[serde(rename = "floodlightConfigurationIdDimensionValue")]
1047    pub floodlight_configuration_id_dimension_value: Option<DimensionValue>,
1048    /// ID of this advertiser. This is a read-only, auto-generated field.
1049    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1050    pub id: Option<i64>,
1051    /// Dimension value for the ID of this advertiser. This is a read-only, auto-generated field.
1052    #[serde(rename = "idDimensionValue")]
1053    pub id_dimension_value: Option<DimensionValue>,
1054    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiser".
1055    pub kind: Option<String>,
1056    /// Name of this advertiser. This is a required field and must be less than 256 characters long and unique among advertisers of the same account.
1057    pub name: Option<String>,
1058    /// Original floodlight configuration before any sharing occurred. Set the floodlightConfigurationId of this advertiser to originalFloodlightConfigurationId to unshare the advertiser's current floodlight configuration. You cannot unshare an advertiser's floodlight configuration if the shared configuration has activities associated with any campaign or placement.
1059    #[serde(rename = "originalFloodlightConfigurationId")]
1060    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1061    pub original_floodlight_configuration_id: Option<i64>,
1062    /// Status of this advertiser.
1063    pub status: Option<String>,
1064    /// Subaccount ID of this advertiser.This is a read-only field that can be left blank.
1065    #[serde(rename = "subaccountId")]
1066    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1067    pub subaccount_id: Option<i64>,
1068    /// Suspension status of this advertiser.
1069    pub suspended: Option<bool>,
1070}
1071
1072impl common::RequestValue for Advertiser {}
1073impl common::Resource for Advertiser {}
1074impl common::ResponseResult for Advertiser {}
1075
1076/// Groups advertisers together so that reports can be generated for the entire group at once.
1077///
1078/// # Activities
1079///
1080/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1081/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1082///
1083/// * [delete advertiser groups](AdvertiserGroupDeleteCall) (none)
1084/// * [get advertiser groups](AdvertiserGroupGetCall) (response)
1085/// * [insert advertiser groups](AdvertiserGroupInsertCall) (request|response)
1086/// * [list advertiser groups](AdvertiserGroupListCall) (none)
1087/// * [patch advertiser groups](AdvertiserGroupPatchCall) (request|response)
1088/// * [update advertiser groups](AdvertiserGroupUpdateCall) (request|response)
1089#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1090#[serde_with::serde_as]
1091#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1092pub struct AdvertiserGroup {
1093    /// Account ID of this advertiser group. This is a read-only field that can be left blank.
1094    #[serde(rename = "accountId")]
1095    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1096    pub account_id: Option<i64>,
1097    /// ID of this advertiser group. This is a read-only, auto-generated field.
1098    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1099    pub id: Option<i64>,
1100    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroup".
1101    pub kind: Option<String>,
1102    /// Name of this advertiser group. This is a required field and must be less than 256 characters long and unique among advertiser groups of the same account.
1103    pub name: Option<String>,
1104}
1105
1106impl common::RequestValue for AdvertiserGroup {}
1107impl common::Resource for AdvertiserGroup {}
1108impl common::ResponseResult for AdvertiserGroup {}
1109
1110/// Advertiser Group List Response
1111///
1112/// # Activities
1113///
1114/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1115/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1116///
1117/// * [list advertiser groups](AdvertiserGroupListCall) (response)
1118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1119#[serde_with::serde_as]
1120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1121pub struct AdvertiserGroupsListResponse {
1122    /// Advertiser group collection.
1123    #[serde(rename = "advertiserGroups")]
1124    pub advertiser_groups: Option<Vec<AdvertiserGroup>>,
1125    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroupsListResponse".
1126    pub kind: Option<String>,
1127    /// Pagination token to be used for the next list operation.
1128    #[serde(rename = "nextPageToken")]
1129    pub next_page_token: Option<String>,
1130}
1131
1132impl common::ResponseResult for AdvertiserGroupsListResponse {}
1133
1134/// Landing Page List Response
1135///
1136/// # Activities
1137///
1138/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1139/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1140///
1141/// * [list advertiser landing pages](AdvertiserLandingPageListCall) (response)
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct AdvertiserLandingPagesListResponse {
1146    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserLandingPagesListResponse".
1147    pub kind: Option<String>,
1148    /// Landing page collection
1149    #[serde(rename = "landingPages")]
1150    pub landing_pages: Option<Vec<LandingPage>>,
1151    /// Pagination token to be used for the next list operation.
1152    #[serde(rename = "nextPageToken")]
1153    pub next_page_token: Option<String>,
1154}
1155
1156impl common::ResponseResult for AdvertiserLandingPagesListResponse {}
1157
1158/// Advertiser List Response
1159///
1160/// # Activities
1161///
1162/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1163/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1164///
1165/// * [list advertisers](AdvertiserListCall) (response)
1166#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1167#[serde_with::serde_as]
1168#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1169pub struct AdvertisersListResponse {
1170    /// Advertiser collection.
1171    pub advertisers: Option<Vec<Advertiser>>,
1172    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertisersListResponse".
1173    pub kind: Option<String>,
1174    /// Pagination token to be used for the next list operation.
1175    #[serde(rename = "nextPageToken")]
1176    pub next_page_token: Option<String>,
1177}
1178
1179impl common::ResponseResult for AdvertisersListResponse {}
1180
1181/// Audience Segment.
1182///
1183/// This type is not used in any activity, and only used as *part* of another schema.
1184///
1185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1186#[serde_with::serde_as]
1187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1188pub struct AudienceSegment {
1189    /// Weight allocated to this segment. The weight assigned will be understood in proportion to the weights assigned to other segments in the same segment group. Acceptable values are 1 to 1000, inclusive.
1190    pub allocation: Option<i32>,
1191    /// ID of this audience segment. This is a read-only, auto-generated field.
1192    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1193    pub id: Option<i64>,
1194    /// Name of this audience segment. This is a required field and must be less than 65 characters long.
1195    pub name: Option<String>,
1196}
1197
1198impl common::Part for AudienceSegment {}
1199
1200/// Audience Segment Group.
1201///
1202/// This type is not used in any activity, and only used as *part* of another schema.
1203///
1204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1205#[serde_with::serde_as]
1206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1207pub struct AudienceSegmentGroup {
1208    /// Audience segments assigned to this group. The number of segments must be between 2 and 100.
1209    #[serde(rename = "audienceSegments")]
1210    pub audience_segments: Option<Vec<AudienceSegment>>,
1211    /// ID of this audience segment group. This is a read-only, auto-generated field.
1212    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1213    pub id: Option<i64>,
1214    /// Name of this audience segment group. This is a required field and must be less than 65 characters long.
1215    pub name: Option<String>,
1216}
1217
1218impl common::Part for AudienceSegmentGroup {}
1219
1220/// Contains information about a browser that can be targeted by ads.
1221///
1222/// # Activities
1223///
1224/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1225/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1226///
1227/// * [list browsers](BrowserListCall) (none)
1228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1229#[serde_with::serde_as]
1230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1231pub struct Browser {
1232    /// ID referring to this grouping of browser and version numbers. This is the ID used for targeting.
1233    #[serde(rename = "browserVersionId")]
1234    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1235    pub browser_version_id: Option<i64>,
1236    /// DART ID of this browser. This is the ID used when generating reports.
1237    #[serde(rename = "dartId")]
1238    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1239    pub dart_id: Option<i64>,
1240    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browser".
1241    pub kind: Option<String>,
1242    /// Major version number (leftmost number) of this browser. For example, for Chrome 5.0.376.86 beta, this field should be set to 5. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is.
1243    #[serde(rename = "majorVersion")]
1244    pub major_version: Option<String>,
1245    /// Minor version number (number after first dot on left) of this browser. For example, for Chrome 5.0.375.86 beta, this field should be set to 0. An asterisk (*) may be used to target any version number, and a question mark (?) may be used to target cases where the version number cannot be identified. For example, Chrome *.* targets any version of Chrome: 1.2, 2.5, 3.5, and so on. Chrome 3.* targets Chrome 3.1, 3.5, but not 4.0. Firefox ?.? targets cases where the ad server knows the browser is Firefox but can't tell which version it is.
1246    #[serde(rename = "minorVersion")]
1247    pub minor_version: Option<String>,
1248    /// Name of this browser.
1249    pub name: Option<String>,
1250}
1251
1252impl common::Resource for Browser {}
1253
1254/// Browser List Response
1255///
1256/// # Activities
1257///
1258/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1259/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1260///
1261/// * [list browsers](BrowserListCall) (response)
1262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1263#[serde_with::serde_as]
1264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1265pub struct BrowsersListResponse {
1266    /// Browser collection.
1267    pub browsers: Option<Vec<Browser>>,
1268    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browsersListResponse".
1269    pub kind: Option<String>,
1270}
1271
1272impl common::ResponseResult for BrowsersListResponse {}
1273
1274/// Contains properties of a Campaign Manager campaign.
1275///
1276/// # Activities
1277///
1278/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1279/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1280///
1281/// * [get campaigns](CampaignGetCall) (response)
1282/// * [insert campaigns](CampaignInsertCall) (request|response)
1283/// * [list campaigns](CampaignListCall) (none)
1284/// * [patch campaigns](CampaignPatchCall) (request|response)
1285/// * [update campaigns](CampaignUpdateCall) (request|response)
1286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1287#[serde_with::serde_as]
1288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1289pub struct Campaign {
1290    /// Account ID of this campaign. This is a read-only field that can be left blank.
1291    #[serde(rename = "accountId")]
1292    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1293    pub account_id: Option<i64>,
1294    /// Ad blocking settings for this campaign.
1295    #[serde(rename = "adBlockingConfiguration")]
1296    pub ad_blocking_configuration: Option<AdBlockingConfiguration>,
1297    /// Additional creative optimization configurations for the campaign.
1298    #[serde(rename = "additionalCreativeOptimizationConfigurations")]
1299    pub additional_creative_optimization_configurations:
1300        Option<Vec<CreativeOptimizationConfiguration>>,
1301    /// Advertiser group ID of the associated advertiser.
1302    #[serde(rename = "advertiserGroupId")]
1303    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1304    pub advertiser_group_id: Option<i64>,
1305    /// Advertiser ID of this campaign. This is a required field.
1306    #[serde(rename = "advertiserId")]
1307    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1308    pub advertiser_id: Option<i64>,
1309    /// Dimension value for the advertiser ID of this campaign. This is a read-only, auto-generated field.
1310    #[serde(rename = "advertiserIdDimensionValue")]
1311    pub advertiser_id_dimension_value: Option<DimensionValue>,
1312    /// Whether this campaign has been archived.
1313    pub archived: Option<bool>,
1314    /// Audience segment groups assigned to this campaign. Cannot have more than 300 segment groups.
1315    #[serde(rename = "audienceSegmentGroups")]
1316    pub audience_segment_groups: Option<Vec<AudienceSegmentGroup>>,
1317    /// Billing invoice code included in the Campaign Manager client billing invoices associated with the campaign.
1318    #[serde(rename = "billingInvoiceCode")]
1319    pub billing_invoice_code: Option<String>,
1320    /// Click-through URL suffix override properties for this campaign.
1321    #[serde(rename = "clickThroughUrlSuffixProperties")]
1322    pub click_through_url_suffix_properties: Option<ClickThroughUrlSuffixProperties>,
1323    /// Arbitrary comments about this campaign. Must be less than 256 characters long.
1324    pub comment: Option<String>,
1325    /// Information about the creation of this campaign. This is a read-only field.
1326    #[serde(rename = "createInfo")]
1327    pub create_info: Option<LastModifiedInfo>,
1328    /// List of creative group IDs that are assigned to the campaign.
1329    #[serde(rename = "creativeGroupIds")]
1330    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
1331    pub creative_group_ids: Option<Vec<i64>>,
1332    /// Creative optimization configuration for the campaign.
1333    #[serde(rename = "creativeOptimizationConfiguration")]
1334    pub creative_optimization_configuration: Option<CreativeOptimizationConfiguration>,
1335    /// Click-through event tag ID override properties for this campaign.
1336    #[serde(rename = "defaultClickThroughEventTagProperties")]
1337    pub default_click_through_event_tag_properties: Option<DefaultClickThroughEventTagProperties>,
1338    /// The default landing page ID for this campaign.
1339    #[serde(rename = "defaultLandingPageId")]
1340    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1341    pub default_landing_page_id: Option<i64>,
1342    /// Date on which the campaign will stop running. On insert, the end date must be today or a future date. The end date must be later than or be the same as the start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective campaign run date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This is a required field.
1343    #[serde(rename = "endDate")]
1344    pub end_date: Option<chrono::NaiveDate>,
1345    /// Overrides that can be used to activate or deactivate advertiser event tags.
1346    #[serde(rename = "eventTagOverrides")]
1347    pub event_tag_overrides: Option<Vec<EventTagOverride>>,
1348    /// External ID for this campaign.
1349    #[serde(rename = "externalId")]
1350    pub external_id: Option<String>,
1351    /// ID of this campaign. This is a read-only auto-generated field.
1352    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1353    pub id: Option<i64>,
1354    /// Dimension value for the ID of this campaign. This is a read-only, auto-generated field.
1355    #[serde(rename = "idDimensionValue")]
1356    pub id_dimension_value: Option<DimensionValue>,
1357    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaign".
1358    pub kind: Option<String>,
1359    /// Information about the most recent modification of this campaign. This is a read-only field.
1360    #[serde(rename = "lastModifiedInfo")]
1361    pub last_modified_info: Option<LastModifiedInfo>,
1362    /// Lookback window settings for the campaign.
1363    #[serde(rename = "lookbackConfiguration")]
1364    pub lookback_configuration: Option<LookbackConfiguration>,
1365    /// Name of this campaign. This is a required field and must be less than 256 characters long and unique among campaigns of the same advertiser.
1366    pub name: Option<String>,
1367    /// Whether Nielsen reports are enabled for this campaign.
1368    #[serde(rename = "nielsenOcrEnabled")]
1369    pub nielsen_ocr_enabled: Option<bool>,
1370    /// Date on which the campaign starts running. The start date can be any date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This is a required field.
1371    #[serde(rename = "startDate")]
1372    pub start_date: Option<chrono::NaiveDate>,
1373    /// Subaccount ID of this campaign. This is a read-only field that can be left blank.
1374    #[serde(rename = "subaccountId")]
1375    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1376    pub subaccount_id: Option<i64>,
1377    /// Campaign trafficker contact emails.
1378    #[serde(rename = "traffickerEmails")]
1379    pub trafficker_emails: Option<Vec<String>>,
1380}
1381
1382impl common::RequestValue for Campaign {}
1383impl common::Resource for Campaign {}
1384impl common::ResponseResult for Campaign {}
1385
1386/// Identifies a creative which has been associated with a given campaign.
1387///
1388/// # Activities
1389///
1390/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1391/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1392///
1393/// * [insert campaign creative associations](CampaignCreativeAssociationInsertCall) (request|response)
1394/// * [list campaign creative associations](CampaignCreativeAssociationListCall) (none)
1395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1396#[serde_with::serde_as]
1397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1398pub struct CampaignCreativeAssociation {
1399    /// ID of the creative associated with the campaign. This is a required field.
1400    #[serde(rename = "creativeId")]
1401    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1402    pub creative_id: Option<i64>,
1403    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation".
1404    pub kind: Option<String>,
1405}
1406
1407impl common::RequestValue for CampaignCreativeAssociation {}
1408impl common::Resource for CampaignCreativeAssociation {}
1409impl common::ResponseResult for CampaignCreativeAssociation {}
1410
1411/// Campaign Creative Association List Response
1412///
1413/// # Activities
1414///
1415/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1416/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1417///
1418/// * [list campaign creative associations](CampaignCreativeAssociationListCall) (response)
1419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1420#[serde_with::serde_as]
1421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1422pub struct CampaignCreativeAssociationsListResponse {
1423    /// Campaign creative association collection
1424    #[serde(rename = "campaignCreativeAssociations")]
1425    pub campaign_creative_associations: Option<Vec<CampaignCreativeAssociation>>,
1426    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociationsListResponse".
1427    pub kind: Option<String>,
1428    /// Pagination token to be used for the next list operation.
1429    #[serde(rename = "nextPageToken")]
1430    pub next_page_token: Option<String>,
1431}
1432
1433impl common::ResponseResult for CampaignCreativeAssociationsListResponse {}
1434
1435/// Campaign List Response
1436///
1437/// # Activities
1438///
1439/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1440/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1441///
1442/// * [list campaigns](CampaignListCall) (response)
1443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1444#[serde_with::serde_as]
1445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1446pub struct CampaignsListResponse {
1447    /// Campaign collection.
1448    pub campaigns: Option<Vec<Campaign>>,
1449    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignsListResponse".
1450    pub kind: Option<String>,
1451    /// Pagination token to be used for the next list operation.
1452    #[serde(rename = "nextPageToken")]
1453    pub next_page_token: Option<String>,
1454}
1455
1456impl common::ResponseResult for CampaignsListResponse {}
1457
1458/// Describes a change that a user has made to a resource.
1459///
1460/// # Activities
1461///
1462/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1463/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1464///
1465/// * [get change logs](ChangeLogGetCall) (response)
1466/// * [list change logs](ChangeLogListCall) (none)
1467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1468#[serde_with::serde_as]
1469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1470pub struct ChangeLog {
1471    /// Account ID of the modified object.
1472    #[serde(rename = "accountId")]
1473    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1474    pub account_id: Option<i64>,
1475    /// Action which caused the change.
1476    pub action: Option<String>,
1477    /// Time when the object was modified.
1478    #[serde(rename = "changeTime")]
1479    pub change_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1480    /// Field name of the object which changed.
1481    #[serde(rename = "fieldName")]
1482    pub field_name: Option<String>,
1483    /// ID of this change log.
1484    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1485    pub id: Option<i64>,
1486    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLog".
1487    pub kind: Option<String>,
1488    /// New value of the object field.
1489    #[serde(rename = "newValue")]
1490    pub new_value: Option<String>,
1491    /// ID of the object of this change log. The object could be a campaign, placement, ad, or other type.
1492    #[serde(rename = "objectId")]
1493    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1494    pub object_id: Option<i64>,
1495    /// Object type of the change log.
1496    #[serde(rename = "objectType")]
1497    pub object_type: Option<String>,
1498    /// Old value of the object field.
1499    #[serde(rename = "oldValue")]
1500    pub old_value: Option<String>,
1501    /// Subaccount ID of the modified object.
1502    #[serde(rename = "subaccountId")]
1503    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1504    pub subaccount_id: Option<i64>,
1505    /// Transaction ID of this change log. When a single API call results in many changes, each change will have a separate ID in the change log but will share the same transactionId.
1506    #[serde(rename = "transactionId")]
1507    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1508    pub transaction_id: Option<i64>,
1509    /// ID of the user who modified the object.
1510    #[serde(rename = "userProfileId")]
1511    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1512    pub user_profile_id: Option<i64>,
1513    /// User profile name of the user who modified the object.
1514    #[serde(rename = "userProfileName")]
1515    pub user_profile_name: Option<String>,
1516}
1517
1518impl common::Resource for ChangeLog {}
1519impl common::ResponseResult for ChangeLog {}
1520
1521/// Change Log List Response
1522///
1523/// # Activities
1524///
1525/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1526/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1527///
1528/// * [list change logs](ChangeLogListCall) (response)
1529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1530#[serde_with::serde_as]
1531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1532pub struct ChangeLogsListResponse {
1533    /// Change log collection.
1534    #[serde(rename = "changeLogs")]
1535    pub change_logs: Option<Vec<ChangeLog>>,
1536    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLogsListResponse".
1537    pub kind: Option<String>,
1538    /// Pagination token to be used for the next list operation.
1539    #[serde(rename = "nextPageToken")]
1540    pub next_page_token: Option<String>,
1541}
1542
1543impl common::ResponseResult for ChangeLogsListResponse {}
1544
1545/// City List Response
1546///
1547/// # Activities
1548///
1549/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1550/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1551///
1552/// * [list cities](CityListCall) (response)
1553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1554#[serde_with::serde_as]
1555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1556pub struct CitiesListResponse {
1557    /// City collection.
1558    pub cities: Option<Vec<City>>,
1559    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#citiesListResponse".
1560    pub kind: Option<String>,
1561}
1562
1563impl common::ResponseResult for CitiesListResponse {}
1564
1565/// Contains information about a city that can be targeted by ads.
1566///
1567/// This type is not used in any activity, and only used as *part* of another schema.
1568///
1569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1570#[serde_with::serde_as]
1571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1572pub struct City {
1573    /// Country code of the country to which this city belongs.
1574    #[serde(rename = "countryCode")]
1575    pub country_code: Option<String>,
1576    /// DART ID of the country to which this city belongs.
1577    #[serde(rename = "countryDartId")]
1578    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1579    pub country_dart_id: Option<i64>,
1580    /// DART ID of this city. This is the ID used for targeting and generating reports.
1581    #[serde(rename = "dartId")]
1582    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1583    pub dart_id: Option<i64>,
1584    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#city".
1585    pub kind: Option<String>,
1586    /// Metro region code of the metro region (DMA) to which this city belongs.
1587    #[serde(rename = "metroCode")]
1588    pub metro_code: Option<String>,
1589    /// ID of the metro region (DMA) to which this city belongs.
1590    #[serde(rename = "metroDmaId")]
1591    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1592    pub metro_dma_id: Option<i64>,
1593    /// Name of this city.
1594    pub name: Option<String>,
1595    /// Region code of the region to which this city belongs.
1596    #[serde(rename = "regionCode")]
1597    pub region_code: Option<String>,
1598    /// DART ID of the region to which this city belongs.
1599    #[serde(rename = "regionDartId")]
1600    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1601    pub region_dart_id: Option<i64>,
1602}
1603
1604impl common::Part for City {}
1605
1606/// Creative Click Tag.
1607///
1608/// This type is not used in any activity, and only used as *part* of another schema.
1609///
1610#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1611#[serde_with::serde_as]
1612#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1613pub struct ClickTag {
1614    /// Parameter value for the specified click tag. This field contains a click-through url.
1615    #[serde(rename = "clickThroughUrl")]
1616    pub click_through_url: Option<CreativeClickThroughUrl>,
1617    /// Advertiser event name associated with the click tag. This field is used by DISPLAY_IMAGE_GALLERY and HTML5_BANNER creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
1618    #[serde(rename = "eventName")]
1619    pub event_name: Option<String>,
1620    /// Parameter name for the specified click tag. For DISPLAY_IMAGE_GALLERY creative assets, this field must match the value of the creative asset's creativeAssetId.name field.
1621    pub name: Option<String>,
1622}
1623
1624impl common::Part for ClickTag {}
1625
1626/// Click-through URL
1627///
1628/// This type is not used in any activity, and only used as *part* of another schema.
1629///
1630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1631#[serde_with::serde_as]
1632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1633pub struct ClickThroughUrl {
1634    /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows:
1635    /// - If defaultLandingPage is enabled then the campaign's default landing page URL is assigned to this field.
1636    /// - If defaultLandingPage is not enabled and a landingPageId is specified then that landing page's URL is assigned to this field.
1637    /// - If neither of the above cases apply, then the customClickThroughUrl is assigned to this field.
1638    #[serde(rename = "computedClickThroughUrl")]
1639    pub computed_click_through_url: Option<String>,
1640    /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset.
1641    #[serde(rename = "customClickThroughUrl")]
1642    pub custom_click_through_url: Option<String>,
1643    /// Whether the campaign default landing page is used.
1644    #[serde(rename = "defaultLandingPage")]
1645    pub default_landing_page: Option<bool>,
1646    /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false.
1647    #[serde(rename = "landingPageId")]
1648    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1649    pub landing_page_id: Option<i64>,
1650}
1651
1652impl common::Part for ClickThroughUrl {}
1653
1654/// Click Through URL Suffix settings.
1655///
1656/// This type is not used in any activity, and only used as *part* of another schema.
1657///
1658#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1659#[serde_with::serde_as]
1660#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1661pub struct ClickThroughUrlSuffixProperties {
1662    /// Click-through URL suffix to apply to all ads in this entity's scope. Must be less than 128 characters long.
1663    #[serde(rename = "clickThroughUrlSuffix")]
1664    pub click_through_url_suffix: Option<String>,
1665    /// Whether this entity should override the inherited click-through URL suffix with its own defined value.
1666    #[serde(rename = "overrideInheritedSuffix")]
1667    pub override_inherited_suffix: Option<bool>,
1668}
1669
1670impl common::Part for ClickThroughUrlSuffixProperties {}
1671
1672/// Companion Click-through override.
1673///
1674/// This type is not used in any activity, and only used as *part* of another schema.
1675///
1676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1677#[serde_with::serde_as]
1678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1679pub struct CompanionClickThroughOverride {
1680    /// Click-through URL of this companion click-through override.
1681    #[serde(rename = "clickThroughUrl")]
1682    pub click_through_url: Option<ClickThroughUrl>,
1683    /// ID of the creative for this companion click-through override.
1684    #[serde(rename = "creativeId")]
1685    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1686    pub creative_id: Option<i64>,
1687}
1688
1689impl common::Part for CompanionClickThroughOverride {}
1690
1691/// Companion Settings
1692///
1693/// This type is not used in any activity, and only used as *part* of another schema.
1694///
1695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1696#[serde_with::serde_as]
1697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1698pub struct CompanionSetting {
1699    /// Whether companions are disabled for this placement.
1700    #[serde(rename = "companionsDisabled")]
1701    pub companions_disabled: Option<bool>,
1702    /// Whitelist of companion sizes to be served to this placement. Set this list to null or empty to serve all companion sizes.
1703    #[serde(rename = "enabledSizes")]
1704    pub enabled_sizes: Option<Vec<Size>>,
1705    /// Whether to serve only static images as companions.
1706    #[serde(rename = "imageOnly")]
1707    pub image_only: Option<bool>,
1708    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#companionSetting".
1709    pub kind: Option<String>,
1710}
1711
1712impl common::Part for CompanionSetting {}
1713
1714/// Represents a response to the queryCompatibleFields method.
1715///
1716/// # Activities
1717///
1718/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1719/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1720///
1721/// * [compatible fields query reports](ReportCompatibleFieldQueryCall) (response)
1722#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1723#[serde_with::serde_as]
1724#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1725pub struct CompatibleFields {
1726    /// Contains items that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH".
1727    #[serde(rename = "crossDimensionReachReportCompatibleFields")]
1728    pub cross_dimension_reach_report_compatible_fields:
1729        Option<CrossDimensionReachReportCompatibleFields>,
1730    /// Contains items that are compatible to be selected for a report of type "FLOODLIGHT".
1731    #[serde(rename = "floodlightReportCompatibleFields")]
1732    pub floodlight_report_compatible_fields: Option<FloodlightReportCompatibleFields>,
1733    /// The kind of resource this is, in this case dfareporting#compatibleFields.
1734    pub kind: Option<String>,
1735    /// Contains items that are compatible to be selected for a report of type "PATH_TO_CONVERSION".
1736    #[serde(rename = "pathToConversionReportCompatibleFields")]
1737    pub path_to_conversion_report_compatible_fields: Option<PathToConversionReportCompatibleFields>,
1738    /// Contains items that are compatible to be selected for a report of type "REACH".
1739    #[serde(rename = "reachReportCompatibleFields")]
1740    pub reach_report_compatible_fields: Option<ReachReportCompatibleFields>,
1741    /// Contains items that are compatible to be selected for a report of type "STANDARD".
1742    #[serde(rename = "reportCompatibleFields")]
1743    pub report_compatible_fields: Option<ReportCompatibleFields>,
1744}
1745
1746impl common::ResponseResult for CompatibleFields {}
1747
1748/// Contains information about an internet connection type that can be targeted by ads. Clients can use the connection type to target mobile vs. broadband users.
1749///
1750/// # Activities
1751///
1752/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1753/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1754///
1755/// * [get connection types](ConnectionTypeGetCall) (response)
1756/// * [list connection types](ConnectionTypeListCall) (none)
1757#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1758#[serde_with::serde_as]
1759#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1760pub struct ConnectionType {
1761    /// ID of this connection type.
1762    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1763    pub id: Option<i64>,
1764    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionType".
1765    pub kind: Option<String>,
1766    /// Name of this connection type.
1767    pub name: Option<String>,
1768}
1769
1770impl common::Resource for ConnectionType {}
1771impl common::ResponseResult for ConnectionType {}
1772
1773/// Connection Type List Response
1774///
1775/// # Activities
1776///
1777/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1778/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1779///
1780/// * [list connection types](ConnectionTypeListCall) (response)
1781#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1782#[serde_with::serde_as]
1783#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1784pub struct ConnectionTypesListResponse {
1785    /// Collection of connection types such as broadband and mobile.
1786    #[serde(rename = "connectionTypes")]
1787    pub connection_types: Option<Vec<ConnectionType>>,
1788    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionTypesListResponse".
1789    pub kind: Option<String>,
1790}
1791
1792impl common::ResponseResult for ConnectionTypesListResponse {}
1793
1794/// Content Category List Response
1795///
1796/// # Activities
1797///
1798/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1799/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1800///
1801/// * [list content categories](ContentCategoryListCall) (response)
1802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1803#[serde_with::serde_as]
1804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1805pub struct ContentCategoriesListResponse {
1806    /// Content category collection.
1807    #[serde(rename = "contentCategories")]
1808    pub content_categories: Option<Vec<ContentCategory>>,
1809    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategoriesListResponse".
1810    pub kind: Option<String>,
1811    /// Pagination token to be used for the next list operation.
1812    #[serde(rename = "nextPageToken")]
1813    pub next_page_token: Option<String>,
1814}
1815
1816impl common::ResponseResult for ContentCategoriesListResponse {}
1817
1818/// Organizes placements according to the contents of their associated webpages.
1819///
1820/// # Activities
1821///
1822/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1823/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1824///
1825/// * [get content categories](ContentCategoryGetCall) (response)
1826/// * [insert content categories](ContentCategoryInsertCall) (request|response)
1827/// * [patch content categories](ContentCategoryPatchCall) (request|response)
1828/// * [update content categories](ContentCategoryUpdateCall) (request|response)
1829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1830#[serde_with::serde_as]
1831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1832pub struct ContentCategory {
1833    /// Account ID of this content category. This is a read-only field that can be left blank.
1834    #[serde(rename = "accountId")]
1835    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1836    pub account_id: Option<i64>,
1837    /// ID of this content category. This is a read-only, auto-generated field.
1838    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1839    pub id: Option<i64>,
1840    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory".
1841    pub kind: Option<String>,
1842    /// Name of this content category. This is a required field and must be less than 256 characters long and unique among content categories of the same account.
1843    pub name: Option<String>,
1844}
1845
1846impl common::RequestValue for ContentCategory {}
1847impl common::ResponseResult for ContentCategory {}
1848
1849/// A Conversion represents when a user successfully performs a desired action after seeing an ad.
1850///
1851/// # Activities
1852///
1853/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1854/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1855///
1856/// * [batchinsert conversions](ConversionBatchinsertCall) (none)
1857/// * [batchupdate conversions](ConversionBatchupdateCall) (none)
1858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1859#[serde_with::serde_as]
1860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1861pub struct Conversion {
1862    /// Whether this particular request may come from a user under the age of 13, under COPPA compliance.
1863    #[serde(rename = "childDirectedTreatment")]
1864    pub child_directed_treatment: Option<bool>,
1865    /// Custom floodlight variables.
1866    #[serde(rename = "customVariables")]
1867    pub custom_variables: Option<Vec<CustomFloodlightVariable>>,
1868    /// The alphanumeric encrypted user ID. When set, encryptionInfo should also be specified. This field is mutually exclusive with encryptedUserIdCandidates[], mobileDeviceId and gclid. This or encryptedUserIdCandidates[] or mobileDeviceId or gclid is a required field.
1869    #[serde(rename = "encryptedUserId")]
1870    pub encrypted_user_id: Option<String>,
1871    /// A list of the alphanumeric encrypted user IDs. Any user ID with exposure prior to the conversion timestamp will be used in the inserted conversion. If no such user ID is found then the conversion will be rejected with NO_COOKIE_MATCH_FOUND error. When set, encryptionInfo should also be specified. This field may only be used when calling batchinsert; it is not supported by batchupdate. This field is mutually exclusive with encryptedUserId, mobileDeviceId and gclid. This or encryptedUserId or mobileDeviceId or gclid is a required field.
1872    #[serde(rename = "encryptedUserIdCandidates")]
1873    pub encrypted_user_id_candidates: Option<Vec<String>>,
1874    /// Floodlight Activity ID of this conversion. This is a required field.
1875    #[serde(rename = "floodlightActivityId")]
1876    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1877    pub floodlight_activity_id: Option<i64>,
1878    /// Floodlight Configuration ID of this conversion. This is a required field.
1879    #[serde(rename = "floodlightConfigurationId")]
1880    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1881    pub floodlight_configuration_id: Option<i64>,
1882    /// The Google click ID. This field is mutually exclusive with encryptedUserId, encryptedUserIdCandidates[] and mobileDeviceId. This or encryptedUserId or encryptedUserIdCandidates[] or mobileDeviceId is a required field.
1883    pub gclid: Option<String>,
1884    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversion".
1885    pub kind: Option<String>,
1886    /// Whether Limit Ad Tracking is enabled. When set to true, the conversion will be used for reporting but not targeting. This will prevent remarketing.
1887    #[serde(rename = "limitAdTracking")]
1888    pub limit_ad_tracking: Option<bool>,
1889    /// The mobile device ID. This field is mutually exclusive with encryptedUserId, encryptedUserIdCandidates[] and gclid. This or encryptedUserId or encryptedUserIdCandidates[] or gclid is a required field.
1890    #[serde(rename = "mobileDeviceId")]
1891    pub mobile_device_id: Option<String>,
1892    /// Whether the conversion was for a non personalized ad.
1893    #[serde(rename = "nonPersonalizedAd")]
1894    pub non_personalized_ad: Option<bool>,
1895    /// The ordinal of the conversion. Use this field to control how conversions of the same user and day are de-duplicated. This is a required field.
1896    pub ordinal: Option<String>,
1897    /// The quantity of the conversion.
1898    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1899    pub quantity: Option<i64>,
1900    /// The timestamp of conversion, in Unix epoch micros. This is a required field.
1901    #[serde(rename = "timestampMicros")]
1902    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1903    pub timestamp_micros: Option<i64>,
1904    /// Whether this particular request may come from a user under the age of 16 (may differ by country), under compliance with the European Union's General Data Protection Regulation (GDPR).
1905    #[serde(rename = "treatmentForUnderage")]
1906    pub treatment_for_underage: Option<bool>,
1907    /// The value of the conversion.
1908    pub value: Option<f64>,
1909}
1910
1911impl common::Resource for Conversion {}
1912
1913/// The error code and description for a conversion that failed to insert or update.
1914///
1915/// This type is not used in any activity, and only used as *part* of another schema.
1916///
1917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1918#[serde_with::serde_as]
1919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1920pub struct ConversionError {
1921    /// The error code.
1922    pub code: Option<String>,
1923    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionError".
1924    pub kind: Option<String>,
1925    /// A description of the error.
1926    pub message: Option<String>,
1927}
1928
1929impl common::Part for ConversionError {}
1930
1931/// The original conversion that was inserted or updated and whether there were any errors.
1932///
1933/// This type is not used in any activity, and only used as *part* of another schema.
1934///
1935#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1936#[serde_with::serde_as]
1937#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1938pub struct ConversionStatus {
1939    /// The original conversion that was inserted or updated.
1940    pub conversion: Option<Conversion>,
1941    /// A list of errors related to this conversion.
1942    pub errors: Option<Vec<ConversionError>>,
1943    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionStatus".
1944    pub kind: Option<String>,
1945}
1946
1947impl common::Part for ConversionStatus {}
1948
1949/// Insert Conversions Request.
1950///
1951/// # Activities
1952///
1953/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1954/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1955///
1956/// * [batchinsert conversions](ConversionBatchinsertCall) (request)
1957#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1958#[serde_with::serde_as]
1959#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1960pub struct ConversionsBatchInsertRequest {
1961    /// The set of conversions to insert.
1962    pub conversions: Option<Vec<Conversion>>,
1963    /// Describes how encryptedUserId or encryptedUserIdCandidates[] is encrypted. This is a required field if encryptedUserId or encryptedUserIdCandidates[] is used.
1964    #[serde(rename = "encryptionInfo")]
1965    pub encryption_info: Option<EncryptionInfo>,
1966    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertRequest".
1967    pub kind: Option<String>,
1968}
1969
1970impl common::RequestValue for ConversionsBatchInsertRequest {}
1971
1972/// Insert Conversions Response.
1973///
1974/// # Activities
1975///
1976/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1977/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1978///
1979/// * [batchinsert conversions](ConversionBatchinsertCall) (response)
1980#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1981#[serde_with::serde_as]
1982#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1983pub struct ConversionsBatchInsertResponse {
1984    /// Indicates that some or all conversions failed to insert.
1985    #[serde(rename = "hasFailures")]
1986    pub has_failures: Option<bool>,
1987    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertResponse".
1988    pub kind: Option<String>,
1989    /// The insert status of each conversion. Statuses are returned in the same order that conversions are inserted.
1990    pub status: Option<Vec<ConversionStatus>>,
1991}
1992
1993impl common::ResponseResult for ConversionsBatchInsertResponse {}
1994
1995/// Update Conversions Request.
1996///
1997/// # Activities
1998///
1999/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2000/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2001///
2002/// * [batchupdate conversions](ConversionBatchupdateCall) (request)
2003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2004#[serde_with::serde_as]
2005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2006pub struct ConversionsBatchUpdateRequest {
2007    /// The set of conversions to update.
2008    pub conversions: Option<Vec<Conversion>>,
2009    /// Describes how encryptedUserId is encrypted. This is a required field if encryptedUserId is used.
2010    #[serde(rename = "encryptionInfo")]
2011    pub encryption_info: Option<EncryptionInfo>,
2012    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchUpdateRequest".
2013    pub kind: Option<String>,
2014}
2015
2016impl common::RequestValue for ConversionsBatchUpdateRequest {}
2017
2018/// Update Conversions Response.
2019///
2020/// # Activities
2021///
2022/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2023/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2024///
2025/// * [batchupdate conversions](ConversionBatchupdateCall) (response)
2026#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2027#[serde_with::serde_as]
2028#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2029pub struct ConversionsBatchUpdateResponse {
2030    /// Indicates that some or all conversions failed to update.
2031    #[serde(rename = "hasFailures")]
2032    pub has_failures: Option<bool>,
2033    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchUpdateResponse".
2034    pub kind: Option<String>,
2035    /// The update status of each conversion. Statuses are returned in the same order that conversions are updated.
2036    pub status: Option<Vec<ConversionStatus>>,
2037}
2038
2039impl common::ResponseResult for ConversionsBatchUpdateResponse {}
2040
2041/// Country List Response
2042///
2043/// # Activities
2044///
2045/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2047///
2048/// * [list countries](CountryListCall) (response)
2049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2050#[serde_with::serde_as]
2051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2052pub struct CountriesListResponse {
2053    /// Country collection.
2054    pub countries: Option<Vec<Country>>,
2055    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse".
2056    pub kind: Option<String>,
2057}
2058
2059impl common::ResponseResult for CountriesListResponse {}
2060
2061/// Contains information about a country that can be targeted by ads.
2062///
2063/// # Activities
2064///
2065/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2066/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2067///
2068/// * [get countries](CountryGetCall) (response)
2069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2070#[serde_with::serde_as]
2071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2072pub struct Country {
2073    /// Country code.
2074    #[serde(rename = "countryCode")]
2075    pub country_code: Option<String>,
2076    /// DART ID of this country. This is the ID used for targeting and generating reports.
2077    #[serde(rename = "dartId")]
2078    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2079    pub dart_id: Option<i64>,
2080    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#country".
2081    pub kind: Option<String>,
2082    /// Name of this country.
2083    pub name: Option<String>,
2084    /// Whether ad serving supports secure servers in this country.
2085    #[serde(rename = "sslEnabled")]
2086    pub ssl_enabled: Option<bool>,
2087}
2088
2089impl common::ResponseResult for Country {}
2090
2091/// Contains properties of a Creative.
2092///
2093/// # Activities
2094///
2095/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2096/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2097///
2098/// * [get creatives](CreativeGetCall) (response)
2099/// * [insert creatives](CreativeInsertCall) (request|response)
2100/// * [list creatives](CreativeListCall) (none)
2101/// * [patch creatives](CreativePatchCall) (request|response)
2102/// * [update creatives](CreativeUpdateCall) (request|response)
2103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2104#[serde_with::serde_as]
2105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2106pub struct Creative {
2107    /// Account ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types.
2108    #[serde(rename = "accountId")]
2109    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2110    pub account_id: Option<i64>,
2111    /// Whether the creative is active. Applicable to all creative types.
2112    pub active: Option<bool>,
2113    /// Ad parameters user for VPAID creative. This is a read-only field. Applicable to the following creative types: all VPAID.
2114    #[serde(rename = "adParameters")]
2115    pub ad_parameters: Option<String>,
2116    /// Keywords for a Rich Media creative. Keywords let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use keywords to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2117    #[serde(rename = "adTagKeys")]
2118    pub ad_tag_keys: Option<Vec<String>>,
2119    /// Additional sizes associated with a responsive creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. Applicable to DISPLAY creatives when the primary asset type is HTML_IMAGE.
2120    #[serde(rename = "additionalSizes")]
2121    pub additional_sizes: Option<Vec<Size>>,
2122    /// Advertiser ID of this creative. This is a required field. Applicable to all creative types.
2123    #[serde(rename = "advertiserId")]
2124    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2125    pub advertiser_id: Option<i64>,
2126    /// Whether script access is allowed for this creative. This is a read-only and deprecated field which will automatically be set to true on update. Applicable to the following creative types: FLASH_INPAGE.
2127    #[serde(rename = "allowScriptAccess")]
2128    pub allow_script_access: Option<bool>,
2129    /// Whether the creative is archived. Applicable to all creative types.
2130    pub archived: Option<bool>,
2131    /// Type of artwork used for the creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2132    #[serde(rename = "artworkType")]
2133    pub artwork_type: Option<String>,
2134    /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types.
2135    #[serde(rename = "authoringSource")]
2136    pub authoring_source: Option<String>,
2137    /// Authoring tool for HTML5 banner creatives. This is a read-only field. Applicable to the following creative types: HTML5_BANNER.
2138    #[serde(rename = "authoringTool")]
2139    pub authoring_tool: Option<String>,
2140    /// Whether images are automatically advanced for image gallery creatives. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY.
2141    #[serde(rename = "autoAdvanceImages")]
2142    pub auto_advance_images: Option<bool>,
2143    /// The 6-character HTML color code, beginning with #, for the background of the window area where the Flash file is displayed. Default is white. Applicable to the following creative types: FLASH_INPAGE.
2144    #[serde(rename = "backgroundColor")]
2145    pub background_color: Option<String>,
2146    /// Click-through URL for backup image. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE.
2147    #[serde(rename = "backupImageClickThroughUrl")]
2148    pub backup_image_click_through_url: Option<CreativeClickThroughUrl>,
2149    /// List of feature dependencies that will cause a backup image to be served if the browser that serves the ad does not support them. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative asset correctly. This field is initially auto-generated to contain all features detected by Campaign Manager for all the assets of this creative and can then be modified by the client. To reset this field, copy over all the creativeAssets' detected features. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2150    #[serde(rename = "backupImageFeatures")]
2151    pub backup_image_features: Option<Vec<String>>,
2152    /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: DISPLAY when the primary asset type is not HTML_IMAGE.
2153    #[serde(rename = "backupImageReportingLabel")]
2154    pub backup_image_reporting_label: Option<String>,
2155    /// Target window for backup image. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2156    #[serde(rename = "backupImageTargetWindow")]
2157    pub backup_image_target_window: Option<TargetWindow>,
2158    /// Click tags of the creative. For DISPLAY, FLASH_INPAGE, and HTML5_BANNER creatives, this is a subset of detected click tags for the assets associated with this creative. After creating a flash asset, detected click tags will be returned in the creativeAssetMetadata. When inserting the creative, populate the creative clickTags field using the creativeAssetMetadata.clickTags field. For DISPLAY_IMAGE_GALLERY creatives, there should be exactly one entry in this list for each image creative asset. A click tag is matched with a corresponding creative asset by matching the clickTag.name field with the creativeAsset.assetIdentifier.name field. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2159    #[serde(rename = "clickTags")]
2160    pub click_tags: Option<Vec<ClickTag>>,
2161    /// Industry standard ID assigned to creative for reach and frequency. Applicable to INSTREAM_VIDEO_REDIRECT creatives.
2162    #[serde(rename = "commercialId")]
2163    pub commercial_id: Option<String>,
2164    /// List of companion creatives assigned to an in-Stream video creative. Acceptable values include IDs of existing flash and image creatives. Applicable to the following creative types: all VPAID, all INSTREAM_AUDIO and all INSTREAM_VIDEO with dynamicAssetSelection set to false.
2165    #[serde(rename = "companionCreatives")]
2166    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
2167    pub companion_creatives: Option<Vec<i64>>,
2168    /// Compatibilities associated with this creative. This is a read-only field. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices or in mobile apps for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. Only pre-existing creatives may have these compatibilities since new creatives will either be assigned DISPLAY or DISPLAY_INTERSTITIAL instead. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. IN_STREAM_AUDIO refers to rendering in in-stream audio ads developed with the VAST standard. Applicable to all creative types.
2169    ///
2170    /// Acceptable values are:
2171    /// - "APP"
2172    /// - "APP_INTERSTITIAL"
2173    /// - "IN_STREAM_VIDEO"
2174    /// - "IN_STREAM_AUDIO"
2175    /// - "DISPLAY"
2176    /// - "DISPLAY_INTERSTITIAL"
2177    pub compatibility: Option<Vec<String>>,
2178    /// Whether Flash assets associated with the creative need to be automatically converted to HTML5. This flag is enabled by default and users can choose to disable it if they don't want the system to generate and use HTML5 asset for this creative. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2179    #[serde(rename = "convertFlashToHtml5")]
2180    pub convert_flash_to_html5: Option<bool>,
2181    /// List of counter events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID.
2182    #[serde(rename = "counterCustomEvents")]
2183    pub counter_custom_events: Option<Vec<CreativeCustomEvent>>,
2184    /// Required if dynamicAssetSelection is true.
2185    #[serde(rename = "creativeAssetSelection")]
2186    pub creative_asset_selection: Option<CreativeAssetSelection>,
2187    /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT
2188    #[serde(rename = "creativeAssets")]
2189    pub creative_assets: Option<Vec<CreativeAsset>>,
2190    /// Creative field assignments for this creative. Applicable to all creative types.
2191    #[serde(rename = "creativeFieldAssignments")]
2192    pub creative_field_assignments: Option<Vec<CreativeFieldAssignment>>,
2193    /// Custom key-values for a Rich Media creative. Key-values let you customize the creative settings of a Rich Media ad running on your site without having to contact the advertiser. You can use key-values to dynamically change the look or functionality of a creative. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2194    #[serde(rename = "customKeyValues")]
2195    pub custom_key_values: Option<Vec<String>>,
2196    /// Set this to true to enable the use of rules to target individual assets in this creative. When set to true creativeAssetSelection must be set. This also controls asset-level companions. When this is true, companion creatives should be assigned to creative assets. Learn more. Applicable to INSTREAM_VIDEO creatives.
2197    #[serde(rename = "dynamicAssetSelection")]
2198    pub dynamic_asset_selection: Option<bool>,
2199    /// List of exit events configured for the creative. For DISPLAY and DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags, For DISPLAY, an event is also created from the backupImageReportingLabel. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2200    #[serde(rename = "exitCustomEvents")]
2201    pub exit_custom_events: Option<Vec<CreativeCustomEvent>>,
2202    /// OpenWindow FSCommand of this creative. This lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. This is only triggered if allowScriptAccess field is true. Applicable to the following creative types: FLASH_INPAGE.
2203    #[serde(rename = "fsCommand")]
2204    pub fs_command: Option<FsCommand>,
2205    /// HTML code for the creative. This is a required field when applicable. This field is ignored if htmlCodeLocked is true. Applicable to the following creative types: all CUSTOM, FLASH_INPAGE, and HTML5_BANNER, and all RICH_MEDIA.
2206    #[serde(rename = "htmlCode")]
2207    pub html_code: Option<String>,
2208    /// Whether HTML code is generated by Campaign Manager or manually entered. Set to true to ignore changes to htmlCode. Applicable to the following creative types: FLASH_INPAGE and HTML5_BANNER.
2209    #[serde(rename = "htmlCodeLocked")]
2210    pub html_code_locked: Option<bool>,
2211    /// ID of this creative. This is a read-only, auto-generated field. Applicable to all creative types.
2212    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2213    pub id: Option<i64>,
2214    /// Dimension value for the ID of this creative. This is a read-only field. Applicable to all creative types.
2215    #[serde(rename = "idDimensionValue")]
2216    pub id_dimension_value: Option<DimensionValue>,
2217    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creative".
2218    pub kind: Option<String>,
2219    /// Creative last modification information. This is a read-only field. Applicable to all creative types.
2220    #[serde(rename = "lastModifiedInfo")]
2221    pub last_modified_info: Option<LastModifiedInfo>,
2222    /// Latest Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2223    #[serde(rename = "latestTraffickedCreativeId")]
2224    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2225    pub latest_trafficked_creative_id: Option<i64>,
2226    /// Description of the audio or video ad. Applicable to the following creative types: all INSTREAM_VIDEO, INSTREAM_AUDIO, and all VPAID.
2227    #[serde(rename = "mediaDescription")]
2228    pub media_description: Option<String>,
2229    /// Creative audio or video duration in seconds. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO, INSTREAM_AUDIO, all RICH_MEDIA, and all VPAID.
2230    #[serde(rename = "mediaDuration")]
2231    pub media_duration: Option<f32>,
2232    /// Name of the creative. This is a required field and must be less than 256 characters long. Applicable to all creative types.
2233    pub name: Option<String>,
2234    /// Override CSS value for rich media creatives. Applicable to the following creative types: all RICH_MEDIA.
2235    #[serde(rename = "overrideCss")]
2236    pub override_css: Option<String>,
2237    /// The asset ID of the polite load image asset. Applicable to the creative type: DISPLAY.
2238    #[serde(rename = "politeLoadAssetId")]
2239    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2240    pub polite_load_asset_id: Option<i64>,
2241    /// Amount of time to play the video before counting a view. Applicable to the following creative types: all INSTREAM_VIDEO.
2242    #[serde(rename = "progressOffset")]
2243    pub progress_offset: Option<VideoOffset>,
2244    /// URL of hosted image or hosted video or another ad tag. For INSTREAM_VIDEO_REDIRECT creatives this is the in-stream video redirect URL. The standard for a VAST (Video Ad Serving Template) ad response allows for a redirect link to another VAST 2.0 or 3.0 call. This is a required field when applicable. Applicable to the following creative types: DISPLAY_REDIRECT, INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO_REDIRECT
2245    #[serde(rename = "redirectUrl")]
2246    pub redirect_url: Option<String>,
2247    /// ID of current rendering version. This is a read-only field. Applicable to all creative types.
2248    #[serde(rename = "renderingId")]
2249    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2250    pub rendering_id: Option<i64>,
2251    /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types.
2252    #[serde(rename = "renderingIdDimensionValue")]
2253    pub rendering_id_dimension_value: Option<DimensionValue>,
2254    /// The minimum required Flash plugin version for this creative. For example, 11.2.202.235. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2255    #[serde(rename = "requiredFlashPluginVersion")]
2256    pub required_flash_plugin_version: Option<String>,
2257    /// The internal Flash version for this creative as calculated by Studio. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2258    #[serde(rename = "requiredFlashVersion")]
2259    pub required_flash_version: Option<i32>,
2260    /// Size associated with this creative. When inserting or updating a creative either the size ID field or size width and height fields can be used. This is a required field when applicable; however for IMAGE, FLASH_INPAGE creatives, and for DISPLAY creatives with a primary asset of type HTML_IMAGE, if left blank, this field will be automatically set using the actual size of the associated image assets. Applicable to the following creative types: DISPLAY, DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA.
2261    pub size: Option<Size>,
2262    /// Amount of time to play the video before the skip button appears. Applicable to the following creative types: all INSTREAM_VIDEO.
2263    #[serde(rename = "skipOffset")]
2264    pub skip_offset: Option<VideoOffset>,
2265    /// Whether the user can choose to skip the creative. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID.
2266    pub skippable: Option<bool>,
2267    /// Whether the creative is SSL-compliant. This is a read-only field. Applicable to all creative types.
2268    #[serde(rename = "sslCompliant")]
2269    pub ssl_compliant: Option<bool>,
2270    /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types.
2271    #[serde(rename = "sslOverride")]
2272    pub ssl_override: Option<bool>,
2273    /// Studio advertiser ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2274    #[serde(rename = "studioAdvertiserId")]
2275    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2276    pub studio_advertiser_id: Option<i64>,
2277    /// Studio creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2278    #[serde(rename = "studioCreativeId")]
2279    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2280    pub studio_creative_id: Option<i64>,
2281    /// Studio trafficked creative ID associated with rich media and VPAID creatives. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2282    #[serde(rename = "studioTraffickedCreativeId")]
2283    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2284    pub studio_trafficked_creative_id: Option<i64>,
2285    /// Subaccount ID of this creative. This field, if left unset, will be auto-generated for both insert and update operations. Applicable to all creative types.
2286    #[serde(rename = "subaccountId")]
2287    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2288    pub subaccount_id: Option<i64>,
2289    /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA.
2290    #[serde(rename = "thirdPartyBackupImageImpressionsUrl")]
2291    pub third_party_backup_image_impressions_url: Option<String>,
2292    /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA.
2293    #[serde(rename = "thirdPartyRichMediaImpressionsUrl")]
2294    pub third_party_rich_media_impressions_url: Option<String>,
2295    /// Third-party URLs for tracking in-stream creative events. Applicable to the following creative types: all INSTREAM_VIDEO, all INSTREAM_AUDIO, and all VPAID.
2296    #[serde(rename = "thirdPartyUrls")]
2297    pub third_party_urls: Option<Vec<ThirdPartyTrackingUrl>>,
2298    /// List of timer events configured for the creative. For DISPLAY_IMAGE_GALLERY creatives, these are read-only and auto-generated from clickTags. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset is not HTML_IMAGE.
2299    #[serde(rename = "timerCustomEvents")]
2300    pub timer_custom_events: Option<Vec<CreativeCustomEvent>>,
2301    /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID.
2302    #[serde(rename = "totalFileSize")]
2303    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2304    pub total_file_size: Option<i64>,
2305    /// Type of this creative. This is a required field. Applicable to all creative types.
2306    ///
2307    /// Note: FLASH_INPAGE, HTML5_BANNER, and IMAGE are only used for existing creatives. New creatives should use DISPLAY as a replacement for these types.
2308    #[serde(rename = "type")]
2309    pub type_: Option<String>,
2310    /// A Universal Ad ID as per the VAST 4.0 spec. Applicable to the following creative types: INSTREAM_AUDIO and INSTREAM_VIDEO and VPAID.
2311    #[serde(rename = "universalAdId")]
2312    pub universal_ad_id: Option<UniversalAdId>,
2313    /// The version number helps you keep track of multiple versions of your creative in your reports. The version number will always be auto-generated during insert operations to start at 1. For tracking creatives the version cannot be incremented and will always remain at 1. For all other creative types the version can be incremented only by 1 during update operations. In addition, the version will be automatically incremented by 1 when undergoing Rich Media creative merging. Applicable to all creative types.
2314    pub version: Option<i32>,
2315}
2316
2317impl common::RequestValue for Creative {}
2318impl common::Resource for Creative {}
2319impl common::ResponseResult for Creative {}
2320
2321/// Creative Asset.
2322///
2323/// # Activities
2324///
2325/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2326/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2327///
2328/// * [insert creative assets](CreativeAssetInsertCall) (none)
2329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2330#[serde_with::serde_as]
2331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2332pub struct CreativeAsset {
2333    /// Whether ActionScript3 is enabled for the flash asset. This is a read-only field. Applicable to the following creative type: FLASH_INPAGE. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2334    #[serde(rename = "actionScript3")]
2335    pub action_script3: Option<bool>,
2336    /// Whether the video or audio asset is active. This is a read-only field for VPAID_NON_LINEAR_VIDEO assets. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and all VPAID.
2337    pub active: Option<bool>,
2338    /// Additional sizes associated with this creative asset. HTML5 asset generated by compatible software such as GWD will be able to support more sizes this creative asset can render.
2339    #[serde(rename = "additionalSizes")]
2340    pub additional_sizes: Option<Vec<Size>>,
2341    /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_DISPLAY_MULTI_FLOATING_INTERSTITIAL.
2342    pub alignment: Option<String>,
2343    /// Artwork type of rich media creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.
2344    #[serde(rename = "artworkType")]
2345    pub artwork_type: Option<String>,
2346    /// Identifier of this asset. This is the same identifier returned during creative asset insert operation. This is a required field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT.
2347    #[serde(rename = "assetIdentifier")]
2348    pub asset_identifier: Option<CreativeAssetId>,
2349    /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA.
2350    #[serde(rename = "backupImageExit")]
2351    pub backup_image_exit: Option<CreativeCustomEvent>,
2352    /// Detected bit-rate for audio or video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and all VPAID.
2353    #[serde(rename = "bitRate")]
2354    pub bit_rate: Option<i32>,
2355    /// Rich media child asset type. This is a read-only field. Applicable to the following creative types: all VPAID.
2356    #[serde(rename = "childAssetType")]
2357    pub child_asset_type: Option<String>,
2358    /// Size of an asset when collapsed. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN.
2359    #[serde(rename = "collapsedSize")]
2360    pub collapsed_size: Option<Size>,
2361    /// List of companion creatives assigned to an in-stream video creative asset. Acceptable values include IDs of existing flash and image creatives. Applicable to INSTREAM_VIDEO creative type with dynamicAssetSelection set to true.
2362    #[serde(rename = "companionCreativeIds")]
2363    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
2364    pub companion_creative_ids: Option<Vec<i64>>,
2365    /// Custom start time in seconds for making the asset visible. Applicable to the following creative types: all RICH_MEDIA. Value must be greater than or equal to 0.
2366    #[serde(rename = "customStartTimeValue")]
2367    pub custom_start_time_value: Option<i32>,
2368    /// List of feature dependencies for the creative asset that are detected by Campaign Manager. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field. Applicable to the following creative types: HTML5_BANNER. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2369    #[serde(rename = "detectedFeatures")]
2370    pub detected_features: Option<Vec<String>>,
2371    /// Type of rich media asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.
2372    #[serde(rename = "displayType")]
2373    pub display_type: Option<String>,
2374    /// Duration in seconds for which an asset will be displayed. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and VPAID_LINEAR_VIDEO. Value must be greater than or equal to 1.
2375    pub duration: Option<i32>,
2376    /// Duration type for which an asset will be displayed. Applicable to the following creative types: all RICH_MEDIA.
2377    #[serde(rename = "durationType")]
2378    pub duration_type: Option<String>,
2379    /// Detected expanded dimension for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID.
2380    #[serde(rename = "expandedDimension")]
2381    pub expanded_dimension: Option<Size>,
2382    /// File size associated with this creative asset. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT.
2383    #[serde(rename = "fileSize")]
2384    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2385    pub file_size: Option<i64>,
2386    /// Flash version of the asset. This is a read-only field. Applicable to the following creative types: FLASH_INPAGE, all RICH_MEDIA, and all VPAID. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2387    #[serde(rename = "flashVersion")]
2388    pub flash_version: Option<i32>,
2389    /// Whether to hide Flash objects flag for an asset. Applicable to the following creative types: all RICH_MEDIA.
2390    #[serde(rename = "hideFlashObjects")]
2391    pub hide_flash_objects: Option<bool>,
2392    /// Whether to hide selection boxes flag for an asset. Applicable to the following creative types: all RICH_MEDIA.
2393    #[serde(rename = "hideSelectionBoxes")]
2394    pub hide_selection_boxes: Option<bool>,
2395    /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.
2396    #[serde(rename = "horizontallyLocked")]
2397    pub horizontally_locked: Option<bool>,
2398    /// Numeric ID of this creative asset. This is a required field and should not be modified. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT.
2399    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2400    pub id: Option<i64>,
2401    /// Dimension value for the ID of the asset. This is a read-only, auto-generated field.
2402    #[serde(rename = "idDimensionValue")]
2403    pub id_dimension_value: Option<DimensionValue>,
2404    /// Detected duration for audio or video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and all VPAID.
2405    #[serde(rename = "mediaDuration")]
2406    pub media_duration: Option<f32>,
2407    /// Detected MIME type for audio or video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and all VPAID.
2408    #[serde(rename = "mimeType")]
2409    pub mime_type: Option<String>,
2410    /// Offset position for an asset in collapsed mode. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID. Additionally, only applicable to assets whose displayType is ASSET_DISPLAY_TYPE_EXPANDING or ASSET_DISPLAY_TYPE_PEEL_DOWN.
2411    pub offset: Option<OffsetPosition>,
2412    /// Orientation of video asset. This is a read-only, auto-generated field.
2413    pub orientation: Option<String>,
2414    /// Whether the backup asset is original or changed by the user in Campaign Manager. Applicable to the following creative types: all RICH_MEDIA.
2415    #[serde(rename = "originalBackup")]
2416    pub original_backup: Option<bool>,
2417    /// Offset position for an asset. Applicable to the following creative types: all RICH_MEDIA.
2418    pub position: Option<OffsetPosition>,
2419    /// Offset left unit for an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.
2420    #[serde(rename = "positionLeftUnit")]
2421    pub position_left_unit: Option<String>,
2422    /// Offset top unit for an asset. This is a read-only field if the asset displayType is ASSET_DISPLAY_TYPE_OVERLAY. Applicable to the following creative types: all RICH_MEDIA.
2423    #[serde(rename = "positionTopUnit")]
2424    pub position_top_unit: Option<String>,
2425    /// Progressive URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID.
2426    #[serde(rename = "progressiveServingUrl")]
2427    pub progressive_serving_url: Option<String>,
2428    /// Whether the asset pushes down other content. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable when the asset offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height.
2429    pub pushdown: Option<bool>,
2430    /// Pushdown duration in seconds for an asset. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable when the asset pushdown field is true, the offsets are 0, the collapsedSize.width matches size.width, and the collapsedSize.height is less than size.height. Acceptable values are 0 to 9.99, inclusive.
2431    #[serde(rename = "pushdownDuration")]
2432    pub pushdown_duration: Option<f32>,
2433    /// Role of the asset in relation to creative. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT. This is a required field.
2434    /// PRIMARY applies to DISPLAY, FLASH_INPAGE, HTML5_BANNER, IMAGE, DISPLAY_IMAGE_GALLERY, all RICH_MEDIA (which may contain multiple primary assets), and all VPAID creatives.
2435    /// BACKUP_IMAGE applies to FLASH_INPAGE, HTML5_BANNER, all RICH_MEDIA, and all VPAID creatives. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2436    /// ADDITIONAL_IMAGE and ADDITIONAL_FLASH apply to FLASH_INPAGE creatives.
2437    /// OTHER refers to assets from sources other than Campaign Manager, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives.
2438    /// PARENT_VIDEO refers to videos uploaded by the user in Campaign Manager and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives.
2439    /// TRANSCODED_VIDEO refers to videos transcoded by Campaign Manager from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives.
2440    /// ALTERNATE_VIDEO refers to the Campaign Manager representation of child asset videos from Studio, and is applicable to VPAID_LINEAR_VIDEO creatives. These cannot be added or removed within Campaign Manager.
2441    /// For VPAID_LINEAR_VIDEO creatives, PARENT_VIDEO, TRANSCODED_VIDEO and ALTERNATE_VIDEO assets that are marked active serve as backup in case the VPAID creative cannot be served. Only PARENT_VIDEO assets can be added or removed for an INSTREAM_VIDEO or VPAID_LINEAR_VIDEO creative.
2442    /// PARENT_AUDIO refers to audios uploaded by the user in Campaign Manager and is applicable to INSTREAM_AUDIO creatives.
2443    /// TRANSCODED_AUDIO refers to audios transcoded by Campaign Manager from PARENT_AUDIO assets and is applicable to INSTREAM_AUDIO creatives.
2444    pub role: Option<String>,
2445    /// Size associated with this creative asset. This is a required field when applicable; however for IMAGE and FLASH_INPAGE, creatives if left blank, this field will be automatically set using the actual size of the associated image asset. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY, FLASH_INPAGE, HTML5_BANNER, IMAGE, and all RICH_MEDIA. Applicable to DISPLAY when the primary asset type is not HTML_IMAGE.
2446    pub size: Option<Size>,
2447    /// Whether the asset is SSL-compliant. This is a read-only field. Applicable to all but the following creative types: all REDIRECT and TRACKING_TEXT.
2448    #[serde(rename = "sslCompliant")]
2449    pub ssl_compliant: Option<bool>,
2450    /// Initial wait time type before making the asset visible. Applicable to the following creative types: all RICH_MEDIA.
2451    #[serde(rename = "startTimeType")]
2452    pub start_time_type: Option<String>,
2453    /// Streaming URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID.
2454    #[serde(rename = "streamingServingUrl")]
2455    pub streaming_serving_url: Option<String>,
2456    /// Whether the asset is transparent. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable to HTML5 assets.
2457    pub transparency: Option<bool>,
2458    /// Whether the asset is vertically locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA.
2459    #[serde(rename = "verticallyLocked")]
2460    pub vertically_locked: Option<bool>,
2461    /// Window mode options for flash assets. Applicable to the following creative types: FLASH_INPAGE, RICH_MEDIA_DISPLAY_EXPANDING, RICH_MEDIA_IM_EXPAND, RICH_MEDIA_DISPLAY_BANNER, and RICH_MEDIA_INPAGE_FLOATING.
2462    #[serde(rename = "windowMode")]
2463    pub window_mode: Option<String>,
2464    /// zIndex value of an asset. Applicable to the following creative types: all RICH_MEDIA.Additionally, only applicable to assets whose displayType is NOT one of the following types: ASSET_DISPLAY_TYPE_INPAGE or ASSET_DISPLAY_TYPE_OVERLAY. Acceptable values are -999999999 to 999999999, inclusive.
2465    #[serde(rename = "zIndex")]
2466    pub z_index: Option<i32>,
2467    /// File name of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER.
2468    #[serde(rename = "zipFilename")]
2469    pub zip_filename: Option<String>,
2470    /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER.
2471    #[serde(rename = "zipFilesize")]
2472    pub zip_filesize: Option<String>,
2473}
2474
2475impl common::Resource for CreativeAsset {}
2476
2477/// Creative Asset ID.
2478///
2479/// This type is not used in any activity, and only used as *part* of another schema.
2480///
2481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2482#[serde_with::serde_as]
2483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2484pub struct CreativeAssetId {
2485    /// Name of the creative asset. This is a required field while inserting an asset. After insertion, this assetIdentifier is used to identify the uploaded asset. Characters in the name must be alphanumeric or one of the following: ".-_ ". Spaces are allowed.
2486    pub name: Option<String>,
2487    /// Type of asset to upload. This is a required field. FLASH and IMAGE are no longer supported for new uploads. All image assets should use HTML_IMAGE.
2488    #[serde(rename = "type")]
2489    pub type_: Option<String>,
2490}
2491
2492impl common::Part for CreativeAssetId {}
2493
2494/// CreativeAssets contains properties of a creative asset file which will be uploaded or has already been uploaded. Refer to the creative sample code for how to upload assets and insert a creative.
2495///
2496/// # Activities
2497///
2498/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2499/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2500///
2501/// * [insert creative assets](CreativeAssetInsertCall) (request|response)
2502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2503#[serde_with::serde_as]
2504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2505pub struct CreativeAssetMetadata {
2506    /// ID of the creative asset. This is a required field.
2507    #[serde(rename = "assetIdentifier")]
2508    pub asset_identifier: Option<CreativeAssetId>,
2509    /// List of detected click tags for assets. This is a read-only auto-generated field.
2510    #[serde(rename = "clickTags")]
2511    pub click_tags: Option<Vec<ClickTag>>,
2512    /// List of feature dependencies for the creative asset that are detected by Campaign Manager. Feature dependencies are features that a browser must be able to support in order to render your HTML5 creative correctly. This is a read-only, auto-generated field.
2513    #[serde(rename = "detectedFeatures")]
2514    pub detected_features: Option<Vec<String>>,
2515    /// Numeric ID of the asset. This is a read-only, auto-generated field.
2516    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2517    pub id: Option<i64>,
2518    /// Dimension value for the numeric ID of the asset. This is a read-only, auto-generated field.
2519    #[serde(rename = "idDimensionValue")]
2520    pub id_dimension_value: Option<DimensionValue>,
2521    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeAssetMetadata".
2522    pub kind: Option<String>,
2523    /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field.
2524    ///
2525    /// Possible values are:
2526    /// - "ADMOB_REFERENCED"
2527    /// - "ASSET_FORMAT_UNSUPPORTED_DCM"
2528    /// - "ASSET_INVALID"
2529    /// - "CLICK_TAG_HARD_CODED"
2530    /// - "CLICK_TAG_INVALID"
2531    /// - "CLICK_TAG_IN_GWD"
2532    /// - "CLICK_TAG_MISSING"
2533    /// - "CLICK_TAG_MORE_THAN_ONE"
2534    /// - "CLICK_TAG_NON_TOP_LEVEL"
2535    /// - "COMPONENT_UNSUPPORTED_DCM"
2536    /// - "ENABLER_UNSUPPORTED_METHOD_DCM"
2537    /// - "EXTERNAL_FILE_REFERENCED"
2538    /// - "FILE_DETAIL_EMPTY"
2539    /// - "FILE_TYPE_INVALID"
2540    /// - "GWD_PROPERTIES_INVALID"
2541    /// - "HTML5_FEATURE_UNSUPPORTED"
2542    /// - "LINKED_FILE_NOT_FOUND"
2543    /// - "MAX_FLASH_VERSION_11"
2544    /// - "MRAID_REFERENCED"
2545    /// - "NOT_SSL_COMPLIANT"
2546    /// - "ORPHANED_ASSET"
2547    /// - "PRIMARY_HTML_MISSING"
2548    /// - "SVG_INVALID"
2549    /// - "ZIP_INVALID"
2550    #[serde(rename = "warnedValidationRules")]
2551    pub warned_validation_rules: Option<Vec<String>>,
2552}
2553
2554impl common::RequestValue for CreativeAssetMetadata {}
2555impl common::ResponseResult for CreativeAssetMetadata {}
2556
2557/// Encapsulates the list of rules for asset selection and a default asset in case none of the rules match. Applicable to INSTREAM_VIDEO creatives.
2558///
2559/// This type is not used in any activity, and only used as *part* of another schema.
2560///
2561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2562#[serde_with::serde_as]
2563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2564pub struct CreativeAssetSelection {
2565    /// A creativeAssets[].id. This should refer to one of the parent assets in this creative, and will be served if none of the rules match. This is a required field.
2566    #[serde(rename = "defaultAssetId")]
2567    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2568    pub default_asset_id: Option<i64>,
2569    /// Rules determine which asset will be served to a viewer. Rules will be evaluated in the order in which they are stored in this list. This list must contain at least one rule. Applicable to INSTREAM_VIDEO creatives.
2570    pub rules: Option<Vec<Rule>>,
2571}
2572
2573impl common::Part for CreativeAssetSelection {}
2574
2575/// Creative Assignment.
2576///
2577/// This type is not used in any activity, and only used as *part* of another schema.
2578///
2579#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2580#[serde_with::serde_as]
2581#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2582pub struct CreativeAssignment {
2583    /// Whether this creative assignment is active. When true, the creative will be included in the ad's rotation.
2584    pub active: Option<bool>,
2585    /// Whether applicable event tags should fire when this creative assignment is rendered. If this value is unset when the ad is inserted or updated, it will default to true for all creative types EXCEPT for INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and INSTREAM_VIDEO.
2586    #[serde(rename = "applyEventTags")]
2587    pub apply_event_tags: Option<bool>,
2588    /// Click-through URL of the creative assignment.
2589    #[serde(rename = "clickThroughUrl")]
2590    pub click_through_url: Option<ClickThroughUrl>,
2591    /// Companion creative overrides for this creative assignment. Applicable to video ads.
2592    #[serde(rename = "companionCreativeOverrides")]
2593    pub companion_creative_overrides: Option<Vec<CompanionClickThroughOverride>>,
2594    /// Creative group assignments for this creative assignment. Only one assignment per creative group number is allowed for a maximum of two assignments.
2595    #[serde(rename = "creativeGroupAssignments")]
2596    pub creative_group_assignments: Option<Vec<CreativeGroupAssignment>>,
2597    /// ID of the creative to be assigned. This is a required field.
2598    #[serde(rename = "creativeId")]
2599    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2600    pub creative_id: Option<i64>,
2601    /// Dimension value for the ID of the creative. This is a read-only, auto-generated field.
2602    #[serde(rename = "creativeIdDimensionValue")]
2603    pub creative_id_dimension_value: Option<DimensionValue>,
2604    /// Date and time that the assigned creative should stop serving. Must be later than the start time.
2605    #[serde(rename = "endTime")]
2606    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2607    /// Rich media exit overrides for this creative assignment.
2608    /// Applicable when the creative type is any of the following:
2609    /// - DISPLAY
2610    /// - RICH_MEDIA_INPAGE
2611    /// - RICH_MEDIA_INPAGE_FLOATING
2612    /// - RICH_MEDIA_IM_EXPAND
2613    /// - RICH_MEDIA_EXPANDING
2614    /// - RICH_MEDIA_INTERSTITIAL_FLOAT
2615    /// - RICH_MEDIA_MOBILE_IN_APP
2616    /// - RICH_MEDIA_MULTI_FLOATING
2617    /// - RICH_MEDIA_PEEL_DOWN
2618    /// - VPAID_LINEAR
2619    /// - VPAID_NON_LINEAR
2620    #[serde(rename = "richMediaExitOverrides")]
2621    pub rich_media_exit_overrides: Option<Vec<RichMediaExitOverride>>,
2622    /// Sequence number of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_SEQUENTIAL. Acceptable values are 1 to 65535, inclusive.
2623    pub sequence: Option<i32>,
2624    /// Whether the creative to be assigned is SSL-compliant. This is a read-only field that is auto-generated when the ad is inserted or updated.
2625    #[serde(rename = "sslCompliant")]
2626    pub ssl_compliant: Option<bool>,
2627    /// Date and time that the assigned creative should start serving.
2628    #[serde(rename = "startTime")]
2629    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2630    /// Weight of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_RANDOM. Value must be greater than or equal to 1.
2631    pub weight: Option<i32>,
2632}
2633
2634impl common::Part for CreativeAssignment {}
2635
2636/// Click-through URL
2637///
2638/// This type is not used in any activity, and only used as *part* of another schema.
2639///
2640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2641#[serde_with::serde_as]
2642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2643pub struct CreativeClickThroughUrl {
2644    /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows:
2645    /// - If landingPageId is specified then that landing page's URL is assigned to this field.
2646    /// - Otherwise, the customClickThroughUrl is assigned to this field.
2647    #[serde(rename = "computedClickThroughUrl")]
2648    pub computed_click_through_url: Option<String>,
2649    /// Custom click-through URL. Applicable if the landingPageId field is left unset.
2650    #[serde(rename = "customClickThroughUrl")]
2651    pub custom_click_through_url: Option<String>,
2652    /// ID of the landing page for the click-through URL.
2653    #[serde(rename = "landingPageId")]
2654    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2655    pub landing_page_id: Option<i64>,
2656}
2657
2658impl common::Part for CreativeClickThroughUrl {}
2659
2660/// Creative Custom Event.
2661///
2662/// This type is not used in any activity, and only used as *part* of another schema.
2663///
2664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2665#[serde_with::serde_as]
2666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2667pub struct CreativeCustomEvent {
2668    /// Unique ID of this event used by Reporting and Data Transfer. This is a read-only field.
2669    #[serde(rename = "advertiserCustomEventId")]
2670    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2671    pub advertiser_custom_event_id: Option<i64>,
2672    /// User-entered name for the event.
2673    #[serde(rename = "advertiserCustomEventName")]
2674    pub advertiser_custom_event_name: Option<String>,
2675    /// Type of the event. This is a read-only field.
2676    #[serde(rename = "advertiserCustomEventType")]
2677    pub advertiser_custom_event_type: Option<String>,
2678    /// Artwork label column, used to link events in Campaign Manager back to events in Studio. This is a required field and should not be modified after insertion.
2679    #[serde(rename = "artworkLabel")]
2680    pub artwork_label: Option<String>,
2681    /// Artwork type used by the creative.This is a read-only field.
2682    #[serde(rename = "artworkType")]
2683    pub artwork_type: Option<String>,
2684    /// Exit click-through URL for the event. This field is used only for exit events.
2685    #[serde(rename = "exitClickThroughUrl")]
2686    pub exit_click_through_url: Option<CreativeClickThroughUrl>,
2687    /// ID of this event. This is a required field and should not be modified after insertion.
2688    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2689    pub id: Option<i64>,
2690    /// Properties for rich media popup windows. This field is used only for exit events.
2691    #[serde(rename = "popupWindowProperties")]
2692    pub popup_window_properties: Option<PopupWindowProperties>,
2693    /// Target type used by the event.
2694    #[serde(rename = "targetType")]
2695    pub target_type: Option<String>,
2696    /// Video reporting ID, used to differentiate multiple videos in a single creative. This is a read-only field.
2697    #[serde(rename = "videoReportingId")]
2698    pub video_reporting_id: Option<String>,
2699}
2700
2701impl common::Part for CreativeCustomEvent {}
2702
2703/// Contains properties of a creative field.
2704///
2705/// # Activities
2706///
2707/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2709///
2710/// * [delete creative fields](CreativeFieldDeleteCall) (none)
2711/// * [get creative fields](CreativeFieldGetCall) (response)
2712/// * [insert creative fields](CreativeFieldInsertCall) (request|response)
2713/// * [list creative fields](CreativeFieldListCall) (none)
2714/// * [patch creative fields](CreativeFieldPatchCall) (request|response)
2715/// * [update creative fields](CreativeFieldUpdateCall) (request|response)
2716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2717#[serde_with::serde_as]
2718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2719pub struct CreativeField {
2720    /// Account ID of this creative field. This is a read-only field that can be left blank.
2721    #[serde(rename = "accountId")]
2722    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2723    pub account_id: Option<i64>,
2724    /// Advertiser ID of this creative field. This is a required field on insertion.
2725    #[serde(rename = "advertiserId")]
2726    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2727    pub advertiser_id: Option<i64>,
2728    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
2729    #[serde(rename = "advertiserIdDimensionValue")]
2730    pub advertiser_id_dimension_value: Option<DimensionValue>,
2731    /// ID of this creative field. This is a read-only, auto-generated field.
2732    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2733    pub id: Option<i64>,
2734    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField".
2735    pub kind: Option<String>,
2736    /// Name of this creative field. This is a required field and must be less than 256 characters long and unique among creative fields of the same advertiser.
2737    pub name: Option<String>,
2738    /// Subaccount ID of this creative field. This is a read-only field that can be left blank.
2739    #[serde(rename = "subaccountId")]
2740    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2741    pub subaccount_id: Option<i64>,
2742}
2743
2744impl common::RequestValue for CreativeField {}
2745impl common::Resource for CreativeField {}
2746impl common::ResponseResult for CreativeField {}
2747
2748/// Creative Field Assignment.
2749///
2750/// This type is not used in any activity, and only used as *part* of another schema.
2751///
2752#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2753#[serde_with::serde_as]
2754#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2755pub struct CreativeFieldAssignment {
2756    /// ID of the creative field.
2757    #[serde(rename = "creativeFieldId")]
2758    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2759    pub creative_field_id: Option<i64>,
2760    /// ID of the creative field value.
2761    #[serde(rename = "creativeFieldValueId")]
2762    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2763    pub creative_field_value_id: Option<i64>,
2764}
2765
2766impl common::Part for CreativeFieldAssignment {}
2767
2768/// Contains properties of a creative field value.
2769///
2770/// # Activities
2771///
2772/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2773/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2774///
2775/// * [delete creative field values](CreativeFieldValueDeleteCall) (none)
2776/// * [get creative field values](CreativeFieldValueGetCall) (response)
2777/// * [insert creative field values](CreativeFieldValueInsertCall) (request|response)
2778/// * [list creative field values](CreativeFieldValueListCall) (none)
2779/// * [patch creative field values](CreativeFieldValuePatchCall) (request|response)
2780/// * [update creative field values](CreativeFieldValueUpdateCall) (request|response)
2781#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2782#[serde_with::serde_as]
2783#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2784pub struct CreativeFieldValue {
2785    /// ID of this creative field value. This is a read-only, auto-generated field.
2786    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2787    pub id: Option<i64>,
2788    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValue".
2789    pub kind: Option<String>,
2790    /// Value of this creative field value. It needs to be less than 256 characters in length and unique per creative field.
2791    pub value: Option<String>,
2792}
2793
2794impl common::RequestValue for CreativeFieldValue {}
2795impl common::Resource for CreativeFieldValue {}
2796impl common::ResponseResult for CreativeFieldValue {}
2797
2798/// Creative Field Value List Response
2799///
2800/// # Activities
2801///
2802/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2803/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2804///
2805/// * [list creative field values](CreativeFieldValueListCall) (response)
2806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2807#[serde_with::serde_as]
2808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2809pub struct CreativeFieldValuesListResponse {
2810    /// Creative field value collection.
2811    #[serde(rename = "creativeFieldValues")]
2812    pub creative_field_values: Option<Vec<CreativeFieldValue>>,
2813    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValuesListResponse".
2814    pub kind: Option<String>,
2815    /// Pagination token to be used for the next list operation.
2816    #[serde(rename = "nextPageToken")]
2817    pub next_page_token: Option<String>,
2818}
2819
2820impl common::ResponseResult for CreativeFieldValuesListResponse {}
2821
2822/// Creative Field List Response
2823///
2824/// # Activities
2825///
2826/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2827/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2828///
2829/// * [list creative fields](CreativeFieldListCall) (response)
2830#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2831#[serde_with::serde_as]
2832#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2833pub struct CreativeFieldsListResponse {
2834    /// Creative field collection.
2835    #[serde(rename = "creativeFields")]
2836    pub creative_fields: Option<Vec<CreativeField>>,
2837    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse".
2838    pub kind: Option<String>,
2839    /// Pagination token to be used for the next list operation.
2840    #[serde(rename = "nextPageToken")]
2841    pub next_page_token: Option<String>,
2842}
2843
2844impl common::ResponseResult for CreativeFieldsListResponse {}
2845
2846/// Contains properties of a creative group.
2847///
2848/// # Activities
2849///
2850/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2851/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2852///
2853/// * [get creative groups](CreativeGroupGetCall) (response)
2854/// * [insert creative groups](CreativeGroupInsertCall) (request|response)
2855/// * [list creative groups](CreativeGroupListCall) (none)
2856/// * [patch creative groups](CreativeGroupPatchCall) (request|response)
2857/// * [update creative groups](CreativeGroupUpdateCall) (request|response)
2858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2859#[serde_with::serde_as]
2860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2861pub struct CreativeGroup {
2862    /// Account ID of this creative group. This is a read-only field that can be left blank.
2863    #[serde(rename = "accountId")]
2864    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2865    pub account_id: Option<i64>,
2866    /// Advertiser ID of this creative group. This is a required field on insertion.
2867    #[serde(rename = "advertiserId")]
2868    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2869    pub advertiser_id: Option<i64>,
2870    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
2871    #[serde(rename = "advertiserIdDimensionValue")]
2872    pub advertiser_id_dimension_value: Option<DimensionValue>,
2873    /// Subgroup of the creative group. Assign your creative groups to a subgroup in order to filter or manage them more easily. This field is required on insertion and is read-only after insertion. Acceptable values are 1 to 2, inclusive.
2874    #[serde(rename = "groupNumber")]
2875    pub group_number: Option<i32>,
2876    /// ID of this creative group. This is a read-only, auto-generated field.
2877    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2878    pub id: Option<i64>,
2879    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroup".
2880    pub kind: Option<String>,
2881    /// Name of this creative group. This is a required field and must be less than 256 characters long and unique among creative groups of the same advertiser.
2882    pub name: Option<String>,
2883    /// Subaccount ID of this creative group. This is a read-only field that can be left blank.
2884    #[serde(rename = "subaccountId")]
2885    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2886    pub subaccount_id: Option<i64>,
2887}
2888
2889impl common::RequestValue for CreativeGroup {}
2890impl common::Resource for CreativeGroup {}
2891impl common::ResponseResult for CreativeGroup {}
2892
2893/// Creative Group Assignment.
2894///
2895/// This type is not used in any activity, and only used as *part* of another schema.
2896///
2897#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2898#[serde_with::serde_as]
2899#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2900pub struct CreativeGroupAssignment {
2901    /// ID of the creative group to be assigned.
2902    #[serde(rename = "creativeGroupId")]
2903    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2904    pub creative_group_id: Option<i64>,
2905    /// Creative group number of the creative group assignment.
2906    #[serde(rename = "creativeGroupNumber")]
2907    pub creative_group_number: Option<String>,
2908}
2909
2910impl common::Part for CreativeGroupAssignment {}
2911
2912/// Creative Group List Response
2913///
2914/// # Activities
2915///
2916/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2917/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2918///
2919/// * [list creative groups](CreativeGroupListCall) (response)
2920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2921#[serde_with::serde_as]
2922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2923pub struct CreativeGroupsListResponse {
2924    /// Creative group collection.
2925    #[serde(rename = "creativeGroups")]
2926    pub creative_groups: Option<Vec<CreativeGroup>>,
2927    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroupsListResponse".
2928    pub kind: Option<String>,
2929    /// Pagination token to be used for the next list operation.
2930    #[serde(rename = "nextPageToken")]
2931    pub next_page_token: Option<String>,
2932}
2933
2934impl common::ResponseResult for CreativeGroupsListResponse {}
2935
2936/// Creative optimization settings.
2937///
2938/// This type is not used in any activity, and only used as *part* of another schema.
2939///
2940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2941#[serde_with::serde_as]
2942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2943pub struct CreativeOptimizationConfiguration {
2944    /// ID of this creative optimization config. This field is auto-generated when the campaign is inserted or updated. It can be null for existing campaigns.
2945    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2946    pub id: Option<i64>,
2947    /// Name of this creative optimization config. This is a required field and must be less than 129 characters long.
2948    pub name: Option<String>,
2949    /// List of optimization activities associated with this configuration.
2950    #[serde(rename = "optimizationActivitys")]
2951    pub optimization_activitys: Option<Vec<OptimizationActivity>>,
2952    /// Optimization model for this configuration.
2953    #[serde(rename = "optimizationModel")]
2954    pub optimization_model: Option<String>,
2955}
2956
2957impl common::Part for CreativeOptimizationConfiguration {}
2958
2959/// Creative Rotation.
2960///
2961/// This type is not used in any activity, and only used as *part* of another schema.
2962///
2963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2964#[serde_with::serde_as]
2965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2966pub struct CreativeRotation {
2967    /// Creative assignments in this creative rotation.
2968    #[serde(rename = "creativeAssignments")]
2969    pub creative_assignments: Option<Vec<CreativeAssignment>>,
2970    /// Creative optimization configuration that is used by this ad. It should refer to one of the existing optimization configurations in the ad's campaign. If it is unset or set to 0, then the campaign's default optimization configuration will be used for this ad.
2971    #[serde(rename = "creativeOptimizationConfigurationId")]
2972    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2973    pub creative_optimization_configuration_id: Option<i64>,
2974    /// Type of creative rotation. Can be used to specify whether to use sequential or random rotation.
2975    #[serde(rename = "type")]
2976    pub type_: Option<String>,
2977    /// Strategy for calculating weights. Used with CREATIVE_ROTATION_TYPE_RANDOM.
2978    #[serde(rename = "weightCalculationStrategy")]
2979    pub weight_calculation_strategy: Option<String>,
2980}
2981
2982impl common::Part for CreativeRotation {}
2983
2984/// Creative Settings
2985///
2986/// This type is not used in any activity, and only used as *part* of another schema.
2987///
2988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2989#[serde_with::serde_as]
2990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2991pub struct CreativeSettings {
2992    /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long.
2993    #[serde(rename = "iFrameFooter")]
2994    pub i_frame_footer: Option<String>,
2995    /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long.
2996    #[serde(rename = "iFrameHeader")]
2997    pub i_frame_header: Option<String>,
2998}
2999
3000impl common::Part for CreativeSettings {}
3001
3002/// Creative List Response
3003///
3004/// # Activities
3005///
3006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3008///
3009/// * [list creatives](CreativeListCall) (response)
3010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3011#[serde_with::serde_as]
3012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3013pub struct CreativesListResponse {
3014    /// Creative collection.
3015    pub creatives: Option<Vec<Creative>>,
3016    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativesListResponse".
3017    pub kind: Option<String>,
3018    /// Pagination token to be used for the next list operation.
3019    #[serde(rename = "nextPageToken")]
3020    pub next_page_token: Option<String>,
3021}
3022
3023impl common::ResponseResult for CreativesListResponse {}
3024
3025/// Represents fields that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH".
3026///
3027/// This type is not used in any activity, and only used as *part* of another schema.
3028///
3029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3030#[serde_with::serde_as]
3031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3032pub struct CrossDimensionReachReportCompatibleFields {
3033    /// Dimensions which are compatible to be selected in the "breakdown" section of the report.
3034    pub breakdown: Option<Vec<Dimension>>,
3035    /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report.
3036    #[serde(rename = "dimensionFilters")]
3037    pub dimension_filters: Option<Vec<Dimension>>,
3038    /// The kind of resource this is, in this case dfareporting#crossDimensionReachReportCompatibleFields.
3039    pub kind: Option<String>,
3040    /// Metrics which are compatible to be selected in the "metricNames" section of the report.
3041    pub metrics: Option<Vec<Metric>>,
3042    /// Metrics which are compatible to be selected in the "overlapMetricNames" section of the report.
3043    #[serde(rename = "overlapMetrics")]
3044    pub overlap_metrics: Option<Vec<Metric>>,
3045}
3046
3047impl common::Part for CrossDimensionReachReportCompatibleFields {}
3048
3049/// A custom floodlight variable.
3050///
3051/// This type is not used in any activity, and only used as *part* of another schema.
3052///
3053#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3054#[serde_with::serde_as]
3055#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3056pub struct CustomFloodlightVariable {
3057    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#customFloodlightVariable".
3058    pub kind: Option<String>,
3059    /// The type of custom floodlight variable to supply a value for. These map to the "u[1-20]=" in the tags.
3060    #[serde(rename = "type")]
3061    pub type_: Option<String>,
3062    /// The value of the custom floodlight variable. The length of string must not exceed 50 characters.
3063    pub value: Option<String>,
3064}
3065
3066impl common::Part for CustomFloodlightVariable {}
3067
3068/// Represents a Custom Rich Media Events group.
3069///
3070/// This type is not used in any activity, and only used as *part* of another schema.
3071///
3072#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3073#[serde_with::serde_as]
3074#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3075pub struct CustomRichMediaEvents {
3076    /// List of custom rich media event IDs. Dimension values must be all of type dfa:richMediaEventTypeIdAndName.
3077    #[serde(rename = "filteredEventIds")]
3078    pub filtered_event_ids: Option<Vec<DimensionValue>>,
3079    /// The kind of resource this is, in this case dfareporting#customRichMediaEvents.
3080    pub kind: Option<String>,
3081}
3082
3083impl common::Part for CustomRichMediaEvents {}
3084
3085/// Represents a date range.
3086///
3087/// This type is not used in any activity, and only used as *part* of another schema.
3088///
3089#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3090#[serde_with::serde_as]
3091#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3092pub struct DateRange {
3093    /// The end date of the date range, inclusive. A string of the format: "yyyy-MM-dd".
3094    #[serde(rename = "endDate")]
3095    pub end_date: Option<chrono::NaiveDate>,
3096    /// The kind of resource this is, in this case dfareporting#dateRange.
3097    pub kind: Option<String>,
3098    /// The date range relative to the date of when the report is run.
3099    #[serde(rename = "relativeDateRange")]
3100    pub relative_date_range: Option<String>,
3101    /// The start date of the date range, inclusive. A string of the format: "yyyy-MM-dd".
3102    #[serde(rename = "startDate")]
3103    pub start_date: Option<chrono::NaiveDate>,
3104}
3105
3106impl common::Part for DateRange {}
3107
3108/// Day Part Targeting.
3109///
3110/// This type is not used in any activity, and only used as *part* of another schema.
3111///
3112#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3113#[serde_with::serde_as]
3114#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3115pub struct DayPartTargeting {
3116    /// Days of the week when the ad will serve.
3117    ///
3118    /// Acceptable values are:
3119    /// - "SUNDAY"
3120    /// - "MONDAY"
3121    /// - "TUESDAY"
3122    /// - "WEDNESDAY"
3123    /// - "THURSDAY"
3124    /// - "FRIDAY"
3125    /// - "SATURDAY"
3126    #[serde(rename = "daysOfWeek")]
3127    pub days_of_week: Option<Vec<String>>,
3128    /// Hours of the day when the ad will serve, where 0 is midnight to 1 AM and 23 is 11 PM to midnight. Can be specified with days of week, in which case the ad would serve during these hours on the specified days. For example if Monday, Wednesday, Friday are the days of week specified and 9-10am, 3-5pm (hours 9, 15, and 16) is specified, the ad would serve Monday, Wednesdays, and Fridays at 9-10am and 3-5pm. Acceptable values are 0 to 23, inclusive.
3129    #[serde(rename = "hoursOfDay")]
3130    pub hours_of_day: Option<Vec<i32>>,
3131    /// Whether or not to use the user's local time. If false, the America/New York time zone applies.
3132    #[serde(rename = "userLocalTime")]
3133    pub user_local_time: Option<bool>,
3134}
3135
3136impl common::Part for DayPartTargeting {}
3137
3138/// Contains information about a landing page deep link.
3139///
3140/// This type is not used in any activity, and only used as *part* of another schema.
3141///
3142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3143#[serde_with::serde_as]
3144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3145pub struct DeepLink {
3146    /// The URL of the mobile app being linked to.
3147    #[serde(rename = "appUrl")]
3148    pub app_url: Option<String>,
3149    /// The fallback URL. This URL will be served to users who do not have the mobile app installed.
3150    #[serde(rename = "fallbackUrl")]
3151    pub fallback_url: Option<String>,
3152    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#deepLink".
3153    pub kind: Option<String>,
3154    /// The mobile app targeted by this deep link.
3155    #[serde(rename = "mobileApp")]
3156    pub mobile_app: Option<MobileApp>,
3157    /// Ads served to users on these remarketing lists will use this deep link. Applicable when mobileApp.directory is APPLE_APP_STORE.
3158    #[serde(rename = "remarketingListIds")]
3159    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
3160    pub remarketing_list_ids: Option<Vec<i64>>,
3161}
3162
3163impl common::Part for DeepLink {}
3164
3165/// Properties of inheriting and overriding the default click-through event tag. A campaign may override the event tag defined at the advertiser level, and an ad may also override the campaign's setting further.
3166///
3167/// This type is not used in any activity, and only used as *part* of another schema.
3168///
3169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3170#[serde_with::serde_as]
3171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3172pub struct DefaultClickThroughEventTagProperties {
3173    /// ID of the click-through event tag to apply to all ads in this entity's scope.
3174    #[serde(rename = "defaultClickThroughEventTagId")]
3175    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3176    pub default_click_through_event_tag_id: Option<i64>,
3177    /// Whether this entity should override the inherited default click-through event tag with its own defined value.
3178    #[serde(rename = "overrideInheritedEventTag")]
3179    pub override_inherited_event_tag: Option<bool>,
3180}
3181
3182impl common::Part for DefaultClickThroughEventTagProperties {}
3183
3184/// Delivery Schedule.
3185///
3186/// This type is not used in any activity, and only used as *part* of another schema.
3187///
3188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3189#[serde_with::serde_as]
3190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3191pub struct DeliverySchedule {
3192    /// Limit on the number of times an individual user can be served the ad within a specified period of time.
3193    #[serde(rename = "frequencyCap")]
3194    pub frequency_cap: Option<FrequencyCap>,
3195    /// Whether or not hard cutoff is enabled. If true, the ad will not serve after the end date and time. Otherwise the ad will continue to be served until it has reached its delivery goals.
3196    #[serde(rename = "hardCutoff")]
3197    pub hard_cutoff: Option<bool>,
3198    /// Impression ratio for this ad. This ratio determines how often each ad is served relative to the others. For example, if ad A has an impression ratio of 1 and ad B has an impression ratio of 3, then Campaign Manager will serve ad B three times as often as ad A. Acceptable values are 1 to 10, inclusive.
3199    #[serde(rename = "impressionRatio")]
3200    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3201    pub impression_ratio: Option<i64>,
3202    /// Serving priority of an ad, with respect to other ads. The lower the priority number, the greater the priority with which it is served.
3203    pub priority: Option<String>,
3204}
3205
3206impl common::Part for DeliverySchedule {}
3207
3208/// Google Ad Manager Settings
3209///
3210/// This type is not used in any activity, and only used as *part* of another schema.
3211///
3212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3213#[serde_with::serde_as]
3214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3215pub struct DfpSettings {
3216    /// Ad Manager network code for this directory site.
3217    #[serde(rename = "dfpNetworkCode")]
3218    pub dfp_network_code: Option<String>,
3219    /// Ad Manager network name for this directory site.
3220    #[serde(rename = "dfpNetworkName")]
3221    pub dfp_network_name: Option<String>,
3222    /// Whether this directory site accepts programmatic placements.
3223    #[serde(rename = "programmaticPlacementAccepted")]
3224    pub programmatic_placement_accepted: Option<bool>,
3225    /// Whether this directory site accepts publisher-paid tags.
3226    #[serde(rename = "pubPaidPlacementAccepted")]
3227    pub pub_paid_placement_accepted: Option<bool>,
3228    /// Whether this directory site is available only via Publisher Portal.
3229    #[serde(rename = "publisherPortalOnly")]
3230    pub publisher_portal_only: Option<bool>,
3231}
3232
3233impl common::Part for DfpSettings {}
3234
3235/// Represents a dimension.
3236///
3237/// This type is not used in any activity, and only used as *part* of another schema.
3238///
3239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3240#[serde_with::serde_as]
3241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3242pub struct Dimension {
3243    /// The kind of resource this is, in this case dfareporting#dimension.
3244    pub kind: Option<String>,
3245    /// The dimension name, e.g. dfa:advertiser
3246    pub name: Option<String>,
3247}
3248
3249impl common::Part for Dimension {}
3250
3251/// Represents a dimension filter.
3252///
3253/// This type is not used in any activity, and only used as *part* of another schema.
3254///
3255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3256#[serde_with::serde_as]
3257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3258pub struct DimensionFilter {
3259    /// The name of the dimension to filter.
3260    #[serde(rename = "dimensionName")]
3261    pub dimension_name: Option<String>,
3262    /// The kind of resource this is, in this case dfareporting#dimensionFilter.
3263    pub kind: Option<String>,
3264    /// The value of the dimension to filter.
3265    pub value: Option<String>,
3266}
3267
3268impl common::Part for DimensionFilter {}
3269
3270/// Represents a DimensionValue resource.
3271///
3272/// # Activities
3273///
3274/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3275/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3276///
3277/// * [query dimension values](DimensionValueQueryCall) (none)
3278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3279#[serde_with::serde_as]
3280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3281pub struct DimensionValue {
3282    /// The name of the dimension.
3283    #[serde(rename = "dimensionName")]
3284    pub dimension_name: Option<String>,
3285    /// The eTag of this response for caching purposes.
3286    pub etag: Option<String>,
3287    /// The ID associated with the value if available.
3288    pub id: Option<String>,
3289    /// The kind of resource this is, in this case dfareporting#dimensionValue.
3290    pub kind: Option<String>,
3291    /// Determines how the 'value' field is matched when filtering. If not specified, defaults to EXACT. If set to WILDCARD_EXPRESSION, '*' is allowed as a placeholder for variable length character sequences, and it can be escaped with a backslash. Note, only paid search dimensions ('dfa:paidSearch*') allow a matchType other than EXACT.
3292    #[serde(rename = "matchType")]
3293    pub match_type: Option<String>,
3294    /// The value of the dimension.
3295    pub value: Option<String>,
3296}
3297
3298impl common::Resource for DimensionValue {}
3299
3300/// Represents the list of DimensionValue resources.
3301///
3302/// # Activities
3303///
3304/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3305/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3306///
3307/// * [query dimension values](DimensionValueQueryCall) (response)
3308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3309#[serde_with::serde_as]
3310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3311pub struct DimensionValueList {
3312    /// The eTag of this response for caching purposes.
3313    pub etag: Option<String>,
3314    /// The dimension values returned in this response.
3315    pub items: Option<Vec<DimensionValue>>,
3316    /// The kind of list this is, in this case dfareporting#dimensionValueList.
3317    pub kind: Option<String>,
3318    /// Continuation token used to page through dimension values. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted.
3319    #[serde(rename = "nextPageToken")]
3320    pub next_page_token: Option<String>,
3321}
3322
3323impl common::ResponseResult for DimensionValueList {}
3324
3325/// Represents a DimensionValuesRequest.
3326///
3327/// # Activities
3328///
3329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3331///
3332/// * [query dimension values](DimensionValueQueryCall) (request)
3333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3334#[serde_with::serde_as]
3335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3336pub struct DimensionValueRequest {
3337    /// The name of the dimension for which values should be requested.
3338    #[serde(rename = "dimensionName")]
3339    pub dimension_name: Option<String>,
3340    /// The end date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd".
3341    #[serde(rename = "endDate")]
3342    pub end_date: Option<chrono::NaiveDate>,
3343    /// The list of filters by which to filter values. The filters are ANDed.
3344    pub filters: Option<Vec<DimensionFilter>>,
3345    /// The kind of request this is, in this case dfareporting#dimensionValueRequest.
3346    pub kind: Option<String>,
3347    /// The start date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd".
3348    #[serde(rename = "startDate")]
3349    pub start_date: Option<chrono::NaiveDate>,
3350}
3351
3352impl common::RequestValue for DimensionValueRequest {}
3353
3354/// DirectorySites contains properties of a website from the Site Directory. Sites need to be added to an account via the Sites resource before they can be assigned to a placement.
3355///
3356/// # Activities
3357///
3358/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3359/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3360///
3361/// * [get directory sites](DirectorySiteGetCall) (response)
3362/// * [insert directory sites](DirectorySiteInsertCall) (request|response)
3363/// * [list directory sites](DirectorySiteListCall) (none)
3364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3365#[serde_with::serde_as]
3366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3367pub struct DirectorySite {
3368    /// Whether this directory site is active.
3369    pub active: Option<bool>,
3370    /// Directory site contacts.
3371    #[serde(rename = "contactAssignments")]
3372    pub contact_assignments: Option<Vec<DirectorySiteContactAssignment>>,
3373    /// Country ID of this directory site. This is a read-only field.
3374    #[serde(rename = "countryId")]
3375    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3376    pub country_id: Option<i64>,
3377    /// Currency ID of this directory site. This is a read-only field.
3378    /// Possible values are:
3379    /// - "1" for USD
3380    /// - "2" for GBP
3381    /// - "3" for ESP
3382    /// - "4" for SEK
3383    /// - "5" for CAD
3384    /// - "6" for JPY
3385    /// - "7" for DEM
3386    /// - "8" for AUD
3387    /// - "9" for FRF
3388    /// - "10" for ITL
3389    /// - "11" for DKK
3390    /// - "12" for NOK
3391    /// - "13" for FIM
3392    /// - "14" for ZAR
3393    /// - "15" for IEP
3394    /// - "16" for NLG
3395    /// - "17" for EUR
3396    /// - "18" for KRW
3397    /// - "19" for TWD
3398    /// - "20" for SGD
3399    /// - "21" for CNY
3400    /// - "22" for HKD
3401    /// - "23" for NZD
3402    /// - "24" for MYR
3403    /// - "25" for BRL
3404    /// - "26" for PTE
3405    /// - "27" for MXP
3406    /// - "28" for CLP
3407    /// - "29" for TRY
3408    /// - "30" for ARS
3409    /// - "31" for PEN
3410    /// - "32" for ILS
3411    /// - "33" for CHF
3412    /// - "34" for VEF
3413    /// - "35" for COP
3414    /// - "36" for GTQ
3415    /// - "37" for PLN
3416    /// - "39" for INR
3417    /// - "40" for THB
3418    /// - "41" for IDR
3419    /// - "42" for CZK
3420    /// - "43" for RON
3421    /// - "44" for HUF
3422    /// - "45" for RUB
3423    /// - "46" for AED
3424    /// - "47" for BGN
3425    /// - "48" for HRK
3426    /// - "49" for MXN
3427    /// - "50" for NGN
3428    #[serde(rename = "currencyId")]
3429    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3430    pub currency_id: Option<i64>,
3431    /// Description of this directory site. This is a read-only field.
3432    pub description: Option<String>,
3433    /// ID of this directory site. This is a read-only, auto-generated field.
3434    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3435    pub id: Option<i64>,
3436    /// Dimension value for the ID of this directory site. This is a read-only, auto-generated field.
3437    #[serde(rename = "idDimensionValue")]
3438    pub id_dimension_value: Option<DimensionValue>,
3439    /// Tag types for regular placements.
3440    ///
3441    /// Acceptable values are:
3442    /// - "STANDARD"
3443    /// - "IFRAME_JAVASCRIPT_INPAGE"
3444    /// - "INTERNAL_REDIRECT_INPAGE"
3445    /// - "JAVASCRIPT_INPAGE"
3446    #[serde(rename = "inpageTagFormats")]
3447    pub inpage_tag_formats: Option<Vec<String>>,
3448    /// Tag types for interstitial placements.
3449    ///
3450    /// Acceptable values are:
3451    /// - "IFRAME_JAVASCRIPT_INTERSTITIAL"
3452    /// - "INTERNAL_REDIRECT_INTERSTITIAL"
3453    /// - "JAVASCRIPT_INTERSTITIAL"
3454    #[serde(rename = "interstitialTagFormats")]
3455    pub interstitial_tag_formats: Option<Vec<String>>,
3456    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySite".
3457    pub kind: Option<String>,
3458    /// Name of this directory site.
3459    pub name: Option<String>,
3460    /// Parent directory site ID.
3461    #[serde(rename = "parentId")]
3462    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3463    pub parent_id: Option<i64>,
3464    /// Directory site settings.
3465    pub settings: Option<DirectorySiteSettings>,
3466    /// URL of this directory site.
3467    pub url: Option<String>,
3468}
3469
3470impl common::RequestValue for DirectorySite {}
3471impl common::Resource for DirectorySite {}
3472impl common::ResponseResult for DirectorySite {}
3473
3474/// Contains properties of a Site Directory contact.
3475///
3476/// # Activities
3477///
3478/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3479/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3480///
3481/// * [get directory site contacts](DirectorySiteContactGetCall) (response)
3482/// * [list directory site contacts](DirectorySiteContactListCall) (none)
3483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3484#[serde_with::serde_as]
3485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3486pub struct DirectorySiteContact {
3487    /// Address of this directory site contact.
3488    pub address: Option<String>,
3489    /// Email address of this directory site contact.
3490    pub email: Option<String>,
3491    /// First name of this directory site contact.
3492    #[serde(rename = "firstName")]
3493    pub first_name: Option<String>,
3494    /// ID of this directory site contact. This is a read-only, auto-generated field.
3495    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3496    pub id: Option<i64>,
3497    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContact".
3498    pub kind: Option<String>,
3499    /// Last name of this directory site contact.
3500    #[serde(rename = "lastName")]
3501    pub last_name: Option<String>,
3502    /// Phone number of this directory site contact.
3503    pub phone: Option<String>,
3504    /// Directory site contact role.
3505    pub role: Option<String>,
3506    /// Title or designation of this directory site contact.
3507    pub title: Option<String>,
3508    /// Directory site contact type.
3509    #[serde(rename = "type")]
3510    pub type_: Option<String>,
3511}
3512
3513impl common::Resource for DirectorySiteContact {}
3514impl common::ResponseResult for DirectorySiteContact {}
3515
3516/// Directory Site Contact Assignment
3517///
3518/// This type is not used in any activity, and only used as *part* of another schema.
3519///
3520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3521#[serde_with::serde_as]
3522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3523pub struct DirectorySiteContactAssignment {
3524    /// ID of this directory site contact. This is a read-only, auto-generated field.
3525    #[serde(rename = "contactId")]
3526    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3527    pub contact_id: Option<i64>,
3528    /// Visibility of this directory site contact assignment. When set to PUBLIC this contact assignment is visible to all account and agency users; when set to PRIVATE it is visible only to the site.
3529    pub visibility: Option<String>,
3530}
3531
3532impl common::Part for DirectorySiteContactAssignment {}
3533
3534/// Directory Site Contact List Response
3535///
3536/// # Activities
3537///
3538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3540///
3541/// * [list directory site contacts](DirectorySiteContactListCall) (response)
3542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3543#[serde_with::serde_as]
3544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3545pub struct DirectorySiteContactsListResponse {
3546    /// Directory site contact collection
3547    #[serde(rename = "directorySiteContacts")]
3548    pub directory_site_contacts: Option<Vec<DirectorySiteContact>>,
3549    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContactsListResponse".
3550    pub kind: Option<String>,
3551    /// Pagination token to be used for the next list operation.
3552    #[serde(rename = "nextPageToken")]
3553    pub next_page_token: Option<String>,
3554}
3555
3556impl common::ResponseResult for DirectorySiteContactsListResponse {}
3557
3558/// Directory Site Settings
3559///
3560/// This type is not used in any activity, and only used as *part* of another schema.
3561///
3562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3563#[serde_with::serde_as]
3564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3565pub struct DirectorySiteSettings {
3566    /// Whether this directory site has disabled active view creatives.
3567    #[serde(rename = "activeViewOptOut")]
3568    pub active_view_opt_out: Option<bool>,
3569    /// Directory site Ad Manager settings.
3570    #[serde(rename = "dfpSettings")]
3571    pub dfp_settings: Option<DfpSettings>,
3572    /// Whether this site accepts in-stream video ads.
3573    #[serde(rename = "instreamVideoPlacementAccepted")]
3574    pub instream_video_placement_accepted: Option<bool>,
3575    /// Whether this site accepts interstitial ads.
3576    #[serde(rename = "interstitialPlacementAccepted")]
3577    pub interstitial_placement_accepted: Option<bool>,
3578    /// Whether this directory site has disabled Nielsen OCR reach ratings.
3579    #[serde(rename = "nielsenOcrOptOut")]
3580    pub nielsen_ocr_opt_out: Option<bool>,
3581    /// Whether this directory site has disabled generation of Verification ins tags.
3582    #[serde(rename = "verificationTagOptOut")]
3583    pub verification_tag_opt_out: Option<bool>,
3584    /// Whether this directory site has disabled active view for in-stream video creatives. This is a read-only field.
3585    #[serde(rename = "videoActiveViewOptOut")]
3586    pub video_active_view_opt_out: Option<bool>,
3587}
3588
3589impl common::Part for DirectorySiteSettings {}
3590
3591/// Directory Site List Response
3592///
3593/// # Activities
3594///
3595/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3596/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3597///
3598/// * [list directory sites](DirectorySiteListCall) (response)
3599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3600#[serde_with::serde_as]
3601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3602pub struct DirectorySitesListResponse {
3603    /// Directory site collection.
3604    #[serde(rename = "directorySites")]
3605    pub directory_sites: Option<Vec<DirectorySite>>,
3606    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySitesListResponse".
3607    pub kind: Option<String>,
3608    /// Pagination token to be used for the next list operation.
3609    #[serde(rename = "nextPageToken")]
3610    pub next_page_token: Option<String>,
3611}
3612
3613impl common::ResponseResult for DirectorySitesListResponse {}
3614
3615/// Contains properties of a dynamic targeting key. Dynamic targeting keys are unique, user-friendly labels, created at the advertiser level in DCM, that can be assigned to ads, creatives, and placements and used for targeting with Studio dynamic creatives. Use these labels instead of numeric Campaign Manager IDs (such as placement IDs) to save time and avoid errors in your dynamic feeds.
3616///
3617/// # Activities
3618///
3619/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3620/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3621///
3622/// * [delete dynamic targeting keys](DynamicTargetingKeyDeleteCall) (none)
3623/// * [insert dynamic targeting keys](DynamicTargetingKeyInsertCall) (request|response)
3624/// * [list dynamic targeting keys](DynamicTargetingKeyListCall) (none)
3625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3626#[serde_with::serde_as]
3627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3628pub struct DynamicTargetingKey {
3629    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKey".
3630    pub kind: Option<String>,
3631    /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase.
3632    pub name: Option<String>,
3633    /// ID of the object of this dynamic targeting key. This is a required field.
3634    #[serde(rename = "objectId")]
3635    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3636    pub object_id: Option<i64>,
3637    /// Type of the object of this dynamic targeting key. This is a required field.
3638    #[serde(rename = "objectType")]
3639    pub object_type: Option<String>,
3640}
3641
3642impl common::RequestValue for DynamicTargetingKey {}
3643impl common::Resource for DynamicTargetingKey {}
3644impl common::ResponseResult for DynamicTargetingKey {}
3645
3646/// Dynamic Targeting Key List Response
3647///
3648/// # Activities
3649///
3650/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3651/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3652///
3653/// * [list dynamic targeting keys](DynamicTargetingKeyListCall) (response)
3654#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3655#[serde_with::serde_as]
3656#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3657pub struct DynamicTargetingKeysListResponse {
3658    /// Dynamic targeting key collection.
3659    #[serde(rename = "dynamicTargetingKeys")]
3660    pub dynamic_targeting_keys: Option<Vec<DynamicTargetingKey>>,
3661    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKeysListResponse".
3662    pub kind: Option<String>,
3663}
3664
3665impl common::ResponseResult for DynamicTargetingKeysListResponse {}
3666
3667/// A description of how user IDs are encrypted.
3668///
3669/// This type is not used in any activity, and only used as *part* of another schema.
3670///
3671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3672#[serde_with::serde_as]
3673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3674pub struct EncryptionInfo {
3675    /// The encryption entity ID. This should match the encryption configuration for ad serving or Data Transfer.
3676    #[serde(rename = "encryptionEntityId")]
3677    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3678    pub encryption_entity_id: Option<i64>,
3679    /// The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer.
3680    #[serde(rename = "encryptionEntityType")]
3681    pub encryption_entity_type: Option<String>,
3682    /// Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer.
3683    #[serde(rename = "encryptionSource")]
3684    pub encryption_source: Option<String>,
3685    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#encryptionInfo".
3686    pub kind: Option<String>,
3687}
3688
3689impl common::Part for EncryptionInfo {}
3690
3691/// Contains properties of an event tag.
3692///
3693/// # Activities
3694///
3695/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3696/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3697///
3698/// * [delete event tags](EventTagDeleteCall) (none)
3699/// * [get event tags](EventTagGetCall) (response)
3700/// * [insert event tags](EventTagInsertCall) (request|response)
3701/// * [list event tags](EventTagListCall) (none)
3702/// * [patch event tags](EventTagPatchCall) (request|response)
3703/// * [update event tags](EventTagUpdateCall) (request|response)
3704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3705#[serde_with::serde_as]
3706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3707pub struct EventTag {
3708    /// Account ID of this event tag. This is a read-only field that can be left blank.
3709    #[serde(rename = "accountId")]
3710    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3711    pub account_id: Option<i64>,
3712    /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion.
3713    #[serde(rename = "advertiserId")]
3714    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3715    pub advertiser_id: Option<i64>,
3716    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
3717    #[serde(rename = "advertiserIdDimensionValue")]
3718    pub advertiser_id_dimension_value: Option<DimensionValue>,
3719    /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion.
3720    #[serde(rename = "campaignId")]
3721    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3722    pub campaign_id: Option<i64>,
3723    /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field.
3724    #[serde(rename = "campaignIdDimensionValue")]
3725    pub campaign_id_dimension_value: Option<DimensionValue>,
3726    /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads.
3727    #[serde(rename = "enabledByDefault")]
3728    pub enabled_by_default: Option<bool>,
3729    /// Whether to remove this event tag from ads that are trafficked through Display & Video 360 to Ad Exchange. This may be useful if the event tag uses a pixel that is unapproved for Ad Exchange bids on one or more networks, such as the Google Display Network.
3730    #[serde(rename = "excludeFromAdxRequests")]
3731    pub exclude_from_adx_requests: Option<bool>,
3732    /// ID of this event tag. This is a read-only, auto-generated field.
3733    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3734    pub id: Option<i64>,
3735    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag".
3736    pub kind: Option<String>,
3737    /// Name of this event tag. This is a required field and must be less than 256 characters long.
3738    pub name: Option<String>,
3739    /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites.
3740    #[serde(rename = "siteFilterType")]
3741    pub site_filter_type: Option<String>,
3742    /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter.
3743    #[serde(rename = "siteIds")]
3744    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
3745    pub site_ids: Option<Vec<i64>>,
3746    /// Whether this tag is SSL-compliant or not. This is a read-only field.
3747    #[serde(rename = "sslCompliant")]
3748    pub ssl_compliant: Option<bool>,
3749    /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field.
3750    pub status: Option<String>,
3751    /// Subaccount ID of this event tag. This is a read-only field that can be left blank.
3752    #[serde(rename = "subaccountId")]
3753    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3754    pub subaccount_id: Option<i64>,
3755    /// Event tag type. Can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking. This is a required field.
3756    #[serde(rename = "type")]
3757    pub type_: Option<String>,
3758    /// Payload URL for this event tag. The URL on a click-through event tag should have a landing page URL appended to the end of it. This field is required on insertion.
3759    pub url: Option<String>,
3760    /// Number of times the landing page URL should be URL-escaped before being appended to the click-through event tag URL. Only applies to click-through event tags as specified by the event tag type.
3761    #[serde(rename = "urlEscapeLevels")]
3762    pub url_escape_levels: Option<i32>,
3763}
3764
3765impl common::RequestValue for EventTag {}
3766impl common::Resource for EventTag {}
3767impl common::ResponseResult for EventTag {}
3768
3769/// Event tag override information.
3770///
3771/// This type is not used in any activity, and only used as *part* of another schema.
3772///
3773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3774#[serde_with::serde_as]
3775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3776pub struct EventTagOverride {
3777    /// Whether this override is enabled.
3778    pub enabled: Option<bool>,
3779    /// ID of this event tag override. This is a read-only, auto-generated field.
3780    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3781    pub id: Option<i64>,
3782}
3783
3784impl common::Part for EventTagOverride {}
3785
3786/// Event Tag List Response
3787///
3788/// # Activities
3789///
3790/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3791/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3792///
3793/// * [list event tags](EventTagListCall) (response)
3794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3795#[serde_with::serde_as]
3796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3797pub struct EventTagsListResponse {
3798    /// Event tag collection.
3799    #[serde(rename = "eventTags")]
3800    pub event_tags: Option<Vec<EventTag>>,
3801    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTagsListResponse".
3802    pub kind: Option<String>,
3803}
3804
3805impl common::ResponseResult for EventTagsListResponse {}
3806
3807/// Represents a File resource. A file contains the metadata for a report run. It shows the status of the run and holds the URLs to the generated report data if the run is finished and the status is “REPORT_AVAILABLE”.
3808///
3809/// # Activities
3810///
3811/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3812/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3813///
3814/// * [get files](FileGetCall) (response)
3815/// * [list files](FileListCall) (none)
3816/// * [files get reports](ReportFileGetCall) (response)
3817/// * [run reports](ReportRunCall) (response)
3818#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3819#[serde_with::serde_as]
3820#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3821pub struct File {
3822    /// The date range for which the file has report data. The date range will always be the absolute date range for which the report is run.
3823    #[serde(rename = "dateRange")]
3824    pub date_range: Option<DateRange>,
3825    /// The eTag of this response for caching purposes.
3826    pub etag: Option<String>,
3827    /// The filename of the file.
3828    #[serde(rename = "fileName")]
3829    pub file_name: Option<String>,
3830    /// The output format of the report. Only available once the file is available.
3831    pub format: Option<String>,
3832    /// The unique ID of this report file.
3833    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3834    pub id: Option<i64>,
3835    /// The kind of resource this is, in this case dfareporting#file.
3836    pub kind: Option<String>,
3837    /// The timestamp in milliseconds since epoch when this file was last modified.
3838    #[serde(rename = "lastModifiedTime")]
3839    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3840    pub last_modified_time: Option<i64>,
3841    /// The ID of the report this file was generated from.
3842    #[serde(rename = "reportId")]
3843    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3844    pub report_id: Option<i64>,
3845    /// The status of the report file.
3846    pub status: Option<String>,
3847    /// The URLs where the completed report file can be downloaded.
3848    pub urls: Option<FileUrls>,
3849}
3850
3851impl common::Resource for File {}
3852impl common::ResponseResult for File {}
3853
3854/// Represents the list of File resources.
3855///
3856/// # Activities
3857///
3858/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3859/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3860///
3861/// * [list files](FileListCall) (response)
3862/// * [files list reports](ReportFileListCall) (response)
3863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3864#[serde_with::serde_as]
3865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3866pub struct FileList {
3867    /// The eTag of this response for caching purposes.
3868    pub etag: Option<String>,
3869    /// The files returned in this response.
3870    pub items: Option<Vec<File>>,
3871    /// The kind of list this is, in this case dfareporting#fileList.
3872    pub kind: Option<String>,
3873    /// Continuation token used to page through files. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted.
3874    #[serde(rename = "nextPageToken")]
3875    pub next_page_token: Option<String>,
3876}
3877
3878impl common::ResponseResult for FileList {}
3879
3880/// Flight
3881///
3882/// This type is not used in any activity, and only used as *part* of another schema.
3883///
3884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3885#[serde_with::serde_as]
3886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3887pub struct Flight {
3888    /// Inventory item flight end date.
3889    #[serde(rename = "endDate")]
3890    pub end_date: Option<chrono::NaiveDate>,
3891    /// Rate or cost of this flight.
3892    #[serde(rename = "rateOrCost")]
3893    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3894    pub rate_or_cost: Option<i64>,
3895    /// Inventory item flight start date.
3896    #[serde(rename = "startDate")]
3897    pub start_date: Option<chrono::NaiveDate>,
3898    /// Units of this flight.
3899    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3900    pub units: Option<i64>,
3901}
3902
3903impl common::Part for Flight {}
3904
3905/// Floodlight Activity GenerateTag Response
3906///
3907/// # Activities
3908///
3909/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3910/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3911///
3912/// * [generatetag floodlight activities](FloodlightActivityGeneratetagCall) (response)
3913#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3914#[serde_with::serde_as]
3915#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3916pub struct FloodlightActivitiesGenerateTagResponse {
3917    /// Generated tag for this Floodlight activity. For global site tags, this is the event snippet.
3918    #[serde(rename = "floodlightActivityTag")]
3919    pub floodlight_activity_tag: Option<String>,
3920    /// The global snippet section of a global site tag. The global site tag sets new cookies on your domain, which will store a unique identifier for a user or the ad click that brought the user to your site. Learn more.
3921    #[serde(rename = "globalSiteTagGlobalSnippet")]
3922    pub global_site_tag_global_snippet: Option<String>,
3923    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesGenerateTagResponse".
3924    pub kind: Option<String>,
3925}
3926
3927impl common::ResponseResult for FloodlightActivitiesGenerateTagResponse {}
3928
3929/// Floodlight Activity List Response
3930///
3931/// # Activities
3932///
3933/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3934/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3935///
3936/// * [list floodlight activities](FloodlightActivityListCall) (response)
3937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3938#[serde_with::serde_as]
3939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3940pub struct FloodlightActivitiesListResponse {
3941    /// Floodlight activity collection.
3942    #[serde(rename = "floodlightActivities")]
3943    pub floodlight_activities: Option<Vec<FloodlightActivity>>,
3944    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesListResponse".
3945    pub kind: Option<String>,
3946    /// Pagination token to be used for the next list operation.
3947    #[serde(rename = "nextPageToken")]
3948    pub next_page_token: Option<String>,
3949}
3950
3951impl common::ResponseResult for FloodlightActivitiesListResponse {}
3952
3953/// Contains properties of a Floodlight activity.
3954///
3955/// # Activities
3956///
3957/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3958/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3959///
3960/// * [get floodlight activities](FloodlightActivityGetCall) (response)
3961/// * [insert floodlight activities](FloodlightActivityInsertCall) (request|response)
3962/// * [patch floodlight activities](FloodlightActivityPatchCall) (request|response)
3963/// * [update floodlight activities](FloodlightActivityUpdateCall) (request|response)
3964#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3965#[serde_with::serde_as]
3966#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3967pub struct FloodlightActivity {
3968    /// Account ID of this floodlight activity. This is a read-only field that can be left blank.
3969    #[serde(rename = "accountId")]
3970    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3971    pub account_id: Option<i64>,
3972    /// Advertiser ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's advertiser or the existing activity's advertiser.
3973    #[serde(rename = "advertiserId")]
3974    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3975    pub advertiser_id: Option<i64>,
3976    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
3977    #[serde(rename = "advertiserIdDimensionValue")]
3978    pub advertiser_id_dimension_value: Option<DimensionValue>,
3979    /// Code type used for cache busting in the generated tag. Applicable only when floodlightActivityGroupType is COUNTER and countingMethod is STANDARD_COUNTING or UNIQUE_COUNTING.
3980    #[serde(rename = "cacheBustingType")]
3981    pub cache_busting_type: Option<String>,
3982    /// Counting method for conversions for this floodlight activity. This is a required field.
3983    #[serde(rename = "countingMethod")]
3984    pub counting_method: Option<String>,
3985    /// Dynamic floodlight tags.
3986    #[serde(rename = "defaultTags")]
3987    pub default_tags: Option<Vec<FloodlightActivityDynamicTag>>,
3988    /// URL where this tag will be deployed. If specified, must be less than 256 characters long.
3989    #[serde(rename = "expectedUrl")]
3990    pub expected_url: Option<String>,
3991    /// Floodlight activity group ID of this floodlight activity. This is a required field.
3992    #[serde(rename = "floodlightActivityGroupId")]
3993    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3994    pub floodlight_activity_group_id: Option<i64>,
3995    /// Name of the associated floodlight activity group. This is a read-only field.
3996    #[serde(rename = "floodlightActivityGroupName")]
3997    pub floodlight_activity_group_name: Option<String>,
3998    /// Tag string of the associated floodlight activity group. This is a read-only field.
3999    #[serde(rename = "floodlightActivityGroupTagString")]
4000    pub floodlight_activity_group_tag_string: Option<String>,
4001    /// Type of the associated floodlight activity group. This is a read-only field.
4002    #[serde(rename = "floodlightActivityGroupType")]
4003    pub floodlight_activity_group_type: Option<String>,
4004    /// Floodlight configuration ID of this floodlight activity. If this field is left blank, the value will be copied over either from the activity group's floodlight configuration or from the existing activity's floodlight configuration.
4005    #[serde(rename = "floodlightConfigurationId")]
4006    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4007    pub floodlight_configuration_id: Option<i64>,
4008    /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field.
4009    #[serde(rename = "floodlightConfigurationIdDimensionValue")]
4010    pub floodlight_configuration_id_dimension_value: Option<DimensionValue>,
4011    /// The type of Floodlight tag this activity will generate. This is a required field.
4012    #[serde(rename = "floodlightTagType")]
4013    pub floodlight_tag_type: Option<String>,
4014    /// Whether this activity is archived.
4015    pub hidden: Option<bool>,
4016    /// ID of this floodlight activity. This is a read-only, auto-generated field.
4017    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4018    pub id: Option<i64>,
4019    /// Dimension value for the ID of this floodlight activity. This is a read-only, auto-generated field.
4020    #[serde(rename = "idDimensionValue")]
4021    pub id_dimension_value: Option<DimensionValue>,
4022    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivity".
4023    pub kind: Option<String>,
4024    /// Name of this floodlight activity. This is a required field. Must be less than 129 characters long and cannot contain quotes.
4025    pub name: Option<String>,
4026    /// General notes or implementation instructions for the tag.
4027    pub notes: Option<String>,
4028    /// Publisher dynamic floodlight tags.
4029    #[serde(rename = "publisherTags")]
4030    pub publisher_tags: Option<Vec<FloodlightActivityPublisherDynamicTag>>,
4031    /// Whether this tag should use SSL.
4032    pub secure: Option<bool>,
4033    /// Whether the floodlight activity is SSL-compliant. This is a read-only field, its value detected by the system from the floodlight tags.
4034    #[serde(rename = "sslCompliant")]
4035    pub ssl_compliant: Option<bool>,
4036    /// Whether this floodlight activity must be SSL-compliant.
4037    #[serde(rename = "sslRequired")]
4038    pub ssl_required: Option<bool>,
4039    /// Subaccount ID of this floodlight activity. This is a read-only field that can be left blank.
4040    #[serde(rename = "subaccountId")]
4041    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4042    pub subaccount_id: Option<i64>,
4043    /// Tag format type for the floodlight activity. If left blank, the tag format will default to HTML.
4044    #[serde(rename = "tagFormat")]
4045    pub tag_format: Option<String>,
4046    /// Value of the cat= parameter in the floodlight tag, which the ad servers use to identify the activity. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activities of the same activity group. This field is read-only after insertion.
4047    #[serde(rename = "tagString")]
4048    pub tag_string: Option<String>,
4049    /// List of the user-defined variables used by this conversion tag. These map to the "u[1-100]=" in the tags. Each of these can have a user defined type.
4050    /// Acceptable values are U1 to U100, inclusive.
4051    #[serde(rename = "userDefinedVariableTypes")]
4052    pub user_defined_variable_types: Option<Vec<String>>,
4053}
4054
4055impl common::RequestValue for FloodlightActivity {}
4056impl common::ResponseResult for FloodlightActivity {}
4057
4058/// Dynamic Tag
4059///
4060/// This type is not used in any activity, and only used as *part* of another schema.
4061///
4062#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4063#[serde_with::serde_as]
4064#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4065pub struct FloodlightActivityDynamicTag {
4066    /// ID of this dynamic tag. This is a read-only, auto-generated field.
4067    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4068    pub id: Option<i64>,
4069    /// Name of this tag.
4070    pub name: Option<String>,
4071    /// Tag code.
4072    pub tag: Option<String>,
4073}
4074
4075impl common::Part for FloodlightActivityDynamicTag {}
4076
4077/// Contains properties of a Floodlight activity group.
4078///
4079/// # Activities
4080///
4081/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4082/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4083///
4084/// * [get floodlight activity groups](FloodlightActivityGroupGetCall) (response)
4085/// * [insert floodlight activity groups](FloodlightActivityGroupInsertCall) (request|response)
4086/// * [list floodlight activity groups](FloodlightActivityGroupListCall) (none)
4087/// * [patch floodlight activity groups](FloodlightActivityGroupPatchCall) (request|response)
4088/// * [update floodlight activity groups](FloodlightActivityGroupUpdateCall) (request|response)
4089#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4090#[serde_with::serde_as]
4091#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4092pub struct FloodlightActivityGroup {
4093    /// Account ID of this floodlight activity group. This is a read-only field that can be left blank.
4094    #[serde(rename = "accountId")]
4095    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4096    pub account_id: Option<i64>,
4097    /// Advertiser ID of this floodlight activity group. If this field is left blank, the value will be copied over either from the floodlight configuration's advertiser or from the existing activity group's advertiser.
4098    #[serde(rename = "advertiserId")]
4099    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4100    pub advertiser_id: Option<i64>,
4101    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
4102    #[serde(rename = "advertiserIdDimensionValue")]
4103    pub advertiser_id_dimension_value: Option<DimensionValue>,
4104    /// Floodlight configuration ID of this floodlight activity group. This is a required field.
4105    #[serde(rename = "floodlightConfigurationId")]
4106    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4107    pub floodlight_configuration_id: Option<i64>,
4108    /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field.
4109    #[serde(rename = "floodlightConfigurationIdDimensionValue")]
4110    pub floodlight_configuration_id_dimension_value: Option<DimensionValue>,
4111    /// ID of this floodlight activity group. This is a read-only, auto-generated field.
4112    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4113    pub id: Option<i64>,
4114    /// Dimension value for the ID of this floodlight activity group. This is a read-only, auto-generated field.
4115    #[serde(rename = "idDimensionValue")]
4116    pub id_dimension_value: Option<DimensionValue>,
4117    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroup".
4118    pub kind: Option<String>,
4119    /// Name of this floodlight activity group. This is a required field. Must be less than 65 characters long and cannot contain quotes.
4120    pub name: Option<String>,
4121    /// Subaccount ID of this floodlight activity group. This is a read-only field that can be left blank.
4122    #[serde(rename = "subaccountId")]
4123    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4124    pub subaccount_id: Option<i64>,
4125    /// Value of the type= parameter in the floodlight tag, which the ad servers use to identify the activity group that the activity belongs to. This is optional: if empty, a new tag string will be generated for you. This string must be 1 to 8 characters long, with valid characters being [a-z][A-Z][0-9][-][ _ ]. This tag string must also be unique among activity groups of the same floodlight configuration. This field is read-only after insertion.
4126    #[serde(rename = "tagString")]
4127    pub tag_string: Option<String>,
4128    /// Type of the floodlight activity group. This is a required field that is read-only after insertion.
4129    #[serde(rename = "type")]
4130    pub type_: Option<String>,
4131}
4132
4133impl common::RequestValue for FloodlightActivityGroup {}
4134impl common::Resource for FloodlightActivityGroup {}
4135impl common::ResponseResult for FloodlightActivityGroup {}
4136
4137/// Floodlight Activity Group List Response
4138///
4139/// # Activities
4140///
4141/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4142/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4143///
4144/// * [list floodlight activity groups](FloodlightActivityGroupListCall) (response)
4145#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4146#[serde_with::serde_as]
4147#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4148pub struct FloodlightActivityGroupsListResponse {
4149    /// Floodlight activity group collection.
4150    #[serde(rename = "floodlightActivityGroups")]
4151    pub floodlight_activity_groups: Option<Vec<FloodlightActivityGroup>>,
4152    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroupsListResponse".
4153    pub kind: Option<String>,
4154    /// Pagination token to be used for the next list operation.
4155    #[serde(rename = "nextPageToken")]
4156    pub next_page_token: Option<String>,
4157}
4158
4159impl common::ResponseResult for FloodlightActivityGroupsListResponse {}
4160
4161/// Publisher Dynamic Tag
4162///
4163/// This type is not used in any activity, and only used as *part* of another schema.
4164///
4165#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4166#[serde_with::serde_as]
4167#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4168pub struct FloodlightActivityPublisherDynamicTag {
4169    /// Whether this tag is applicable only for click-throughs.
4170    #[serde(rename = "clickThrough")]
4171    pub click_through: Option<bool>,
4172    /// Directory site ID of this dynamic tag. This is a write-only field that can be used as an alternative to the siteId field. When this resource is retrieved, only the siteId field will be populated.
4173    #[serde(rename = "directorySiteId")]
4174    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4175    pub directory_site_id: Option<i64>,
4176    /// Dynamic floodlight tag.
4177    #[serde(rename = "dynamicTag")]
4178    pub dynamic_tag: Option<FloodlightActivityDynamicTag>,
4179    /// Site ID of this dynamic tag.
4180    #[serde(rename = "siteId")]
4181    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4182    pub site_id: Option<i64>,
4183    /// Dimension value for the ID of the site. This is a read-only, auto-generated field.
4184    #[serde(rename = "siteIdDimensionValue")]
4185    pub site_id_dimension_value: Option<DimensionValue>,
4186    /// Whether this tag is applicable only for view-throughs.
4187    #[serde(rename = "viewThrough")]
4188    pub view_through: Option<bool>,
4189}
4190
4191impl common::Part for FloodlightActivityPublisherDynamicTag {}
4192
4193/// Contains properties of a Floodlight configuration.
4194///
4195/// # Activities
4196///
4197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4199///
4200/// * [get floodlight configurations](FloodlightConfigurationGetCall) (response)
4201/// * [list floodlight configurations](FloodlightConfigurationListCall) (none)
4202/// * [patch floodlight configurations](FloodlightConfigurationPatchCall) (request|response)
4203/// * [update floodlight configurations](FloodlightConfigurationUpdateCall) (request|response)
4204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4205#[serde_with::serde_as]
4206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4207pub struct FloodlightConfiguration {
4208    /// Account ID of this floodlight configuration. This is a read-only field that can be left blank.
4209    #[serde(rename = "accountId")]
4210    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4211    pub account_id: Option<i64>,
4212    /// Advertiser ID of the parent advertiser of this floodlight configuration.
4213    #[serde(rename = "advertiserId")]
4214    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4215    pub advertiser_id: Option<i64>,
4216    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
4217    #[serde(rename = "advertiserIdDimensionValue")]
4218    pub advertiser_id_dimension_value: Option<DimensionValue>,
4219    /// Whether advertiser data is shared with Google Analytics.
4220    #[serde(rename = "analyticsDataSharingEnabled")]
4221    pub analytics_data_sharing_enabled: Option<bool>,
4222    /// Whether the exposure-to-conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting.
4223    #[serde(rename = "exposureToConversionEnabled")]
4224    pub exposure_to_conversion_enabled: Option<bool>,
4225    /// Day that will be counted as the first day of the week in reports. This is a required field.
4226    #[serde(rename = "firstDayOfWeek")]
4227    pub first_day_of_week: Option<String>,
4228    /// ID of this floodlight configuration. This is a read-only, auto-generated field.
4229    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4230    pub id: Option<i64>,
4231    /// Dimension value for the ID of this floodlight configuration. This is a read-only, auto-generated field.
4232    #[serde(rename = "idDimensionValue")]
4233    pub id_dimension_value: Option<DimensionValue>,
4234    /// Whether in-app attribution tracking is enabled.
4235    #[serde(rename = "inAppAttributionTrackingEnabled")]
4236    pub in_app_attribution_tracking_enabled: Option<bool>,
4237    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfiguration".
4238    pub kind: Option<String>,
4239    /// Lookback window settings for this floodlight configuration.
4240    #[serde(rename = "lookbackConfiguration")]
4241    pub lookback_configuration: Option<LookbackConfiguration>,
4242    /// Types of attribution options for natural search conversions.
4243    #[serde(rename = "naturalSearchConversionAttributionOption")]
4244    pub natural_search_conversion_attribution_option: Option<String>,
4245    /// Settings for Campaign Manager Omniture integration.
4246    #[serde(rename = "omnitureSettings")]
4247    pub omniture_settings: Option<OmnitureSettings>,
4248    /// Subaccount ID of this floodlight configuration. This is a read-only field that can be left blank.
4249    #[serde(rename = "subaccountId")]
4250    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4251    pub subaccount_id: Option<i64>,
4252    /// Configuration settings for dynamic and image floodlight tags.
4253    #[serde(rename = "tagSettings")]
4254    pub tag_settings: Option<TagSettings>,
4255    /// List of third-party authentication tokens enabled for this configuration.
4256    #[serde(rename = "thirdPartyAuthenticationTokens")]
4257    pub third_party_authentication_tokens: Option<Vec<ThirdPartyAuthenticationToken>>,
4258    /// List of user defined variables enabled for this configuration.
4259    #[serde(rename = "userDefinedVariableConfigurations")]
4260    pub user_defined_variable_configurations: Option<Vec<UserDefinedVariableConfiguration>>,
4261}
4262
4263impl common::RequestValue for FloodlightConfiguration {}
4264impl common::Resource for FloodlightConfiguration {}
4265impl common::ResponseResult for FloodlightConfiguration {}
4266
4267/// Floodlight Configuration List Response
4268///
4269/// # Activities
4270///
4271/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4272/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4273///
4274/// * [list floodlight configurations](FloodlightConfigurationListCall) (response)
4275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4276#[serde_with::serde_as]
4277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4278pub struct FloodlightConfigurationsListResponse {
4279    /// Floodlight configuration collection.
4280    #[serde(rename = "floodlightConfigurations")]
4281    pub floodlight_configurations: Option<Vec<FloodlightConfiguration>>,
4282    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfigurationsListResponse".
4283    pub kind: Option<String>,
4284}
4285
4286impl common::ResponseResult for FloodlightConfigurationsListResponse {}
4287
4288/// Represents fields that are compatible to be selected for a report of type "FlOODLIGHT".
4289///
4290/// This type is not used in any activity, and only used as *part* of another schema.
4291///
4292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4293#[serde_with::serde_as]
4294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4295pub struct FloodlightReportCompatibleFields {
4296    /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report.
4297    #[serde(rename = "dimensionFilters")]
4298    pub dimension_filters: Option<Vec<Dimension>>,
4299    /// Dimensions which are compatible to be selected in the "dimensions" section of the report.
4300    pub dimensions: Option<Vec<Dimension>>,
4301    /// The kind of resource this is, in this case dfareporting#floodlightReportCompatibleFields.
4302    pub kind: Option<String>,
4303    /// Metrics which are compatible to be selected in the "metricNames" section of the report.
4304    pub metrics: Option<Vec<Metric>>,
4305}
4306
4307impl common::Part for FloodlightReportCompatibleFields {}
4308
4309/// Frequency Cap.
4310///
4311/// This type is not used in any activity, and only used as *part* of another schema.
4312///
4313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4314#[serde_with::serde_as]
4315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4316pub struct FrequencyCap {
4317    /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days. Acceptable values are 1 to 7776000, inclusive.
4318    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4319    pub duration: Option<i64>,
4320    /// Number of times an individual user can be served the ad within the specified duration. Acceptable values are 1 to 15, inclusive.
4321    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4322    pub impressions: Option<i64>,
4323}
4324
4325impl common::Part for FrequencyCap {}
4326
4327/// FsCommand.
4328///
4329/// This type is not used in any activity, and only used as *part* of another schema.
4330///
4331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4332#[serde_with::serde_as]
4333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4334pub struct FsCommand {
4335    /// Distance from the left of the browser.Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER.
4336    pub left: Option<i32>,
4337    /// Position in the browser where the window will open.
4338    #[serde(rename = "positionOption")]
4339    pub position_option: Option<String>,
4340    /// Distance from the top of the browser. Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER.
4341    pub top: Option<i32>,
4342    /// Height of the window.
4343    #[serde(rename = "windowHeight")]
4344    pub window_height: Option<i32>,
4345    /// Width of the window.
4346    #[serde(rename = "windowWidth")]
4347    pub window_width: Option<i32>,
4348}
4349
4350impl common::Part for FsCommand {}
4351
4352/// Geographical Targeting.
4353///
4354/// This type is not used in any activity, and only used as *part* of another schema.
4355///
4356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4357#[serde_with::serde_as]
4358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4359pub struct GeoTargeting {
4360    /// Cities to be targeted. For each city only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a city, do not target or exclude the country of the city, and do not target the metro or region of the city.
4361    pub cities: Option<Vec<City>>,
4362    /// Countries to be targeted or excluded from targeting, depending on the setting of the excludeCountries field. For each country only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting or excluding a country, do not target regions, cities, metros, or postal codes in the same country.
4363    pub countries: Option<Vec<Country>>,
4364    /// Whether or not to exclude the countries in the countries field from targeting. If false, the countries field refers to countries which will be targeted by the ad.
4365    #[serde(rename = "excludeCountries")]
4366    pub exclude_countries: Option<bool>,
4367    /// Metros to be targeted. For each metro only dmaId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a metro, do not target or exclude the country of the metro.
4368    pub metros: Option<Vec<Metro>>,
4369    /// Postal codes to be targeted. For each postal code only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a postal code, do not target or exclude the country of the postal code.
4370    #[serde(rename = "postalCodes")]
4371    pub postal_codes: Option<Vec<PostalCode>>,
4372    /// Regions to be targeted. For each region only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting a region, do not target or exclude the country of the region.
4373    pub regions: Option<Vec<Region>>,
4374}
4375
4376impl common::Part for GeoTargeting {}
4377
4378/// Represents a buy from the Planning inventory store.
4379///
4380/// # Activities
4381///
4382/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4383/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4384///
4385/// * [get inventory items](InventoryItemGetCall) (response)
4386/// * [list inventory items](InventoryItemListCall) (none)
4387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4388#[serde_with::serde_as]
4389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4390pub struct InventoryItem {
4391    /// Account ID of this inventory item.
4392    #[serde(rename = "accountId")]
4393    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4394    pub account_id: Option<i64>,
4395    /// Ad slots of this inventory item. If this inventory item represents a standalone placement, there will be exactly one ad slot. If this inventory item represents a placement group, there will be more than one ad slot, each representing one child placement in that placement group.
4396    #[serde(rename = "adSlots")]
4397    pub ad_slots: Option<Vec<AdSlot>>,
4398    /// Advertiser ID of this inventory item.
4399    #[serde(rename = "advertiserId")]
4400    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4401    pub advertiser_id: Option<i64>,
4402    /// Content category ID of this inventory item.
4403    #[serde(rename = "contentCategoryId")]
4404    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4405    pub content_category_id: Option<i64>,
4406    /// Estimated click-through rate of this inventory item.
4407    #[serde(rename = "estimatedClickThroughRate")]
4408    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4409    pub estimated_click_through_rate: Option<i64>,
4410    /// Estimated conversion rate of this inventory item.
4411    #[serde(rename = "estimatedConversionRate")]
4412    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4413    pub estimated_conversion_rate: Option<i64>,
4414    /// ID of this inventory item.
4415    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4416    pub id: Option<i64>,
4417    /// Whether this inventory item is in plan.
4418    #[serde(rename = "inPlan")]
4419    pub in_plan: Option<bool>,
4420    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItem".
4421    pub kind: Option<String>,
4422    /// Information about the most recent modification of this inventory item.
4423    #[serde(rename = "lastModifiedInfo")]
4424    pub last_modified_info: Option<LastModifiedInfo>,
4425    /// Name of this inventory item. For standalone inventory items, this is the same name as that of its only ad slot. For group inventory items, this can differ from the name of any of its ad slots.
4426    pub name: Option<String>,
4427    /// Negotiation channel ID of this inventory item.
4428    #[serde(rename = "negotiationChannelId")]
4429    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4430    pub negotiation_channel_id: Option<i64>,
4431    /// Order ID of this inventory item.
4432    #[serde(rename = "orderId")]
4433    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4434    pub order_id: Option<i64>,
4435    /// Placement strategy ID of this inventory item.
4436    #[serde(rename = "placementStrategyId")]
4437    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4438    pub placement_strategy_id: Option<i64>,
4439    /// Pricing of this inventory item.
4440    pub pricing: Option<Pricing>,
4441    /// Project ID of this inventory item.
4442    #[serde(rename = "projectId")]
4443    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4444    pub project_id: Option<i64>,
4445    /// RFP ID of this inventory item.
4446    #[serde(rename = "rfpId")]
4447    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4448    pub rfp_id: Option<i64>,
4449    /// ID of the site this inventory item is associated with.
4450    #[serde(rename = "siteId")]
4451    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4452    pub site_id: Option<i64>,
4453    /// Subaccount ID of this inventory item.
4454    #[serde(rename = "subaccountId")]
4455    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4456    pub subaccount_id: Option<i64>,
4457    /// Type of inventory item.
4458    #[serde(rename = "type")]
4459    pub type_: Option<String>,
4460}
4461
4462impl common::Resource for InventoryItem {}
4463impl common::ResponseResult for InventoryItem {}
4464
4465/// Inventory item List Response
4466///
4467/// # Activities
4468///
4469/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4470/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4471///
4472/// * [list inventory items](InventoryItemListCall) (response)
4473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4474#[serde_with::serde_as]
4475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4476pub struct InventoryItemsListResponse {
4477    /// Inventory item collection
4478    #[serde(rename = "inventoryItems")]
4479    pub inventory_items: Option<Vec<InventoryItem>>,
4480    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItemsListResponse".
4481    pub kind: Option<String>,
4482    /// Pagination token to be used for the next list operation.
4483    #[serde(rename = "nextPageToken")]
4484    pub next_page_token: Option<String>,
4485}
4486
4487impl common::ResponseResult for InventoryItemsListResponse {}
4488
4489/// Key Value Targeting Expression.
4490///
4491/// This type is not used in any activity, and only used as *part* of another schema.
4492///
4493#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4494#[serde_with::serde_as]
4495#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4496pub struct KeyValueTargetingExpression {
4497    /// Keyword expression being targeted by the ad.
4498    pub expression: Option<String>,
4499}
4500
4501impl common::Part for KeyValueTargetingExpression {}
4502
4503/// Contains information about where a user’s browser is taken after the user clicks an ad.
4504///
4505/// # Activities
4506///
4507/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4508/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4509///
4510/// * [get advertiser landing pages](AdvertiserLandingPageGetCall) (response)
4511/// * [insert advertiser landing pages](AdvertiserLandingPageInsertCall) (request|response)
4512/// * [patch advertiser landing pages](AdvertiserLandingPagePatchCall) (request|response)
4513/// * [update advertiser landing pages](AdvertiserLandingPageUpdateCall) (request|response)
4514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4515#[serde_with::serde_as]
4516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4517pub struct LandingPage {
4518    /// Advertiser ID of this landing page. This is a required field.
4519    #[serde(rename = "advertiserId")]
4520    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4521    pub advertiser_id: Option<i64>,
4522    /// Whether this landing page has been archived.
4523    pub archived: Option<bool>,
4524    /// Links that will direct the user to a mobile app, if installed.
4525    #[serde(rename = "deepLinks")]
4526    pub deep_links: Option<Vec<DeepLink>>,
4527    /// ID of this landing page. This is a read-only, auto-generated field.
4528    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4529    pub id: Option<i64>,
4530    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPage".
4531    pub kind: Option<String>,
4532    /// Name of this landing page. This is a required field. It must be less than 256 characters long.
4533    pub name: Option<String>,
4534    /// URL of this landing page. This is a required field.
4535    pub url: Option<String>,
4536}
4537
4538impl common::RequestValue for LandingPage {}
4539impl common::ResponseResult for LandingPage {}
4540
4541/// Contains information about a language that can be targeted by ads.
4542///
4543/// # Activities
4544///
4545/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4546/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4547///
4548/// * [list languages](LanguageListCall) (none)
4549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4550#[serde_with::serde_as]
4551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4552pub struct Language {
4553    /// Language ID of this language. This is the ID used for targeting and generating reports.
4554    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4555    pub id: Option<i64>,
4556    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#language".
4557    pub kind: Option<String>,
4558    /// Format of language code is an ISO 639 two-letter language code optionally followed by an underscore followed by an ISO 3166 code. Examples are "en" for English or "zh_CN" for Simplified Chinese.
4559    #[serde(rename = "languageCode")]
4560    pub language_code: Option<String>,
4561    /// Name of this language.
4562    pub name: Option<String>,
4563}
4564
4565impl common::Resource for Language {}
4566
4567/// Language Targeting.
4568///
4569/// This type is not used in any activity, and only used as *part* of another schema.
4570///
4571#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4572#[serde_with::serde_as]
4573#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4574pub struct LanguageTargeting {
4575    /// Languages that this ad targets. For each language only languageId is required. The other fields are populated automatically when the ad is inserted or updated.
4576    pub languages: Option<Vec<Language>>,
4577}
4578
4579impl common::Part for LanguageTargeting {}
4580
4581/// Language List Response
4582///
4583/// # Activities
4584///
4585/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4586/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4587///
4588/// * [list languages](LanguageListCall) (response)
4589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4590#[serde_with::serde_as]
4591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4592pub struct LanguagesListResponse {
4593    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#languagesListResponse".
4594    pub kind: Option<String>,
4595    /// Language collection.
4596    pub languages: Option<Vec<Language>>,
4597}
4598
4599impl common::ResponseResult for LanguagesListResponse {}
4600
4601/// Modification timestamp.
4602///
4603/// This type is not used in any activity, and only used as *part* of another schema.
4604///
4605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4606#[serde_with::serde_as]
4607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4608pub struct LastModifiedInfo {
4609    /// Timestamp of the last change in milliseconds since epoch.
4610    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4611    pub time: Option<i64>,
4612}
4613
4614impl common::Part for LastModifiedInfo {}
4615
4616/// A group clause made up of list population terms representing constraints joined by ORs.
4617///
4618/// This type is not used in any activity, and only used as *part* of another schema.
4619///
4620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4621#[serde_with::serde_as]
4622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4623pub struct ListPopulationClause {
4624    /// Terms of this list population clause. Each clause is made up of list population terms representing constraints and are joined by ORs.
4625    pub terms: Option<Vec<ListPopulationTerm>>,
4626}
4627
4628impl common::Part for ListPopulationClause {}
4629
4630/// Remarketing List Population Rule.
4631///
4632/// This type is not used in any activity, and only used as *part* of another schema.
4633///
4634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4635#[serde_with::serde_as]
4636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4637pub struct ListPopulationRule {
4638    /// Floodlight activity ID associated with this rule. This field can be left blank.
4639    #[serde(rename = "floodlightActivityId")]
4640    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4641    pub floodlight_activity_id: Option<i64>,
4642    /// Name of floodlight activity associated with this rule. This is a read-only, auto-generated field.
4643    #[serde(rename = "floodlightActivityName")]
4644    pub floodlight_activity_name: Option<String>,
4645    /// Clauses that make up this list population rule. Clauses are joined by ANDs, and the clauses themselves are made up of list population terms which are joined by ORs.
4646    #[serde(rename = "listPopulationClauses")]
4647    pub list_population_clauses: Option<Vec<ListPopulationClause>>,
4648}
4649
4650impl common::Part for ListPopulationRule {}
4651
4652/// Remarketing List Population Rule Term.
4653///
4654/// This type is not used in any activity, and only used as *part* of another schema.
4655///
4656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4657#[serde_with::serde_as]
4658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4659pub struct ListPopulationTerm {
4660    /// Will be true if the term should check if the user is in the list and false if the term should check if the user is not in the list. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. False by default.
4661    pub contains: Option<bool>,
4662    /// Whether to negate the comparison result of this term during rule evaluation. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM.
4663    pub negation: Option<bool>,
4664    /// Comparison operator of this term. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM.
4665    pub operator: Option<String>,
4666    /// ID of the list in question. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM.
4667    #[serde(rename = "remarketingListId")]
4668    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4669    pub remarketing_list_id: Option<i64>,
4670    /// List population term type determines the applicable fields in this object. If left unset or set to CUSTOM_VARIABLE_TERM, then variableName, variableFriendlyName, operator, value, and negation are applicable. If set to LIST_MEMBERSHIP_TERM then remarketingListId and contains are applicable. If set to REFERRER_TERM then operator, value, and negation are applicable.
4671    #[serde(rename = "type")]
4672    pub type_: Option<String>,
4673    /// Literal to compare the variable to. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM.
4674    pub value: Option<String>,
4675    /// Friendly name of this term's variable. This is a read-only, auto-generated field. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM.
4676    #[serde(rename = "variableFriendlyName")]
4677    pub variable_friendly_name: Option<String>,
4678    /// Name of the variable (U1, U2, etc.) being compared in this term. This field is only relevant when type is set to null, CUSTOM_VARIABLE_TERM or REFERRER_TERM.
4679    #[serde(rename = "variableName")]
4680    pub variable_name: Option<String>,
4681}
4682
4683impl common::Part for ListPopulationTerm {}
4684
4685/// Remarketing List Targeting Expression.
4686///
4687/// This type is not used in any activity, and only used as *part* of another schema.
4688///
4689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4690#[serde_with::serde_as]
4691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4692pub struct ListTargetingExpression {
4693    /// Expression describing which lists are being targeted by the ad.
4694    pub expression: Option<String>,
4695}
4696
4697impl common::Part for ListTargetingExpression {}
4698
4699/// Lookback configuration settings.
4700///
4701/// This type is not used in any activity, and only used as *part* of another schema.
4702///
4703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4704#[serde_with::serde_as]
4705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4706pub struct LookbackConfiguration {
4707    /// Lookback window, in days, from the last time a given user clicked on one of your ads. If you enter 0, clicks will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. Acceptable values are 0 to 90, inclusive.
4708    #[serde(rename = "clickDuration")]
4709    pub click_duration: Option<i32>,
4710    /// Lookback window, in days, from the last time a given user viewed one of your ads. If you enter 0, impressions will not be considered as triggering events for floodlight tracking. If you leave this field blank, the default value for your account will be used. Acceptable values are 0 to 90, inclusive.
4711    #[serde(rename = "postImpressionActivitiesDuration")]
4712    pub post_impression_activities_duration: Option<i32>,
4713}
4714
4715impl common::Part for LookbackConfiguration {}
4716
4717/// Represents a metric.
4718///
4719/// This type is not used in any activity, and only used as *part* of another schema.
4720///
4721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4722#[serde_with::serde_as]
4723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4724pub struct Metric {
4725    /// The kind of resource this is, in this case dfareporting#metric.
4726    pub kind: Option<String>,
4727    /// The metric name, e.g. dfa:impressions
4728    pub name: Option<String>,
4729}
4730
4731impl common::Part for Metric {}
4732
4733/// Contains information about a metro region that can be targeted by ads.
4734///
4735/// # Activities
4736///
4737/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4738/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4739///
4740/// * [list metros](MetroListCall) (none)
4741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4742#[serde_with::serde_as]
4743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4744pub struct Metro {
4745    /// Country code of the country to which this metro region belongs.
4746    #[serde(rename = "countryCode")]
4747    pub country_code: Option<String>,
4748    /// DART ID of the country to which this metro region belongs.
4749    #[serde(rename = "countryDartId")]
4750    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4751    pub country_dart_id: Option<i64>,
4752    /// DART ID of this metro region.
4753    #[serde(rename = "dartId")]
4754    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4755    pub dart_id: Option<i64>,
4756    /// DMA ID of this metro region. This is the ID used for targeting and generating reports, and is equivalent to metro_code.
4757    #[serde(rename = "dmaId")]
4758    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4759    pub dma_id: Option<i64>,
4760    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metro".
4761    pub kind: Option<String>,
4762    /// Metro code of this metro region. This is equivalent to dma_id.
4763    #[serde(rename = "metroCode")]
4764    pub metro_code: Option<String>,
4765    /// Name of this metro region.
4766    pub name: Option<String>,
4767}
4768
4769impl common::Resource for Metro {}
4770
4771/// Metro List Response
4772///
4773/// # Activities
4774///
4775/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4776/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4777///
4778/// * [list metros](MetroListCall) (response)
4779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4780#[serde_with::serde_as]
4781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4782pub struct MetrosListResponse {
4783    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metrosListResponse".
4784    pub kind: Option<String>,
4785    /// Metro collection.
4786    pub metros: Option<Vec<Metro>>,
4787}
4788
4789impl common::ResponseResult for MetrosListResponse {}
4790
4791/// Contains information about a mobile app. Used as a landing page deep link.
4792///
4793/// # Activities
4794///
4795/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4797///
4798/// * [get mobile apps](MobileAppGetCall) (response)
4799/// * [list mobile apps](MobileAppListCall) (none)
4800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4801#[serde_with::serde_as]
4802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4803pub struct MobileApp {
4804    /// Mobile app directory.
4805    pub directory: Option<String>,
4806    /// ID of this mobile app.
4807    pub id: Option<String>,
4808    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileApp".
4809    pub kind: Option<String>,
4810    /// Publisher name.
4811    #[serde(rename = "publisherName")]
4812    pub publisher_name: Option<String>,
4813    /// Title of this mobile app.
4814    pub title: Option<String>,
4815}
4816
4817impl common::Resource for MobileApp {}
4818impl common::ResponseResult for MobileApp {}
4819
4820/// Mobile app List Response
4821///
4822/// # Activities
4823///
4824/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4825/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4826///
4827/// * [list mobile apps](MobileAppListCall) (response)
4828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4829#[serde_with::serde_as]
4830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4831pub struct MobileAppsListResponse {
4832    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileAppsListResponse".
4833    pub kind: Option<String>,
4834    /// Mobile apps collection.
4835    #[serde(rename = "mobileApps")]
4836    pub mobile_apps: Option<Vec<MobileApp>>,
4837    /// Pagination token to be used for the next list operation.
4838    #[serde(rename = "nextPageToken")]
4839    pub next_page_token: Option<String>,
4840}
4841
4842impl common::ResponseResult for MobileAppsListResponse {}
4843
4844/// Contains information about a mobile carrier that can be targeted by ads.
4845///
4846/// # Activities
4847///
4848/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4849/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4850///
4851/// * [get mobile carriers](MobileCarrierGetCall) (response)
4852/// * [list mobile carriers](MobileCarrierListCall) (none)
4853#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4854#[serde_with::serde_as]
4855#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4856pub struct MobileCarrier {
4857    /// Country code of the country to which this mobile carrier belongs.
4858    #[serde(rename = "countryCode")]
4859    pub country_code: Option<String>,
4860    /// DART ID of the country to which this mobile carrier belongs.
4861    #[serde(rename = "countryDartId")]
4862    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4863    pub country_dart_id: Option<i64>,
4864    /// ID of this mobile carrier.
4865    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4866    pub id: Option<i64>,
4867    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarrier".
4868    pub kind: Option<String>,
4869    /// Name of this mobile carrier.
4870    pub name: Option<String>,
4871}
4872
4873impl common::Resource for MobileCarrier {}
4874impl common::ResponseResult for MobileCarrier {}
4875
4876/// Mobile Carrier List Response
4877///
4878/// # Activities
4879///
4880/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4881/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4882///
4883/// * [list mobile carriers](MobileCarrierListCall) (response)
4884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4885#[serde_with::serde_as]
4886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4887pub struct MobileCarriersListResponse {
4888    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarriersListResponse".
4889    pub kind: Option<String>,
4890    /// Mobile carrier collection.
4891    #[serde(rename = "mobileCarriers")]
4892    pub mobile_carriers: Option<Vec<MobileCarrier>>,
4893}
4894
4895impl common::ResponseResult for MobileCarriersListResponse {}
4896
4897/// Object Filter.
4898///
4899/// This type is not used in any activity, and only used as *part* of another schema.
4900///
4901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4902#[serde_with::serde_as]
4903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4904pub struct ObjectFilter {
4905    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#objectFilter".
4906    pub kind: Option<String>,
4907    /// Applicable when status is ASSIGNED. The user has access to objects with these object IDs.
4908    #[serde(rename = "objectIds")]
4909    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
4910    pub object_ids: Option<Vec<i64>>,
4911    /// Status of the filter. NONE means the user has access to none of the objects. ALL means the user has access to all objects. ASSIGNED means the user has access to the objects with IDs in the objectIds list.
4912    pub status: Option<String>,
4913}
4914
4915impl common::Part for ObjectFilter {}
4916
4917/// Offset Position.
4918///
4919/// This type is not used in any activity, and only used as *part* of another schema.
4920///
4921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4922#[serde_with::serde_as]
4923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4924pub struct OffsetPosition {
4925    /// Offset distance from left side of an asset or a window.
4926    pub left: Option<i32>,
4927    /// Offset distance from top side of an asset or a window.
4928    pub top: Option<i32>,
4929}
4930
4931impl common::Part for OffsetPosition {}
4932
4933/// Omniture Integration Settings.
4934///
4935/// This type is not used in any activity, and only used as *part* of another schema.
4936///
4937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4938#[serde_with::serde_as]
4939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4940pub struct OmnitureSettings {
4941    /// Whether placement cost data will be sent to Omniture. This property can be enabled only if omnitureIntegrationEnabled is true.
4942    #[serde(rename = "omnitureCostDataEnabled")]
4943    pub omniture_cost_data_enabled: Option<bool>,
4944    /// Whether Omniture integration is enabled. This property can be enabled only when the "Advanced Ad Serving" account setting is enabled.
4945    #[serde(rename = "omnitureIntegrationEnabled")]
4946    pub omniture_integration_enabled: Option<bool>,
4947}
4948
4949impl common::Part for OmnitureSettings {}
4950
4951/// Contains information about an operating system that can be targeted by ads.
4952///
4953/// # Activities
4954///
4955/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4956/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4957///
4958/// * [get operating systems](OperatingSystemGetCall) (response)
4959/// * [list operating systems](OperatingSystemListCall) (none)
4960#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4961#[serde_with::serde_as]
4962#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4963pub struct OperatingSystem {
4964    /// DART ID of this operating system. This is the ID used for targeting.
4965    #[serde(rename = "dartId")]
4966    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4967    pub dart_id: Option<i64>,
4968    /// Whether this operating system is for desktop.
4969    pub desktop: Option<bool>,
4970    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystem".
4971    pub kind: Option<String>,
4972    /// Whether this operating system is for mobile.
4973    pub mobile: Option<bool>,
4974    /// Name of this operating system.
4975    pub name: Option<String>,
4976}
4977
4978impl common::Resource for OperatingSystem {}
4979impl common::ResponseResult for OperatingSystem {}
4980
4981/// Contains information about a particular version of an operating system that can be targeted by ads.
4982///
4983/// # Activities
4984///
4985/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
4986/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
4987///
4988/// * [get operating system versions](OperatingSystemVersionGetCall) (response)
4989/// * [list operating system versions](OperatingSystemVersionListCall) (none)
4990#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
4991#[serde_with::serde_as]
4992#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
4993pub struct OperatingSystemVersion {
4994    /// ID of this operating system version.
4995    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
4996    pub id: Option<i64>,
4997    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersion".
4998    pub kind: Option<String>,
4999    /// Major version (leftmost number) of this operating system version.
5000    #[serde(rename = "majorVersion")]
5001    pub major_version: Option<String>,
5002    /// Minor version (number after the first dot) of this operating system version.
5003    #[serde(rename = "minorVersion")]
5004    pub minor_version: Option<String>,
5005    /// Name of this operating system version.
5006    pub name: Option<String>,
5007    /// Operating system of this operating system version.
5008    #[serde(rename = "operatingSystem")]
5009    pub operating_system: Option<OperatingSystem>,
5010}
5011
5012impl common::Resource for OperatingSystemVersion {}
5013impl common::ResponseResult for OperatingSystemVersion {}
5014
5015/// Operating System Version List Response
5016///
5017/// # Activities
5018///
5019/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5020/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5021///
5022/// * [list operating system versions](OperatingSystemVersionListCall) (response)
5023#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5024#[serde_with::serde_as]
5025#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5026pub struct OperatingSystemVersionsListResponse {
5027    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse".
5028    pub kind: Option<String>,
5029    /// Operating system version collection.
5030    #[serde(rename = "operatingSystemVersions")]
5031    pub operating_system_versions: Option<Vec<OperatingSystemVersion>>,
5032}
5033
5034impl common::ResponseResult for OperatingSystemVersionsListResponse {}
5035
5036/// Operating System List Response
5037///
5038/// # Activities
5039///
5040/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5041/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5042///
5043/// * [list operating systems](OperatingSystemListCall) (response)
5044#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5045#[serde_with::serde_as]
5046#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5047pub struct OperatingSystemsListResponse {
5048    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemsListResponse".
5049    pub kind: Option<String>,
5050    /// Operating system collection.
5051    #[serde(rename = "operatingSystems")]
5052    pub operating_systems: Option<Vec<OperatingSystem>>,
5053}
5054
5055impl common::ResponseResult for OperatingSystemsListResponse {}
5056
5057/// Creative optimization activity.
5058///
5059/// This type is not used in any activity, and only used as *part* of another schema.
5060///
5061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5062#[serde_with::serde_as]
5063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5064pub struct OptimizationActivity {
5065    /// Floodlight activity ID of this optimization activity. This is a required field.
5066    #[serde(rename = "floodlightActivityId")]
5067    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5068    pub floodlight_activity_id: Option<i64>,
5069    /// Dimension value for the ID of the floodlight activity. This is a read-only, auto-generated field.
5070    #[serde(rename = "floodlightActivityIdDimensionValue")]
5071    pub floodlight_activity_id_dimension_value: Option<DimensionValue>,
5072    /// Weight associated with this optimization. The weight assigned will be understood in proportion to the weights assigned to the other optimization activities. Value must be greater than or equal to 1.
5073    pub weight: Option<i32>,
5074}
5075
5076impl common::Part for OptimizationActivity {}
5077
5078/// Describes properties of a Planning order.
5079///
5080/// # Activities
5081///
5082/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5083/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5084///
5085/// * [get orders](OrderGetCall) (response)
5086/// * [list orders](OrderListCall) (none)
5087#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5088#[serde_with::serde_as]
5089#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5090pub struct Order {
5091    /// Account ID of this order.
5092    #[serde(rename = "accountId")]
5093    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5094    pub account_id: Option<i64>,
5095    /// Advertiser ID of this order.
5096    #[serde(rename = "advertiserId")]
5097    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5098    pub advertiser_id: Option<i64>,
5099    /// IDs for users that have to approve documents created for this order.
5100    #[serde(rename = "approverUserProfileIds")]
5101    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
5102    pub approver_user_profile_ids: Option<Vec<i64>>,
5103    /// Buyer invoice ID associated with this order.
5104    #[serde(rename = "buyerInvoiceId")]
5105    pub buyer_invoice_id: Option<String>,
5106    /// Name of the buyer organization.
5107    #[serde(rename = "buyerOrganizationName")]
5108    pub buyer_organization_name: Option<String>,
5109    /// Comments in this order.
5110    pub comments: Option<String>,
5111    /// Contacts for this order.
5112    pub contacts: Option<Vec<OrderContact>>,
5113    /// ID of this order. This is a read-only, auto-generated field.
5114    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5115    pub id: Option<i64>,
5116    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#order".
5117    pub kind: Option<String>,
5118    /// Information about the most recent modification of this order.
5119    #[serde(rename = "lastModifiedInfo")]
5120    pub last_modified_info: Option<LastModifiedInfo>,
5121    /// Name of this order.
5122    pub name: Option<String>,
5123    /// Notes of this order.
5124    pub notes: Option<String>,
5125    /// ID of the terms and conditions template used in this order.
5126    #[serde(rename = "planningTermId")]
5127    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5128    pub planning_term_id: Option<i64>,
5129    /// Project ID of this order.
5130    #[serde(rename = "projectId")]
5131    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5132    pub project_id: Option<i64>,
5133    /// Seller order ID associated with this order.
5134    #[serde(rename = "sellerOrderId")]
5135    pub seller_order_id: Option<String>,
5136    /// Name of the seller organization.
5137    #[serde(rename = "sellerOrganizationName")]
5138    pub seller_organization_name: Option<String>,
5139    /// Site IDs this order is associated with.
5140    #[serde(rename = "siteId")]
5141    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
5142    pub site_id: Option<Vec<i64>>,
5143    /// Free-form site names this order is associated with.
5144    #[serde(rename = "siteNames")]
5145    pub site_names: Option<Vec<String>>,
5146    /// Subaccount ID of this order.
5147    #[serde(rename = "subaccountId")]
5148    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5149    pub subaccount_id: Option<i64>,
5150    /// Terms and conditions of this order.
5151    #[serde(rename = "termsAndConditions")]
5152    pub terms_and_conditions: Option<String>,
5153}
5154
5155impl common::Resource for Order {}
5156impl common::ResponseResult for Order {}
5157
5158/// Contact of an order.
5159///
5160/// This type is not used in any activity, and only used as *part* of another schema.
5161///
5162#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5163#[serde_with::serde_as]
5164#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5165pub struct OrderContact {
5166    /// Free-form information about this contact. It could be any information related to this contact in addition to type, title, name, and signature user profile ID.
5167    #[serde(rename = "contactInfo")]
5168    pub contact_info: Option<String>,
5169    /// Name of this contact.
5170    #[serde(rename = "contactName")]
5171    pub contact_name: Option<String>,
5172    /// Title of this contact.
5173    #[serde(rename = "contactTitle")]
5174    pub contact_title: Option<String>,
5175    /// Type of this contact.
5176    #[serde(rename = "contactType")]
5177    pub contact_type: Option<String>,
5178    /// ID of the user profile containing the signature that will be embedded into order documents.
5179    #[serde(rename = "signatureUserProfileId")]
5180    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5181    pub signature_user_profile_id: Option<i64>,
5182}
5183
5184impl common::Part for OrderContact {}
5185
5186/// Contains properties of a Planning order document.
5187///
5188/// # Activities
5189///
5190/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5191/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5192///
5193/// * [get order documents](OrderDocumentGetCall) (response)
5194/// * [list order documents](OrderDocumentListCall) (none)
5195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5196#[serde_with::serde_as]
5197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5198pub struct OrderDocument {
5199    /// Account ID of this order document.
5200    #[serde(rename = "accountId")]
5201    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5202    pub account_id: Option<i64>,
5203    /// Advertiser ID of this order document.
5204    #[serde(rename = "advertiserId")]
5205    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5206    pub advertiser_id: Option<i64>,
5207    /// The amended order document ID of this order document. An order document can be created by optionally amending another order document so that the change history can be preserved.
5208    #[serde(rename = "amendedOrderDocumentId")]
5209    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5210    pub amended_order_document_id: Option<i64>,
5211    /// IDs of users who have approved this order document.
5212    #[serde(rename = "approvedByUserProfileIds")]
5213    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
5214    pub approved_by_user_profile_ids: Option<Vec<i64>>,
5215    /// Whether this order document is cancelled.
5216    pub cancelled: Option<bool>,
5217    /// Information about the creation of this order document.
5218    #[serde(rename = "createdInfo")]
5219    pub created_info: Option<LastModifiedInfo>,
5220    /// Effective date of this order document.
5221    #[serde(rename = "effectiveDate")]
5222    pub effective_date: Option<chrono::NaiveDate>,
5223    /// ID of this order document.
5224    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5225    pub id: Option<i64>,
5226    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocument".
5227    pub kind: Option<String>,
5228    /// List of email addresses that received the last sent document.
5229    #[serde(rename = "lastSentRecipients")]
5230    pub last_sent_recipients: Option<Vec<String>>,
5231    /// Timestamp of the last email sent with this order document.
5232    #[serde(rename = "lastSentTime")]
5233    pub last_sent_time: Option<chrono::DateTime<chrono::offset::Utc>>,
5234    /// ID of the order from which this order document is created.
5235    #[serde(rename = "orderId")]
5236    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5237    pub order_id: Option<i64>,
5238    /// Project ID of this order document.
5239    #[serde(rename = "projectId")]
5240    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5241    pub project_id: Option<i64>,
5242    /// Whether this order document has been signed.
5243    pub signed: Option<bool>,
5244    /// Subaccount ID of this order document.
5245    #[serde(rename = "subaccountId")]
5246    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5247    pub subaccount_id: Option<i64>,
5248    /// Title of this order document.
5249    pub title: Option<String>,
5250    /// Type of this order document
5251    #[serde(rename = "type")]
5252    pub type_: Option<String>,
5253}
5254
5255impl common::Resource for OrderDocument {}
5256impl common::ResponseResult for OrderDocument {}
5257
5258/// Order document List Response
5259///
5260/// # Activities
5261///
5262/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5263/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5264///
5265/// * [list order documents](OrderDocumentListCall) (response)
5266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5267#[serde_with::serde_as]
5268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5269pub struct OrderDocumentsListResponse {
5270    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocumentsListResponse".
5271    pub kind: Option<String>,
5272    /// Pagination token to be used for the next list operation.
5273    #[serde(rename = "nextPageToken")]
5274    pub next_page_token: Option<String>,
5275    /// Order document collection
5276    #[serde(rename = "orderDocuments")]
5277    pub order_documents: Option<Vec<OrderDocument>>,
5278}
5279
5280impl common::ResponseResult for OrderDocumentsListResponse {}
5281
5282/// Order List Response
5283///
5284/// # Activities
5285///
5286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5288///
5289/// * [list orders](OrderListCall) (response)
5290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5291#[serde_with::serde_as]
5292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5293pub struct OrdersListResponse {
5294    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ordersListResponse".
5295    pub kind: Option<String>,
5296    /// Pagination token to be used for the next list operation.
5297    #[serde(rename = "nextPageToken")]
5298    pub next_page_token: Option<String>,
5299    /// Order collection.
5300    pub orders: Option<Vec<Order>>,
5301}
5302
5303impl common::ResponseResult for OrdersListResponse {}
5304
5305/// Represents fields that are compatible to be selected for a report of type "PATH_TO_CONVERSION".
5306///
5307/// This type is not used in any activity, and only used as *part* of another schema.
5308///
5309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5310#[serde_with::serde_as]
5311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5312pub struct PathToConversionReportCompatibleFields {
5313    /// Conversion dimensions which are compatible to be selected in the "conversionDimensions" section of the report.
5314    #[serde(rename = "conversionDimensions")]
5315    pub conversion_dimensions: Option<Vec<Dimension>>,
5316    /// Custom floodlight variables which are compatible to be selected in the "customFloodlightVariables" section of the report.
5317    #[serde(rename = "customFloodlightVariables")]
5318    pub custom_floodlight_variables: Option<Vec<Dimension>>,
5319    /// The kind of resource this is, in this case dfareporting#pathToConversionReportCompatibleFields.
5320    pub kind: Option<String>,
5321    /// Metrics which are compatible to be selected in the "metricNames" section of the report.
5322    pub metrics: Option<Vec<Metric>>,
5323    /// Per-interaction dimensions which are compatible to be selected in the "perInteractionDimensions" section of the report.
5324    #[serde(rename = "perInteractionDimensions")]
5325    pub per_interaction_dimensions: Option<Vec<Dimension>>,
5326}
5327
5328impl common::Part for PathToConversionReportCompatibleFields {}
5329
5330/// Contains properties of a placement.
5331///
5332/// # Activities
5333///
5334/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5335/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5336///
5337/// * [generatetags placements](PlacementGeneratetagCall) (none)
5338/// * [get placements](PlacementGetCall) (response)
5339/// * [insert placements](PlacementInsertCall) (request|response)
5340/// * [list placements](PlacementListCall) (none)
5341/// * [patch placements](PlacementPatchCall) (request|response)
5342/// * [update placements](PlacementUpdateCall) (request|response)
5343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5344#[serde_with::serde_as]
5345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5346pub struct Placement {
5347    /// Account ID of this placement. This field can be left blank.
5348    #[serde(rename = "accountId")]
5349    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5350    pub account_id: Option<i64>,
5351    /// Whether this placement opts out of ad blocking. When true, ad blocking is disabled for this placement. When false, the campaign and site settings take effect.
5352    #[serde(rename = "adBlockingOptOut")]
5353    pub ad_blocking_opt_out: Option<bool>,
5354    /// Additional sizes associated with this placement. When inserting or updating a placement, only the size ID field is used.
5355    #[serde(rename = "additionalSizes")]
5356    pub additional_sizes: Option<Vec<Size>>,
5357    /// Advertiser ID of this placement. This field can be left blank.
5358    #[serde(rename = "advertiserId")]
5359    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5360    pub advertiser_id: Option<i64>,
5361    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
5362    #[serde(rename = "advertiserIdDimensionValue")]
5363    pub advertiser_id_dimension_value: Option<DimensionValue>,
5364    /// Whether this placement is archived.
5365    pub archived: Option<bool>,
5366    /// Campaign ID of this placement. This field is a required field on insertion.
5367    #[serde(rename = "campaignId")]
5368    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5369    pub campaign_id: Option<i64>,
5370    /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field.
5371    #[serde(rename = "campaignIdDimensionValue")]
5372    pub campaign_id_dimension_value: Option<DimensionValue>,
5373    /// Comments for this placement.
5374    pub comment: Option<String>,
5375    /// Placement compatibility. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering on desktop, on mobile devices or in mobile apps for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are no longer allowed for new placement insertions. Instead, use DISPLAY or DISPLAY_INTERSTITIAL. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard. This field is required on insertion.
5376    pub compatibility: Option<String>,
5377    /// ID of the content category assigned to this placement.
5378    #[serde(rename = "contentCategoryId")]
5379    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5380    pub content_category_id: Option<i64>,
5381    /// Information about the creation of this placement. This is a read-only field.
5382    #[serde(rename = "createInfo")]
5383    pub create_info: Option<LastModifiedInfo>,
5384    /// Directory site ID of this placement. On insert, you must set either this field or the siteId field to specify the site associated with this placement. This is a required field that is read-only after insertion.
5385    #[serde(rename = "directorySiteId")]
5386    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5387    pub directory_site_id: Option<i64>,
5388    /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field.
5389    #[serde(rename = "directorySiteIdDimensionValue")]
5390    pub directory_site_id_dimension_value: Option<DimensionValue>,
5391    /// External ID for this placement.
5392    #[serde(rename = "externalId")]
5393    pub external_id: Option<String>,
5394    /// ID of this placement. This is a read-only, auto-generated field.
5395    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5396    pub id: Option<i64>,
5397    /// Dimension value for the ID of this placement. This is a read-only, auto-generated field.
5398    #[serde(rename = "idDimensionValue")]
5399    pub id_dimension_value: Option<DimensionValue>,
5400    /// Key name of this placement. This is a read-only, auto-generated field.
5401    #[serde(rename = "keyName")]
5402    pub key_name: Option<String>,
5403    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placement".
5404    pub kind: Option<String>,
5405    /// Information about the most recent modification of this placement. This is a read-only field.
5406    #[serde(rename = "lastModifiedInfo")]
5407    pub last_modified_info: Option<LastModifiedInfo>,
5408    /// Lookback window settings for this placement.
5409    #[serde(rename = "lookbackConfiguration")]
5410    pub lookback_configuration: Option<LookbackConfiguration>,
5411    /// Name of this placement.This is a required field and must be less than 256 characters long.
5412    pub name: Option<String>,
5413    /// Whether payment was approved for this placement. This is a read-only field relevant only to publisher-paid placements.
5414    #[serde(rename = "paymentApproved")]
5415    pub payment_approved: Option<bool>,
5416    /// Payment source for this placement. This is a required field that is read-only after insertion.
5417    #[serde(rename = "paymentSource")]
5418    pub payment_source: Option<String>,
5419    /// ID of this placement's group, if applicable.
5420    #[serde(rename = "placementGroupId")]
5421    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5422    pub placement_group_id: Option<i64>,
5423    /// Dimension value for the ID of the placement group. This is a read-only, auto-generated field.
5424    #[serde(rename = "placementGroupIdDimensionValue")]
5425    pub placement_group_id_dimension_value: Option<DimensionValue>,
5426    /// ID of the placement strategy assigned to this placement.
5427    #[serde(rename = "placementStrategyId")]
5428    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5429    pub placement_strategy_id: Option<i64>,
5430    /// Pricing schedule of this placement. This field is required on insertion, specifically subfields startDate, endDate and pricingType.
5431    #[serde(rename = "pricingSchedule")]
5432    pub pricing_schedule: Option<PricingSchedule>,
5433    /// Whether this placement is the primary placement of a roadblock (placement group). You cannot change this field from true to false. Setting this field to true will automatically set the primary field on the original primary placement of the roadblock to false, and it will automatically set the roadblock's primaryPlacementId field to the ID of this placement.
5434    pub primary: Option<bool>,
5435    /// Information about the last publisher update. This is a read-only field.
5436    #[serde(rename = "publisherUpdateInfo")]
5437    pub publisher_update_info: Option<LastModifiedInfo>,
5438    /// Site ID associated with this placement. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement. This is a required field that is read-only after insertion.
5439    #[serde(rename = "siteId")]
5440    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5441    pub site_id: Option<i64>,
5442    /// Dimension value for the ID of the site. This is a read-only, auto-generated field.
5443    #[serde(rename = "siteIdDimensionValue")]
5444    pub site_id_dimension_value: Option<DimensionValue>,
5445    /// Size associated with this placement. When inserting or updating a placement, only the size ID field is used. This field is required on insertion.
5446    pub size: Option<Size>,
5447    /// Whether creatives assigned to this placement must be SSL-compliant.
5448    #[serde(rename = "sslRequired")]
5449    pub ssl_required: Option<bool>,
5450    /// Third-party placement status.
5451    pub status: Option<String>,
5452    /// Subaccount ID of this placement. This field can be left blank.
5453    #[serde(rename = "subaccountId")]
5454    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5455    pub subaccount_id: Option<i64>,
5456    /// Tag formats to generate for this placement. This field is required on insertion.
5457    /// Acceptable values are:
5458    /// - "PLACEMENT_TAG_STANDARD"
5459    /// - "PLACEMENT_TAG_IFRAME_JAVASCRIPT"
5460    /// - "PLACEMENT_TAG_IFRAME_ILAYER"
5461    /// - "PLACEMENT_TAG_INTERNAL_REDIRECT"
5462    /// - "PLACEMENT_TAG_JAVASCRIPT"
5463    /// - "PLACEMENT_TAG_INTERSTITIAL_IFRAME_JAVASCRIPT"
5464    /// - "PLACEMENT_TAG_INTERSTITIAL_INTERNAL_REDIRECT"
5465    /// - "PLACEMENT_TAG_INTERSTITIAL_JAVASCRIPT"
5466    /// - "PLACEMENT_TAG_CLICK_COMMANDS"
5467    /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH"
5468    /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH_VAST_3"
5469    /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH_VAST_4"
5470    /// - "PLACEMENT_TAG_TRACKING"
5471    /// - "PLACEMENT_TAG_TRACKING_IFRAME"
5472    /// - "PLACEMENT_TAG_TRACKING_JAVASCRIPT"
5473    #[serde(rename = "tagFormats")]
5474    pub tag_formats: Option<Vec<String>>,
5475    /// Tag settings for this placement.
5476    #[serde(rename = "tagSetting")]
5477    pub tag_setting: Option<TagSetting>,
5478    /// Whether Verification and ActiveView are disabled for in-stream video creatives for this placement. The same setting videoActiveViewOptOut exists on the site level -- the opt out occurs if either of these settings are true. These settings are distinct from DirectorySites.settings.activeViewOptOut or Sites.siteSettings.activeViewOptOut which only apply to display ads. However, Accounts.activeViewOptOut opts out both video traffic, as well as display ads, from Verification and ActiveView.
5479    #[serde(rename = "videoActiveViewOptOut")]
5480    pub video_active_view_opt_out: Option<bool>,
5481    /// A collection of settings which affect video creatives served through this placement. Applicable to placements with IN_STREAM_VIDEO compatibility.
5482    #[serde(rename = "videoSettings")]
5483    pub video_settings: Option<VideoSettings>,
5484    /// VPAID adapter setting for this placement. Controls which VPAID format the measurement adapter will use for in-stream video creatives assigned to this placement.
5485    ///
5486    /// Note: Flash is no longer supported. This field now defaults to HTML5 when the following values are provided: FLASH, BOTH.
5487    #[serde(rename = "vpaidAdapterChoice")]
5488    pub vpaid_adapter_choice: Option<String>,
5489}
5490
5491impl common::RequestValue for Placement {}
5492impl common::Resource for Placement {}
5493impl common::ResponseResult for Placement {}
5494
5495/// Placement Assignment.
5496///
5497/// This type is not used in any activity, and only used as *part* of another schema.
5498///
5499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5500#[serde_with::serde_as]
5501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5502pub struct PlacementAssignment {
5503    /// Whether this placement assignment is active. When true, the placement will be included in the ad's rotation.
5504    pub active: Option<bool>,
5505    /// ID of the placement to be assigned. This is a required field.
5506    #[serde(rename = "placementId")]
5507    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5508    pub placement_id: Option<i64>,
5509    /// Dimension value for the ID of the placement. This is a read-only, auto-generated field.
5510    #[serde(rename = "placementIdDimensionValue")]
5511    pub placement_id_dimension_value: Option<DimensionValue>,
5512    /// Whether the placement to be assigned requires SSL. This is a read-only field that is auto-generated when the ad is inserted or updated.
5513    #[serde(rename = "sslRequired")]
5514    pub ssl_required: Option<bool>,
5515}
5516
5517impl common::Part for PlacementAssignment {}
5518
5519/// Contains properties of a package or roadblock.
5520///
5521/// # Activities
5522///
5523/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5524/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5525///
5526/// * [get placement groups](PlacementGroupGetCall) (response)
5527/// * [insert placement groups](PlacementGroupInsertCall) (request|response)
5528/// * [list placement groups](PlacementGroupListCall) (none)
5529/// * [patch placement groups](PlacementGroupPatchCall) (request|response)
5530/// * [update placement groups](PlacementGroupUpdateCall) (request|response)
5531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5532#[serde_with::serde_as]
5533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5534pub struct PlacementGroup {
5535    /// Account ID of this placement group. This is a read-only field that can be left blank.
5536    #[serde(rename = "accountId")]
5537    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5538    pub account_id: Option<i64>,
5539    /// Advertiser ID of this placement group. This is a required field on insertion.
5540    #[serde(rename = "advertiserId")]
5541    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5542    pub advertiser_id: Option<i64>,
5543    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
5544    #[serde(rename = "advertiserIdDimensionValue")]
5545    pub advertiser_id_dimension_value: Option<DimensionValue>,
5546    /// Whether this placement group is archived.
5547    pub archived: Option<bool>,
5548    /// Campaign ID of this placement group. This field is required on insertion.
5549    #[serde(rename = "campaignId")]
5550    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5551    pub campaign_id: Option<i64>,
5552    /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field.
5553    #[serde(rename = "campaignIdDimensionValue")]
5554    pub campaign_id_dimension_value: Option<DimensionValue>,
5555    /// IDs of placements which are assigned to this placement group. This is a read-only, auto-generated field.
5556    #[serde(rename = "childPlacementIds")]
5557    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
5558    pub child_placement_ids: Option<Vec<i64>>,
5559    /// Comments for this placement group.
5560    pub comment: Option<String>,
5561    /// ID of the content category assigned to this placement group.
5562    #[serde(rename = "contentCategoryId")]
5563    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5564    pub content_category_id: Option<i64>,
5565    /// Information about the creation of this placement group. This is a read-only field.
5566    #[serde(rename = "createInfo")]
5567    pub create_info: Option<LastModifiedInfo>,
5568    /// Directory site ID associated with this placement group. On insert, you must set either this field or the site_id field to specify the site associated with this placement group. This is a required field that is read-only after insertion.
5569    #[serde(rename = "directorySiteId")]
5570    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5571    pub directory_site_id: Option<i64>,
5572    /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field.
5573    #[serde(rename = "directorySiteIdDimensionValue")]
5574    pub directory_site_id_dimension_value: Option<DimensionValue>,
5575    /// External ID for this placement.
5576    #[serde(rename = "externalId")]
5577    pub external_id: Option<String>,
5578    /// ID of this placement group. This is a read-only, auto-generated field.
5579    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5580    pub id: Option<i64>,
5581    /// Dimension value for the ID of this placement group. This is a read-only, auto-generated field.
5582    #[serde(rename = "idDimensionValue")]
5583    pub id_dimension_value: Option<DimensionValue>,
5584    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroup".
5585    pub kind: Option<String>,
5586    /// Information about the most recent modification of this placement group. This is a read-only field.
5587    #[serde(rename = "lastModifiedInfo")]
5588    pub last_modified_info: Option<LastModifiedInfo>,
5589    /// Name of this placement group. This is a required field and must be less than 256 characters long.
5590    pub name: Option<String>,
5591    /// Type of this placement group. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting. This field is required on insertion.
5592    #[serde(rename = "placementGroupType")]
5593    pub placement_group_type: Option<String>,
5594    /// ID of the placement strategy assigned to this placement group.
5595    #[serde(rename = "placementStrategyId")]
5596    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5597    pub placement_strategy_id: Option<i64>,
5598    /// Pricing schedule of this placement group. This field is required on insertion.
5599    #[serde(rename = "pricingSchedule")]
5600    pub pricing_schedule: Option<PricingSchedule>,
5601    /// ID of the primary placement, used to calculate the media cost of a roadblock (placement group). Modifying this field will automatically modify the primary field on all affected roadblock child placements.
5602    #[serde(rename = "primaryPlacementId")]
5603    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5604    pub primary_placement_id: Option<i64>,
5605    /// Dimension value for the ID of the primary placement. This is a read-only, auto-generated field.
5606    #[serde(rename = "primaryPlacementIdDimensionValue")]
5607    pub primary_placement_id_dimension_value: Option<DimensionValue>,
5608    /// Site ID associated with this placement group. On insert, you must set either this field or the directorySiteId field to specify the site associated with this placement group. This is a required field that is read-only after insertion.
5609    #[serde(rename = "siteId")]
5610    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5611    pub site_id: Option<i64>,
5612    /// Dimension value for the ID of the site. This is a read-only, auto-generated field.
5613    #[serde(rename = "siteIdDimensionValue")]
5614    pub site_id_dimension_value: Option<DimensionValue>,
5615    /// Subaccount ID of this placement group. This is a read-only field that can be left blank.
5616    #[serde(rename = "subaccountId")]
5617    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5618    pub subaccount_id: Option<i64>,
5619}
5620
5621impl common::RequestValue for PlacementGroup {}
5622impl common::Resource for PlacementGroup {}
5623impl common::ResponseResult for PlacementGroup {}
5624
5625/// Placement Group List Response
5626///
5627/// # Activities
5628///
5629/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5630/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5631///
5632/// * [list placement groups](PlacementGroupListCall) (response)
5633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5634#[serde_with::serde_as]
5635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5636pub struct PlacementGroupsListResponse {
5637    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse".
5638    pub kind: Option<String>,
5639    /// Pagination token to be used for the next list operation.
5640    #[serde(rename = "nextPageToken")]
5641    pub next_page_token: Option<String>,
5642    /// Placement group collection.
5643    #[serde(rename = "placementGroups")]
5644    pub placement_groups: Option<Vec<PlacementGroup>>,
5645}
5646
5647impl common::ResponseResult for PlacementGroupsListResponse {}
5648
5649/// Placement Strategy List Response
5650///
5651/// # Activities
5652///
5653/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5654/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5655///
5656/// * [list placement strategies](PlacementStrategyListCall) (response)
5657#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5658#[serde_with::serde_as]
5659#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5660pub struct PlacementStrategiesListResponse {
5661    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategiesListResponse".
5662    pub kind: Option<String>,
5663    /// Pagination token to be used for the next list operation.
5664    #[serde(rename = "nextPageToken")]
5665    pub next_page_token: Option<String>,
5666    /// Placement strategy collection.
5667    #[serde(rename = "placementStrategies")]
5668    pub placement_strategies: Option<Vec<PlacementStrategy>>,
5669}
5670
5671impl common::ResponseResult for PlacementStrategiesListResponse {}
5672
5673/// Contains properties of a placement strategy.
5674///
5675/// # Activities
5676///
5677/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5678/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5679///
5680/// * [get placement strategies](PlacementStrategyGetCall) (response)
5681/// * [insert placement strategies](PlacementStrategyInsertCall) (request|response)
5682/// * [patch placement strategies](PlacementStrategyPatchCall) (request|response)
5683/// * [update placement strategies](PlacementStrategyUpdateCall) (request|response)
5684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5685#[serde_with::serde_as]
5686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5687pub struct PlacementStrategy {
5688    /// Account ID of this placement strategy.This is a read-only field that can be left blank.
5689    #[serde(rename = "accountId")]
5690    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5691    pub account_id: Option<i64>,
5692    /// ID of this placement strategy. This is a read-only, auto-generated field.
5693    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5694    pub id: Option<i64>,
5695    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy".
5696    pub kind: Option<String>,
5697    /// Name of this placement strategy. This is a required field. It must be less than 256 characters long and unique among placement strategies of the same account.
5698    pub name: Option<String>,
5699}
5700
5701impl common::RequestValue for PlacementStrategy {}
5702impl common::ResponseResult for PlacementStrategy {}
5703
5704/// Placement Tag
5705///
5706/// This type is not used in any activity, and only used as *part* of another schema.
5707///
5708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5709#[serde_with::serde_as]
5710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5711pub struct PlacementTag {
5712    /// Placement ID
5713    #[serde(rename = "placementId")]
5714    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5715    pub placement_id: Option<i64>,
5716    /// Tags generated for this placement.
5717    #[serde(rename = "tagDatas")]
5718    pub tag_datas: Option<Vec<TagData>>,
5719}
5720
5721impl common::Part for PlacementTag {}
5722
5723/// Placement GenerateTags Response
5724///
5725/// # Activities
5726///
5727/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5728/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5729///
5730/// * [generatetags placements](PlacementGeneratetagCall) (response)
5731#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5732#[serde_with::serde_as]
5733#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5734pub struct PlacementsGenerateTagsResponse {
5735    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsGenerateTagsResponse".
5736    pub kind: Option<String>,
5737    /// Set of generated tags for the specified placements.
5738    #[serde(rename = "placementTags")]
5739    pub placement_tags: Option<Vec<PlacementTag>>,
5740}
5741
5742impl common::ResponseResult for PlacementsGenerateTagsResponse {}
5743
5744/// Placement List Response
5745///
5746/// # Activities
5747///
5748/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5749/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5750///
5751/// * [list placements](PlacementListCall) (response)
5752#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5753#[serde_with::serde_as]
5754#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5755pub struct PlacementsListResponse {
5756    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsListResponse".
5757    pub kind: Option<String>,
5758    /// Pagination token to be used for the next list operation.
5759    #[serde(rename = "nextPageToken")]
5760    pub next_page_token: Option<String>,
5761    /// Placement collection.
5762    pub placements: Option<Vec<Placement>>,
5763}
5764
5765impl common::ResponseResult for PlacementsListResponse {}
5766
5767/// Contains information about a platform type that can be targeted by ads.
5768///
5769/// # Activities
5770///
5771/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5772/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5773///
5774/// * [get platform types](PlatformTypeGetCall) (response)
5775/// * [list platform types](PlatformTypeListCall) (none)
5776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5777#[serde_with::serde_as]
5778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5779pub struct PlatformType {
5780    /// ID of this platform type.
5781    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5782    pub id: Option<i64>,
5783    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformType".
5784    pub kind: Option<String>,
5785    /// Name of this platform type.
5786    pub name: Option<String>,
5787}
5788
5789impl common::Resource for PlatformType {}
5790impl common::ResponseResult for PlatformType {}
5791
5792/// Platform Type List Response
5793///
5794/// # Activities
5795///
5796/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5797/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5798///
5799/// * [list platform types](PlatformTypeListCall) (response)
5800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5801#[serde_with::serde_as]
5802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5803pub struct PlatformTypesListResponse {
5804    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformTypesListResponse".
5805    pub kind: Option<String>,
5806    /// Platform type collection.
5807    #[serde(rename = "platformTypes")]
5808    pub platform_types: Option<Vec<PlatformType>>,
5809}
5810
5811impl common::ResponseResult for PlatformTypesListResponse {}
5812
5813/// Popup Window Properties.
5814///
5815/// This type is not used in any activity, and only used as *part* of another schema.
5816///
5817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5818#[serde_with::serde_as]
5819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5820pub struct PopupWindowProperties {
5821    /// Popup dimension for a creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID
5822    pub dimension: Option<Size>,
5823    /// Upper-left corner coordinates of the popup window. Applicable if positionType is COORDINATES.
5824    pub offset: Option<OffsetPosition>,
5825    /// Popup window position either centered or at specific coordinate.
5826    #[serde(rename = "positionType")]
5827    pub position_type: Option<String>,
5828    /// Whether to display the browser address bar.
5829    #[serde(rename = "showAddressBar")]
5830    pub show_address_bar: Option<bool>,
5831    /// Whether to display the browser menu bar.
5832    #[serde(rename = "showMenuBar")]
5833    pub show_menu_bar: Option<bool>,
5834    /// Whether to display the browser scroll bar.
5835    #[serde(rename = "showScrollBar")]
5836    pub show_scroll_bar: Option<bool>,
5837    /// Whether to display the browser status bar.
5838    #[serde(rename = "showStatusBar")]
5839    pub show_status_bar: Option<bool>,
5840    /// Whether to display the browser tool bar.
5841    #[serde(rename = "showToolBar")]
5842    pub show_tool_bar: Option<bool>,
5843    /// Title of popup window.
5844    pub title: Option<String>,
5845}
5846
5847impl common::Part for PopupWindowProperties {}
5848
5849/// Contains information about a postal code that can be targeted by ads.
5850///
5851/// # Activities
5852///
5853/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5854/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5855///
5856/// * [get postal codes](PostalCodeGetCall) (response)
5857/// * [list postal codes](PostalCodeListCall) (none)
5858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5859#[serde_with::serde_as]
5860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5861pub struct PostalCode {
5862    /// Postal code. This is equivalent to the id field.
5863    pub code: Option<String>,
5864    /// Country code of the country to which this postal code belongs.
5865    #[serde(rename = "countryCode")]
5866    pub country_code: Option<String>,
5867    /// DART ID of the country to which this postal code belongs.
5868    #[serde(rename = "countryDartId")]
5869    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5870    pub country_dart_id: Option<i64>,
5871    /// ID of this postal code.
5872    pub id: Option<String>,
5873    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCode".
5874    pub kind: Option<String>,
5875}
5876
5877impl common::Resource for PostalCode {}
5878impl common::ResponseResult for PostalCode {}
5879
5880/// Postal Code List Response
5881///
5882/// # Activities
5883///
5884/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
5885/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
5886///
5887/// * [list postal codes](PostalCodeListCall) (response)
5888#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5889#[serde_with::serde_as]
5890#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5891pub struct PostalCodesListResponse {
5892    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCodesListResponse".
5893    pub kind: Option<String>,
5894    /// Postal code collection.
5895    #[serde(rename = "postalCodes")]
5896    pub postal_codes: Option<Vec<PostalCode>>,
5897}
5898
5899impl common::ResponseResult for PostalCodesListResponse {}
5900
5901/// Pricing Information
5902///
5903/// This type is not used in any activity, and only used as *part* of another schema.
5904///
5905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5906#[serde_with::serde_as]
5907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5908pub struct Pricing {
5909    /// Cap cost type of this inventory item.
5910    #[serde(rename = "capCostType")]
5911    pub cap_cost_type: Option<String>,
5912    /// End date of this inventory item.
5913    #[serde(rename = "endDate")]
5914    pub end_date: Option<chrono::NaiveDate>,
5915    /// Flights of this inventory item. A flight (a.k.a. pricing period) represents the inventory item pricing information for a specific period of time.
5916    pub flights: Option<Vec<Flight>>,
5917    /// Group type of this inventory item if it represents a placement group. Is null otherwise. There are two type of placement groups: PLANNING_PLACEMENT_GROUP_TYPE_PACKAGE is a simple group of inventory items that acts as a single pricing point for a group of tags. PLANNING_PLACEMENT_GROUP_TYPE_ROADBLOCK is a group of inventory items that not only acts as a single pricing point, but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned inventory items to be marked as primary.
5918    #[serde(rename = "groupType")]
5919    pub group_type: Option<String>,
5920    /// Pricing type of this inventory item.
5921    #[serde(rename = "pricingType")]
5922    pub pricing_type: Option<String>,
5923    /// Start date of this inventory item.
5924    #[serde(rename = "startDate")]
5925    pub start_date: Option<chrono::NaiveDate>,
5926}
5927
5928impl common::Part for Pricing {}
5929
5930/// Pricing Schedule
5931///
5932/// This type is not used in any activity, and only used as *part* of another schema.
5933///
5934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5935#[serde_with::serde_as]
5936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5937pub struct PricingSchedule {
5938    /// Placement cap cost option.
5939    #[serde(rename = "capCostOption")]
5940    pub cap_cost_option: Option<String>,
5941    /// Whether cap costs are ignored by ad serving.
5942    #[serde(rename = "disregardOverdelivery")]
5943    pub disregard_overdelivery: Option<bool>,
5944    /// Placement end date. This date must be later than, or the same day as, the placement start date, but not later than the campaign end date. If, for example, you set 6/25/2015 as both the start and end dates, the effective placement date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error. This field is required on insertion.
5945    #[serde(rename = "endDate")]
5946    pub end_date: Option<chrono::NaiveDate>,
5947    /// Whether this placement is flighted. If true, pricing periods will be computed automatically.
5948    pub flighted: Option<bool>,
5949    /// Floodlight activity ID associated with this placement. This field should be set when placement pricing type is set to PRICING_TYPE_CPA.
5950    #[serde(rename = "floodlightActivityId")]
5951    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5952    pub floodlight_activity_id: Option<i64>,
5953    /// Pricing periods for this placement.
5954    #[serde(rename = "pricingPeriods")]
5955    pub pricing_periods: Option<Vec<PricingSchedulePricingPeriod>>,
5956    /// Placement pricing type. This field is required on insertion.
5957    #[serde(rename = "pricingType")]
5958    pub pricing_type: Option<String>,
5959    /// Placement start date. This date must be later than, or the same day as, the campaign start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error. This field is required on insertion.
5960    #[serde(rename = "startDate")]
5961    pub start_date: Option<chrono::NaiveDate>,
5962    /// Testing start date of this placement. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error.
5963    #[serde(rename = "testingStartDate")]
5964    pub testing_start_date: Option<chrono::NaiveDate>,
5965}
5966
5967impl common::Part for PricingSchedule {}
5968
5969/// Pricing Period
5970///
5971/// This type is not used in any activity, and only used as *part* of another schema.
5972///
5973#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
5974#[serde_with::serde_as]
5975#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
5976pub struct PricingSchedulePricingPeriod {
5977    /// Pricing period end date. This date must be later than, or the same day as, the pricing period start date, but not later than the placement end date. The period end date can be the same date as the period start date. If, for example, you set 6/25/2015 as both the start and end dates, the effective pricing period date is just that day only, 6/25/2015. The hours, minutes, and seconds of the end date should not be set, as doing so will result in an error.
5978    #[serde(rename = "endDate")]
5979    pub end_date: Option<chrono::NaiveDate>,
5980    /// Comments for this pricing period.
5981    #[serde(rename = "pricingComment")]
5982    pub pricing_comment: Option<String>,
5983    /// Rate or cost of this pricing period in nanos (i.e., multipled by 1000000000). Acceptable values are 0 to 1000000000000000000, inclusive.
5984    #[serde(rename = "rateOrCostNanos")]
5985    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5986    pub rate_or_cost_nanos: Option<i64>,
5987    /// Pricing period start date. This date must be later than, or the same day as, the placement start date. The hours, minutes, and seconds of the start date should not be set, as doing so will result in an error.
5988    #[serde(rename = "startDate")]
5989    pub start_date: Option<chrono::NaiveDate>,
5990    /// Units of this pricing period. Acceptable values are 0 to 10000000000, inclusive.
5991    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
5992    pub units: Option<i64>,
5993}
5994
5995impl common::Part for PricingSchedulePricingPeriod {}
5996
5997/// Contains properties of a Planning project.
5998///
5999/// # Activities
6000///
6001/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6002/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6003///
6004/// * [get projects](ProjectGetCall) (response)
6005/// * [list projects](ProjectListCall) (none)
6006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6007#[serde_with::serde_as]
6008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6009pub struct Project {
6010    /// Account ID of this project.
6011    #[serde(rename = "accountId")]
6012    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6013    pub account_id: Option<i64>,
6014    /// Advertiser ID of this project.
6015    #[serde(rename = "advertiserId")]
6016    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6017    pub advertiser_id: Option<i64>,
6018    /// Audience age group of this project.
6019    #[serde(rename = "audienceAgeGroup")]
6020    pub audience_age_group: Option<String>,
6021    /// Audience gender of this project.
6022    #[serde(rename = "audienceGender")]
6023    pub audience_gender: Option<String>,
6024    /// Budget of this project in the currency specified by the current account. The value stored in this field represents only the non-fractional amount. For example, for USD, the smallest value that can be represented by this field is 1 US dollar.
6025    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6026    pub budget: Option<i64>,
6027    /// Client billing code of this project.
6028    #[serde(rename = "clientBillingCode")]
6029    pub client_billing_code: Option<String>,
6030    /// Name of the project client.
6031    #[serde(rename = "clientName")]
6032    pub client_name: Option<String>,
6033    /// End date of the project.
6034    #[serde(rename = "endDate")]
6035    pub end_date: Option<chrono::NaiveDate>,
6036    /// ID of this project. This is a read-only, auto-generated field.
6037    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6038    pub id: Option<i64>,
6039    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#project".
6040    pub kind: Option<String>,
6041    /// Information about the most recent modification of this project.
6042    #[serde(rename = "lastModifiedInfo")]
6043    pub last_modified_info: Option<LastModifiedInfo>,
6044    /// Name of this project.
6045    pub name: Option<String>,
6046    /// Overview of this project.
6047    pub overview: Option<String>,
6048    /// Start date of the project.
6049    #[serde(rename = "startDate")]
6050    pub start_date: Option<chrono::NaiveDate>,
6051    /// Subaccount ID of this project.
6052    #[serde(rename = "subaccountId")]
6053    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6054    pub subaccount_id: Option<i64>,
6055    /// Number of clicks that the advertiser is targeting.
6056    #[serde(rename = "targetClicks")]
6057    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6058    pub target_clicks: Option<i64>,
6059    /// Number of conversions that the advertiser is targeting.
6060    #[serde(rename = "targetConversions")]
6061    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6062    pub target_conversions: Option<i64>,
6063    /// CPA that the advertiser is targeting.
6064    #[serde(rename = "targetCpaNanos")]
6065    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6066    pub target_cpa_nanos: Option<i64>,
6067    /// CPC that the advertiser is targeting.
6068    #[serde(rename = "targetCpcNanos")]
6069    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6070    pub target_cpc_nanos: Option<i64>,
6071    /// vCPM from Active View that the advertiser is targeting.
6072    #[serde(rename = "targetCpmActiveViewNanos")]
6073    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6074    pub target_cpm_active_view_nanos: Option<i64>,
6075    /// CPM that the advertiser is targeting.
6076    #[serde(rename = "targetCpmNanos")]
6077    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6078    pub target_cpm_nanos: Option<i64>,
6079    /// Number of impressions that the advertiser is targeting.
6080    #[serde(rename = "targetImpressions")]
6081    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6082    pub target_impressions: Option<i64>,
6083}
6084
6085impl common::Resource for Project {}
6086impl common::ResponseResult for Project {}
6087
6088/// Project List Response
6089///
6090/// # Activities
6091///
6092/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6093/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6094///
6095/// * [list projects](ProjectListCall) (response)
6096#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6097#[serde_with::serde_as]
6098#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6099pub struct ProjectsListResponse {
6100    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#projectsListResponse".
6101    pub kind: Option<String>,
6102    /// Pagination token to be used for the next list operation.
6103    #[serde(rename = "nextPageToken")]
6104    pub next_page_token: Option<String>,
6105    /// Project collection.
6106    pub projects: Option<Vec<Project>>,
6107}
6108
6109impl common::ResponseResult for ProjectsListResponse {}
6110
6111/// Represents fields that are compatible to be selected for a report of type "REACH".
6112///
6113/// This type is not used in any activity, and only used as *part* of another schema.
6114///
6115#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6116#[serde_with::serde_as]
6117#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6118pub struct ReachReportCompatibleFields {
6119    /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report.
6120    #[serde(rename = "dimensionFilters")]
6121    pub dimension_filters: Option<Vec<Dimension>>,
6122    /// Dimensions which are compatible to be selected in the "dimensions" section of the report.
6123    pub dimensions: Option<Vec<Dimension>>,
6124    /// The kind of resource this is, in this case dfareporting#reachReportCompatibleFields.
6125    pub kind: Option<String>,
6126    /// Metrics which are compatible to be selected in the "metricNames" section of the report.
6127    pub metrics: Option<Vec<Metric>>,
6128    /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report.
6129    #[serde(rename = "pivotedActivityMetrics")]
6130    pub pivoted_activity_metrics: Option<Vec<Metric>>,
6131    /// Metrics which are compatible to be selected in the "reachByFrequencyMetricNames" section of the report.
6132    #[serde(rename = "reachByFrequencyMetrics")]
6133    pub reach_by_frequency_metrics: Option<Vec<Metric>>,
6134}
6135
6136impl common::Part for ReachReportCompatibleFields {}
6137
6138/// Represents a recipient.
6139///
6140/// This type is not used in any activity, and only used as *part* of another schema.
6141///
6142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6143#[serde_with::serde_as]
6144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6145pub struct Recipient {
6146    /// The delivery type for the recipient.
6147    #[serde(rename = "deliveryType")]
6148    pub delivery_type: Option<String>,
6149    /// The email address of the recipient.
6150    pub email: Option<String>,
6151    /// The kind of resource this is, in this case dfareporting#recipient.
6152    pub kind: Option<String>,
6153}
6154
6155impl common::Part for Recipient {}
6156
6157/// Contains information about a region that can be targeted by ads.
6158///
6159/// # Activities
6160///
6161/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6162/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6163///
6164/// * [list regions](RegionListCall) (none)
6165#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6166#[serde_with::serde_as]
6167#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6168pub struct Region {
6169    /// Country code of the country to which this region belongs.
6170    #[serde(rename = "countryCode")]
6171    pub country_code: Option<String>,
6172    /// DART ID of the country to which this region belongs.
6173    #[serde(rename = "countryDartId")]
6174    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6175    pub country_dart_id: Option<i64>,
6176    /// DART ID of this region.
6177    #[serde(rename = "dartId")]
6178    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6179    pub dart_id: Option<i64>,
6180    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#region".
6181    pub kind: Option<String>,
6182    /// Name of this region.
6183    pub name: Option<String>,
6184    /// Region code.
6185    #[serde(rename = "regionCode")]
6186    pub region_code: Option<String>,
6187}
6188
6189impl common::Resource for Region {}
6190
6191/// Region List Response
6192///
6193/// # Activities
6194///
6195/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6196/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6197///
6198/// * [list regions](RegionListCall) (response)
6199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6200#[serde_with::serde_as]
6201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6202pub struct RegionsListResponse {
6203    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#regionsListResponse".
6204    pub kind: Option<String>,
6205    /// Region collection.
6206    pub regions: Option<Vec<Region>>,
6207}
6208
6209impl common::ResponseResult for RegionsListResponse {}
6210
6211/// Contains properties of a remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource can be used to manage remarketing lists that are owned by your advertisers. To see all remarketing lists that are visible to your advertisers, including those that are shared to your advertiser or account, use the TargetableRemarketingLists resource.
6212///
6213/// # Activities
6214///
6215/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6216/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6217///
6218/// * [get remarketing lists](RemarketingListGetCall) (response)
6219/// * [insert remarketing lists](RemarketingListInsertCall) (request|response)
6220/// * [list remarketing lists](RemarketingListListCall) (none)
6221/// * [patch remarketing lists](RemarketingListPatchCall) (request|response)
6222/// * [update remarketing lists](RemarketingListUpdateCall) (request|response)
6223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6224#[serde_with::serde_as]
6225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6226pub struct RemarketingList {
6227    /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests.
6228    #[serde(rename = "accountId")]
6229    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6230    pub account_id: Option<i64>,
6231    /// Whether this remarketing list is active.
6232    pub active: Option<bool>,
6233    /// Dimension value for the advertiser ID that owns this remarketing list. This is a required field.
6234    #[serde(rename = "advertiserId")]
6235    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6236    pub advertiser_id: Option<i64>,
6237    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
6238    #[serde(rename = "advertiserIdDimensionValue")]
6239    pub advertiser_id_dimension_value: Option<DimensionValue>,
6240    /// Remarketing list description.
6241    pub description: Option<String>,
6242    /// Remarketing list ID. This is a read-only, auto-generated field.
6243    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6244    pub id: Option<i64>,
6245    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingList".
6246    pub kind: Option<String>,
6247    /// Number of days that a user should remain in the remarketing list without an impression. Acceptable values are 1 to 540, inclusive.
6248    #[serde(rename = "lifeSpan")]
6249    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6250    pub life_span: Option<i64>,
6251    /// Rule used to populate the remarketing list with users.
6252    #[serde(rename = "listPopulationRule")]
6253    pub list_population_rule: Option<ListPopulationRule>,
6254    /// Number of users currently in the list. This is a read-only field.
6255    #[serde(rename = "listSize")]
6256    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6257    pub list_size: Option<i64>,
6258    /// Product from which this remarketing list was originated.
6259    #[serde(rename = "listSource")]
6260    pub list_source: Option<String>,
6261    /// Name of the remarketing list. This is a required field. Must be no greater than 128 characters long.
6262    pub name: Option<String>,
6263    /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests.
6264    #[serde(rename = "subaccountId")]
6265    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6266    pub subaccount_id: Option<i64>,
6267}
6268
6269impl common::RequestValue for RemarketingList {}
6270impl common::Resource for RemarketingList {}
6271impl common::ResponseResult for RemarketingList {}
6272
6273/// Contains properties of a remarketing list’s sharing information. Sharing allows other accounts or advertisers to target to your remarketing lists. This resource can be used to manage remarketing list sharing to other accounts and advertisers.
6274///
6275/// # Activities
6276///
6277/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6278/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6279///
6280/// * [get remarketing list shares](RemarketingListShareGetCall) (response)
6281/// * [patch remarketing list shares](RemarketingListSharePatchCall) (request|response)
6282/// * [update remarketing list shares](RemarketingListShareUpdateCall) (request|response)
6283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6284#[serde_with::serde_as]
6285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6286pub struct RemarketingListShare {
6287    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListShare".
6288    pub kind: Option<String>,
6289    /// Remarketing list ID. This is a read-only, auto-generated field.
6290    #[serde(rename = "remarketingListId")]
6291    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6292    pub remarketing_list_id: Option<i64>,
6293    /// Accounts that the remarketing list is shared with.
6294    #[serde(rename = "sharedAccountIds")]
6295    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
6296    pub shared_account_ids: Option<Vec<i64>>,
6297    /// Advertisers that the remarketing list is shared with.
6298    #[serde(rename = "sharedAdvertiserIds")]
6299    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
6300    pub shared_advertiser_ids: Option<Vec<i64>>,
6301}
6302
6303impl common::RequestValue for RemarketingListShare {}
6304impl common::Resource for RemarketingListShare {}
6305impl common::ResponseResult for RemarketingListShare {}
6306
6307/// Remarketing list response
6308///
6309/// # Activities
6310///
6311/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6312/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6313///
6314/// * [list remarketing lists](RemarketingListListCall) (response)
6315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6316#[serde_with::serde_as]
6317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6318pub struct RemarketingListsListResponse {
6319    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListsListResponse".
6320    pub kind: Option<String>,
6321    /// Pagination token to be used for the next list operation.
6322    #[serde(rename = "nextPageToken")]
6323    pub next_page_token: Option<String>,
6324    /// Remarketing list collection.
6325    #[serde(rename = "remarketingLists")]
6326    pub remarketing_lists: Option<Vec<RemarketingList>>,
6327}
6328
6329impl common::ResponseResult for RemarketingListsListResponse {}
6330
6331/// Represents a Report resource.
6332///
6333/// # Activities
6334///
6335/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6336/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6337///
6338/// * [compatible fields query reports](ReportCompatibleFieldQueryCall) (request)
6339/// * [files get reports](ReportFileGetCall) (none)
6340/// * [files list reports](ReportFileListCall) (none)
6341/// * [delete reports](ReportDeleteCall) (none)
6342/// * [get reports](ReportGetCall) (response)
6343/// * [insert reports](ReportInsertCall) (request|response)
6344/// * [list reports](ReportListCall) (none)
6345/// * [patch reports](ReportPatchCall) (request|response)
6346/// * [run reports](ReportRunCall) (none)
6347/// * [update reports](ReportUpdateCall) (request|response)
6348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6349#[serde_with::serde_as]
6350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6351pub struct Report {
6352    /// The account ID to which this report belongs.
6353    #[serde(rename = "accountId")]
6354    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6355    pub account_id: Option<i64>,
6356    /// The report criteria for a report of type "STANDARD".
6357    pub criteria: Option<ReportCriteria>,
6358    /// The report criteria for a report of type "CROSS_DIMENSION_REACH".
6359    #[serde(rename = "crossDimensionReachCriteria")]
6360    pub cross_dimension_reach_criteria: Option<ReportCrossDimensionReachCriteria>,
6361    /// The report's email delivery settings.
6362    pub delivery: Option<ReportDelivery>,
6363    /// The eTag of this response for caching purposes.
6364    pub etag: Option<String>,
6365    /// The filename used when generating report files for this report.
6366    #[serde(rename = "fileName")]
6367    pub file_name: Option<String>,
6368    /// The report criteria for a report of type "FLOODLIGHT".
6369    #[serde(rename = "floodlightCriteria")]
6370    pub floodlight_criteria: Option<ReportFloodlightCriteria>,
6371    /// The output format of the report. If not specified, default format is "CSV". Note that the actual format in the completed report file might differ if for instance the report's size exceeds the format's capabilities. "CSV" will then be the fallback format.
6372    pub format: Option<String>,
6373    /// The unique ID identifying this report resource.
6374    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6375    pub id: Option<i64>,
6376    /// The kind of resource this is, in this case dfareporting#report.
6377    pub kind: Option<String>,
6378    /// The timestamp (in milliseconds since epoch) of when this report was last modified.
6379    #[serde(rename = "lastModifiedTime")]
6380    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6381    pub last_modified_time: Option<u64>,
6382    /// The name of the report.
6383    pub name: Option<String>,
6384    /// The user profile id of the owner of this report.
6385    #[serde(rename = "ownerProfileId")]
6386    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6387    pub owner_profile_id: Option<i64>,
6388    /// The report criteria for a report of type "PATH_TO_CONVERSION".
6389    #[serde(rename = "pathToConversionCriteria")]
6390    pub path_to_conversion_criteria: Option<ReportPathToConversionCriteria>,
6391    /// The report criteria for a report of type "REACH".
6392    #[serde(rename = "reachCriteria")]
6393    pub reach_criteria: Option<ReportReachCriteria>,
6394    /// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY".
6395    pub schedule: Option<ReportSchedule>,
6396    /// The subaccount ID to which this report belongs if applicable.
6397    #[serde(rename = "subAccountId")]
6398    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6399    pub sub_account_id: Option<i64>,
6400    /// The type of the report.
6401    #[serde(rename = "type")]
6402    pub type_: Option<String>,
6403}
6404
6405impl common::RequestValue for Report {}
6406impl common::Resource for Report {}
6407impl common::ResponseResult for Report {}
6408
6409/// Represents fields that are compatible to be selected for a report of type "STANDARD".
6410///
6411/// This type is not used in any activity, and only used as *part* of another schema.
6412///
6413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6414#[serde_with::serde_as]
6415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6416pub struct ReportCompatibleFields {
6417    /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report.
6418    #[serde(rename = "dimensionFilters")]
6419    pub dimension_filters: Option<Vec<Dimension>>,
6420    /// Dimensions which are compatible to be selected in the "dimensions" section of the report.
6421    pub dimensions: Option<Vec<Dimension>>,
6422    /// The kind of resource this is, in this case dfareporting#reportCompatibleFields.
6423    pub kind: Option<String>,
6424    /// Metrics which are compatible to be selected in the "metricNames" section of the report.
6425    pub metrics: Option<Vec<Metric>>,
6426    /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report.
6427    #[serde(rename = "pivotedActivityMetrics")]
6428    pub pivoted_activity_metrics: Option<Vec<Metric>>,
6429}
6430
6431impl common::Part for ReportCompatibleFields {}
6432
6433/// Represents the list of reports.
6434///
6435/// # Activities
6436///
6437/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6438/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6439///
6440/// * [list reports](ReportListCall) (response)
6441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6442#[serde_with::serde_as]
6443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6444pub struct ReportList {
6445    /// The eTag of this response for caching purposes.
6446    pub etag: Option<String>,
6447    /// The reports returned in this response.
6448    pub items: Option<Vec<Report>>,
6449    /// The kind of list this is, in this case dfareporting#reportList.
6450    pub kind: Option<String>,
6451    /// Continuation token used to page through reports. To retrieve the next page of results, set the next request's "pageToken" to the value of this field. The page token is only valid for a limited amount of time and should not be persisted.
6452    #[serde(rename = "nextPageToken")]
6453    pub next_page_token: Option<String>,
6454}
6455
6456impl common::ResponseResult for ReportList {}
6457
6458/// Reporting Configuration
6459///
6460/// This type is not used in any activity, and only used as *part* of another schema.
6461///
6462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6463#[serde_with::serde_as]
6464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6465pub struct ReportsConfiguration {
6466    /// Whether the exposure to conversion report is enabled. This report shows detailed pathway information on up to 10 of the most recent ad exposures seen by a user before converting.
6467    #[serde(rename = "exposureToConversionEnabled")]
6468    pub exposure_to_conversion_enabled: Option<bool>,
6469    /// Default lookback windows for new advertisers in this account.
6470    #[serde(rename = "lookbackConfiguration")]
6471    pub lookback_configuration: Option<LookbackConfiguration>,
6472    /// Report generation time zone ID of this account. This is a required field that can only be changed by a superuser.
6473    /// Acceptable values are:
6474    ///
6475    /// - "1" for "America/New_York"
6476    /// - "2" for "Europe/London"
6477    /// - "3" for "Europe/Paris"
6478    /// - "4" for "Africa/Johannesburg"
6479    /// - "5" for "Asia/Jerusalem"
6480    /// - "6" for "Asia/Shanghai"
6481    /// - "7" for "Asia/Hong_Kong"
6482    /// - "8" for "Asia/Tokyo"
6483    /// - "9" for "Australia/Sydney"
6484    /// - "10" for "Asia/Dubai"
6485    /// - "11" for "America/Los_Angeles"
6486    /// - "12" for "Pacific/Auckland"
6487    /// - "13" for "America/Sao_Paulo"
6488    #[serde(rename = "reportGenerationTimeZoneId")]
6489    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6490    pub report_generation_time_zone_id: Option<i64>,
6491}
6492
6493impl common::Part for ReportsConfiguration {}
6494
6495/// Rich Media Exit Override.
6496///
6497/// This type is not used in any activity, and only used as *part* of another schema.
6498///
6499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6500#[serde_with::serde_as]
6501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6502pub struct RichMediaExitOverride {
6503    /// Click-through URL of this rich media exit override. Applicable if the enabled field is set to true.
6504    #[serde(rename = "clickThroughUrl")]
6505    pub click_through_url: Option<ClickThroughUrl>,
6506    /// Whether to use the clickThroughUrl. If false, the creative-level exit will be used.
6507    pub enabled: Option<bool>,
6508    /// ID for the override to refer to a specific exit in the creative.
6509    #[serde(rename = "exitId")]
6510    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6511    pub exit_id: Option<i64>,
6512}
6513
6514impl common::Part for RichMediaExitOverride {}
6515
6516/// A rule associates an asset with a targeting template for asset-level targeting. Applicable to INSTREAM_VIDEO creatives.
6517///
6518/// This type is not used in any activity, and only used as *part* of another schema.
6519///
6520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6521#[serde_with::serde_as]
6522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6523pub struct Rule {
6524    /// A creativeAssets[].id. This should refer to one of the parent assets in this creative. This is a required field.
6525    #[serde(rename = "assetId")]
6526    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6527    pub asset_id: Option<i64>,
6528    /// A user-friendly name for this rule. This is a required field.
6529    pub name: Option<String>,
6530    /// A targeting template ID. The targeting from the targeting template will be used to determine whether this asset should be served. This is a required field.
6531    #[serde(rename = "targetingTemplateId")]
6532    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6533    pub targeting_template_id: Option<i64>,
6534}
6535
6536impl common::Part for Rule {}
6537
6538/// Contains properties of a site.
6539///
6540/// # Activities
6541///
6542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6544///
6545/// * [get sites](SiteGetCall) (response)
6546/// * [insert sites](SiteInsertCall) (request|response)
6547/// * [list sites](SiteListCall) (none)
6548/// * [patch sites](SitePatchCall) (request|response)
6549/// * [update sites](SiteUpdateCall) (request|response)
6550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6551#[serde_with::serde_as]
6552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6553pub struct Site {
6554    /// Account ID of this site. This is a read-only field that can be left blank.
6555    #[serde(rename = "accountId")]
6556    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6557    pub account_id: Option<i64>,
6558    /// Whether this site is approved.
6559    pub approved: Option<bool>,
6560    /// Directory site associated with this site. This is a required field that is read-only after insertion.
6561    #[serde(rename = "directorySiteId")]
6562    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6563    pub directory_site_id: Option<i64>,
6564    /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field.
6565    #[serde(rename = "directorySiteIdDimensionValue")]
6566    pub directory_site_id_dimension_value: Option<DimensionValue>,
6567    /// ID of this site. This is a read-only, auto-generated field.
6568    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6569    pub id: Option<i64>,
6570    /// Dimension value for the ID of this site. This is a read-only, auto-generated field.
6571    #[serde(rename = "idDimensionValue")]
6572    pub id_dimension_value: Option<DimensionValue>,
6573    /// Key name of this site. This is a read-only, auto-generated field.
6574    #[serde(rename = "keyName")]
6575    pub key_name: Option<String>,
6576    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#site".
6577    pub kind: Option<String>,
6578    /// Name of this site.This is a required field. Must be less than 128 characters long. If this site is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this site is a top-level site, and the name must be unique among top-level sites of the same account.
6579    pub name: Option<String>,
6580    /// Site contacts.
6581    #[serde(rename = "siteContacts")]
6582    pub site_contacts: Option<Vec<SiteContact>>,
6583    /// Site-wide settings.
6584    #[serde(rename = "siteSettings")]
6585    pub site_settings: Option<SiteSettings>,
6586    /// Subaccount ID of this site. This is a read-only field that can be left blank.
6587    #[serde(rename = "subaccountId")]
6588    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6589    pub subaccount_id: Option<i64>,
6590}
6591
6592impl common::RequestValue for Site {}
6593impl common::Resource for Site {}
6594impl common::ResponseResult for Site {}
6595
6596/// Site Contact
6597///
6598/// This type is not used in any activity, and only used as *part* of another schema.
6599///
6600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6601#[serde_with::serde_as]
6602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6603pub struct SiteContact {
6604    /// Address of this site contact.
6605    pub address: Option<String>,
6606    /// Site contact type.
6607    #[serde(rename = "contactType")]
6608    pub contact_type: Option<String>,
6609    /// Email address of this site contact. This is a required field.
6610    pub email: Option<String>,
6611    /// First name of this site contact.
6612    #[serde(rename = "firstName")]
6613    pub first_name: Option<String>,
6614    /// ID of this site contact. This is a read-only, auto-generated field.
6615    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6616    pub id: Option<i64>,
6617    /// Last name of this site contact.
6618    #[serde(rename = "lastName")]
6619    pub last_name: Option<String>,
6620    /// Primary phone number of this site contact.
6621    pub phone: Option<String>,
6622    /// Title or designation of this site contact.
6623    pub title: Option<String>,
6624}
6625
6626impl common::Part for SiteContact {}
6627
6628/// Site Settings
6629///
6630/// This type is not used in any activity, and only used as *part* of another schema.
6631///
6632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6633#[serde_with::serde_as]
6634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6635pub struct SiteSettings {
6636    /// Whether active view creatives are disabled for this site.
6637    #[serde(rename = "activeViewOptOut")]
6638    pub active_view_opt_out: Option<bool>,
6639    /// Whether this site opts out of ad blocking. When true, ad blocking is disabled for all placements under the site, regardless of the individual placement settings. When false, the campaign and placement settings take effect.
6640    #[serde(rename = "adBlockingOptOut")]
6641    pub ad_blocking_opt_out: Option<bool>,
6642    /// Site-wide creative settings.
6643    #[serde(rename = "creativeSettings")]
6644    pub creative_settings: Option<CreativeSettings>,
6645    /// Whether new cookies are disabled for this site.
6646    #[serde(rename = "disableNewCookie")]
6647    pub disable_new_cookie: Option<bool>,
6648    /// Lookback window settings for this site.
6649    #[serde(rename = "lookbackConfiguration")]
6650    pub lookback_configuration: Option<LookbackConfiguration>,
6651    /// Configuration settings for dynamic and image floodlight tags.
6652    #[serde(rename = "tagSetting")]
6653    pub tag_setting: Option<TagSetting>,
6654    /// Whether Verification and ActiveView for in-stream video creatives are disabled by default for new placements created under this site. This value will be used to populate the placement.videoActiveViewOptOut field, when no value is specified for the new placement.
6655    #[serde(rename = "videoActiveViewOptOutTemplate")]
6656    pub video_active_view_opt_out_template: Option<bool>,
6657    /// Default VPAID adapter setting for new placements created under this site. This value will be used to populate the placements.vpaidAdapterChoice field, when no value is specified for the new placement. Controls which VPAID format the measurement adapter will use for in-stream video creatives assigned to the placement. The publisher's specifications will typically determine this setting. For VPAID creatives, the adapter format will match the VPAID format (HTML5 VPAID creatives use the HTML5 adapter).
6658    ///
6659    /// Note: Flash is no longer supported. This field now defaults to HTML5 when the following values are provided: FLASH, BOTH.
6660    #[serde(rename = "vpaidAdapterChoiceTemplate")]
6661    pub vpaid_adapter_choice_template: Option<String>,
6662}
6663
6664impl common::Part for SiteSettings {}
6665
6666/// Site List Response
6667///
6668/// # Activities
6669///
6670/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6671/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6672///
6673/// * [list sites](SiteListCall) (response)
6674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6675#[serde_with::serde_as]
6676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6677pub struct SitesListResponse {
6678    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sitesListResponse".
6679    pub kind: Option<String>,
6680    /// Pagination token to be used for the next list operation.
6681    #[serde(rename = "nextPageToken")]
6682    pub next_page_token: Option<String>,
6683    /// Site collection.
6684    pub sites: Option<Vec<Site>>,
6685}
6686
6687impl common::ResponseResult for SitesListResponse {}
6688
6689/// Represents the dimensions of ads, placements, creatives, or creative assets.
6690///
6691/// # Activities
6692///
6693/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6694/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6695///
6696/// * [get sizes](SizeGetCall) (response)
6697/// * [insert sizes](SizeInsertCall) (request|response)
6698/// * [list sizes](SizeListCall) (none)
6699#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6700#[serde_with::serde_as]
6701#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6702pub struct Size {
6703    /// Height of this size. Acceptable values are 0 to 32767, inclusive.
6704    pub height: Option<i32>,
6705    /// IAB standard size. This is a read-only, auto-generated field.
6706    pub iab: Option<bool>,
6707    /// ID of this size. This is a read-only, auto-generated field.
6708    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6709    pub id: Option<i64>,
6710    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#size".
6711    pub kind: Option<String>,
6712    /// Width of this size. Acceptable values are 0 to 32767, inclusive.
6713    pub width: Option<i32>,
6714}
6715
6716impl common::RequestValue for Size {}
6717impl common::Resource for Size {}
6718impl common::ResponseResult for Size {}
6719
6720/// Size List Response
6721///
6722/// # Activities
6723///
6724/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6725/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6726///
6727/// * [list sizes](SizeListCall) (response)
6728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6729#[serde_with::serde_as]
6730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6731pub struct SizesListResponse {
6732    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sizesListResponse".
6733    pub kind: Option<String>,
6734    /// Size collection.
6735    pub sizes: Option<Vec<Size>>,
6736}
6737
6738impl common::ResponseResult for SizesListResponse {}
6739
6740/// Skippable Settings
6741///
6742/// This type is not used in any activity, and only used as *part* of another schema.
6743///
6744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6745#[serde_with::serde_as]
6746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6747pub struct SkippableSetting {
6748    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#skippableSetting".
6749    pub kind: Option<String>,
6750    /// Amount of time to play videos served to this placement before counting a view. Applicable when skippable is true.
6751    #[serde(rename = "progressOffset")]
6752    pub progress_offset: Option<VideoOffset>,
6753    /// Amount of time to play videos served to this placement before the skip button should appear. Applicable when skippable is true.
6754    #[serde(rename = "skipOffset")]
6755    pub skip_offset: Option<VideoOffset>,
6756    /// Whether the user can skip creatives served to this placement.
6757    pub skippable: Option<bool>,
6758}
6759
6760impl common::Part for SkippableSetting {}
6761
6762/// Represents a sorted dimension.
6763///
6764/// This type is not used in any activity, and only used as *part* of another schema.
6765///
6766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6767#[serde_with::serde_as]
6768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6769pub struct SortedDimension {
6770    /// The kind of resource this is, in this case dfareporting#sortedDimension.
6771    pub kind: Option<String>,
6772    /// The name of the dimension.
6773    pub name: Option<String>,
6774    /// An optional sort order for the dimension column.
6775    #[serde(rename = "sortOrder")]
6776    pub sort_order: Option<String>,
6777}
6778
6779impl common::Part for SortedDimension {}
6780
6781/// Contains properties of a Campaign Manager subaccount.
6782///
6783/// # Activities
6784///
6785/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6786/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6787///
6788/// * [get subaccounts](SubaccountGetCall) (response)
6789/// * [insert subaccounts](SubaccountInsertCall) (request|response)
6790/// * [list subaccounts](SubaccountListCall) (none)
6791/// * [patch subaccounts](SubaccountPatchCall) (request|response)
6792/// * [update subaccounts](SubaccountUpdateCall) (request|response)
6793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6794#[serde_with::serde_as]
6795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6796pub struct Subaccount {
6797    /// ID of the account that contains this subaccount. This is a read-only field that can be left blank.
6798    #[serde(rename = "accountId")]
6799    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6800    pub account_id: Option<i64>,
6801    /// IDs of the available user role permissions for this subaccount.
6802    #[serde(rename = "availablePermissionIds")]
6803    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
6804    pub available_permission_ids: Option<Vec<i64>>,
6805    /// ID of this subaccount. This is a read-only, auto-generated field.
6806    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6807    pub id: Option<i64>,
6808    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccount".
6809    pub kind: Option<String>,
6810    /// Name of this subaccount. This is a required field. Must be less than 128 characters long and be unique among subaccounts of the same account.
6811    pub name: Option<String>,
6812}
6813
6814impl common::RequestValue for Subaccount {}
6815impl common::Resource for Subaccount {}
6816impl common::ResponseResult for Subaccount {}
6817
6818/// Subaccount List Response
6819///
6820/// # Activities
6821///
6822/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6823/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6824///
6825/// * [list subaccounts](SubaccountListCall) (response)
6826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6827#[serde_with::serde_as]
6828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6829pub struct SubaccountsListResponse {
6830    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccountsListResponse".
6831    pub kind: Option<String>,
6832    /// Pagination token to be used for the next list operation.
6833    #[serde(rename = "nextPageToken")]
6834    pub next_page_token: Option<String>,
6835    /// Subaccount collection.
6836    pub subaccounts: Option<Vec<Subaccount>>,
6837}
6838
6839impl common::ResponseResult for SubaccountsListResponse {}
6840
6841/// Placement Tag Data
6842///
6843/// This type is not used in any activity, and only used as *part* of another schema.
6844///
6845#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6846#[serde_with::serde_as]
6847#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6848pub struct TagData {
6849    /// Ad associated with this placement tag. Applicable only when format is PLACEMENT_TAG_TRACKING.
6850    #[serde(rename = "adId")]
6851    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6852    pub ad_id: Option<i64>,
6853    /// Tag string to record a click.
6854    #[serde(rename = "clickTag")]
6855    pub click_tag: Option<String>,
6856    /// Creative associated with this placement tag. Applicable only when format is PLACEMENT_TAG_TRACKING.
6857    #[serde(rename = "creativeId")]
6858    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6859    pub creative_id: Option<i64>,
6860    /// TagData tag format of this tag.
6861    pub format: Option<String>,
6862    /// Tag string for serving an ad.
6863    #[serde(rename = "impressionTag")]
6864    pub impression_tag: Option<String>,
6865}
6866
6867impl common::Part for TagData {}
6868
6869/// Tag Settings
6870///
6871/// This type is not used in any activity, and only used as *part* of another schema.
6872///
6873#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6874#[serde_with::serde_as]
6875#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6876pub struct TagSetting {
6877    /// Additional key-values to be included in tags. Each key-value pair must be of the form key=value, and pairs must be separated by a semicolon (;). Keys and values must not contain commas. For example, id=2;color=red is a valid value for this field.
6878    #[serde(rename = "additionalKeyValues")]
6879    pub additional_key_values: Option<String>,
6880    /// Whether static landing page URLs should be included in the tags. This setting applies only to placements.
6881    #[serde(rename = "includeClickThroughUrls")]
6882    pub include_click_through_urls: Option<bool>,
6883    /// Whether click-tracking string should be included in the tags.
6884    #[serde(rename = "includeClickTracking")]
6885    pub include_click_tracking: Option<bool>,
6886    /// Option specifying how keywords are embedded in ad tags. This setting can be used to specify whether keyword placeholders are inserted in placement tags for this site. Publishers can then add keywords to those placeholders.
6887    #[serde(rename = "keywordOption")]
6888    pub keyword_option: Option<String>,
6889}
6890
6891impl common::Part for TagSetting {}
6892
6893/// Dynamic and Image Tag Settings.
6894///
6895/// This type is not used in any activity, and only used as *part* of another schema.
6896///
6897#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6898#[serde_with::serde_as]
6899#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6900pub struct TagSettings {
6901    /// Whether dynamic floodlight tags are enabled.
6902    #[serde(rename = "dynamicTagEnabled")]
6903    pub dynamic_tag_enabled: Option<bool>,
6904    /// Whether image tags are enabled.
6905    #[serde(rename = "imageTagEnabled")]
6906    pub image_tag_enabled: Option<bool>,
6907}
6908
6909impl common::Part for TagSettings {}
6910
6911/// Target Window.
6912///
6913/// This type is not used in any activity, and only used as *part* of another schema.
6914///
6915#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6916#[serde_with::serde_as]
6917#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6918pub struct TargetWindow {
6919    /// User-entered value.
6920    #[serde(rename = "customHtml")]
6921    pub custom_html: Option<String>,
6922    /// Type of browser window for which the backup image of the flash creative can be displayed.
6923    #[serde(rename = "targetWindowOption")]
6924    pub target_window_option: Option<String>,
6925}
6926
6927impl common::Part for TargetWindow {}
6928
6929/// Contains properties of a targetable remarketing list. Remarketing enables you to create lists of users who have performed specific actions on a site, then target ads to members of those lists. This resource is a read-only view of a remarketing list to be used to faciliate targeting ads to specific lists. Remarketing lists that are owned by your advertisers and those that are shared to your advertisers or account are accessible via this resource. To manage remarketing lists that are owned by your advertisers, use the RemarketingLists resource.
6930///
6931/// # Activities
6932///
6933/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6934/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6935///
6936/// * [get targetable remarketing lists](TargetableRemarketingListGetCall) (response)
6937/// * [list targetable remarketing lists](TargetableRemarketingListListCall) (none)
6938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6939#[serde_with::serde_as]
6940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6941pub struct TargetableRemarketingList {
6942    /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests.
6943    #[serde(rename = "accountId")]
6944    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6945    pub account_id: Option<i64>,
6946    /// Whether this targetable remarketing list is active.
6947    pub active: Option<bool>,
6948    /// Dimension value for the advertiser ID that owns this targetable remarketing list.
6949    #[serde(rename = "advertiserId")]
6950    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6951    pub advertiser_id: Option<i64>,
6952    /// Dimension value for the ID of the advertiser.
6953    #[serde(rename = "advertiserIdDimensionValue")]
6954    pub advertiser_id_dimension_value: Option<DimensionValue>,
6955    /// Targetable remarketing list description.
6956    pub description: Option<String>,
6957    /// Targetable remarketing list ID.
6958    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6959    pub id: Option<i64>,
6960    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingList".
6961    pub kind: Option<String>,
6962    /// Number of days that a user should remain in the targetable remarketing list without an impression.
6963    #[serde(rename = "lifeSpan")]
6964    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6965    pub life_span: Option<i64>,
6966    /// Number of users currently in the list. This is a read-only field.
6967    #[serde(rename = "listSize")]
6968    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6969    pub list_size: Option<i64>,
6970    /// Product from which this targetable remarketing list was originated.
6971    #[serde(rename = "listSource")]
6972    pub list_source: Option<String>,
6973    /// Name of the targetable remarketing list. Is no greater than 128 characters long.
6974    pub name: Option<String>,
6975    /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests.
6976    #[serde(rename = "subaccountId")]
6977    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
6978    pub subaccount_id: Option<i64>,
6979}
6980
6981impl common::Resource for TargetableRemarketingList {}
6982impl common::ResponseResult for TargetableRemarketingList {}
6983
6984/// Targetable remarketing list response
6985///
6986/// # Activities
6987///
6988/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
6989/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
6990///
6991/// * [list targetable remarketing lists](TargetableRemarketingListListCall) (response)
6992#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
6993#[serde_with::serde_as]
6994#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
6995pub struct TargetableRemarketingListsListResponse {
6996    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingListsListResponse".
6997    pub kind: Option<String>,
6998    /// Pagination token to be used for the next list operation.
6999    #[serde(rename = "nextPageToken")]
7000    pub next_page_token: Option<String>,
7001    /// Targetable remarketing list collection.
7002    #[serde(rename = "targetableRemarketingLists")]
7003    pub targetable_remarketing_lists: Option<Vec<TargetableRemarketingList>>,
7004}
7005
7006impl common::ResponseResult for TargetableRemarketingListsListResponse {}
7007
7008/// Contains properties of a targeting template. A targeting template encapsulates targeting information which can be reused across multiple ads.
7009///
7010/// # Activities
7011///
7012/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7013/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7014///
7015/// * [get targeting templates](TargetingTemplateGetCall) (response)
7016/// * [insert targeting templates](TargetingTemplateInsertCall) (request|response)
7017/// * [list targeting templates](TargetingTemplateListCall) (none)
7018/// * [patch targeting templates](TargetingTemplatePatchCall) (request|response)
7019/// * [update targeting templates](TargetingTemplateUpdateCall) (request|response)
7020#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7021#[serde_with::serde_as]
7022#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7023pub struct TargetingTemplate {
7024    /// Account ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert.
7025    #[serde(rename = "accountId")]
7026    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7027    pub account_id: Option<i64>,
7028    /// Advertiser ID of this targeting template. This is a required field on insert and is read-only after insert.
7029    #[serde(rename = "advertiserId")]
7030    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7031    pub advertiser_id: Option<i64>,
7032    /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field.
7033    #[serde(rename = "advertiserIdDimensionValue")]
7034    pub advertiser_id_dimension_value: Option<DimensionValue>,
7035    /// Time and day targeting criteria.
7036    #[serde(rename = "dayPartTargeting")]
7037    pub day_part_targeting: Option<DayPartTargeting>,
7038    /// Geographical targeting criteria.
7039    #[serde(rename = "geoTargeting")]
7040    pub geo_targeting: Option<GeoTargeting>,
7041    /// ID of this targeting template. This is a read-only, auto-generated field.
7042    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7043    pub id: Option<i64>,
7044    /// Key-value targeting criteria.
7045    #[serde(rename = "keyValueTargetingExpression")]
7046    pub key_value_targeting_expression: Option<KeyValueTargetingExpression>,
7047    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplate".
7048    pub kind: Option<String>,
7049    /// Language targeting criteria.
7050    #[serde(rename = "languageTargeting")]
7051    pub language_targeting: Option<LanguageTargeting>,
7052    /// Remarketing list targeting criteria.
7053    #[serde(rename = "listTargetingExpression")]
7054    pub list_targeting_expression: Option<ListTargetingExpression>,
7055    /// Name of this targeting template. This field is required. It must be less than 256 characters long and unique within an advertiser.
7056    pub name: Option<String>,
7057    /// Subaccount ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert.
7058    #[serde(rename = "subaccountId")]
7059    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7060    pub subaccount_id: Option<i64>,
7061    /// Technology platform targeting criteria.
7062    #[serde(rename = "technologyTargeting")]
7063    pub technology_targeting: Option<TechnologyTargeting>,
7064}
7065
7066impl common::RequestValue for TargetingTemplate {}
7067impl common::Resource for TargetingTemplate {}
7068impl common::ResponseResult for TargetingTemplate {}
7069
7070/// Targeting Template List Response
7071///
7072/// # Activities
7073///
7074/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7075/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7076///
7077/// * [list targeting templates](TargetingTemplateListCall) (response)
7078#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7079#[serde_with::serde_as]
7080#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7081pub struct TargetingTemplatesListResponse {
7082    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplatesListResponse".
7083    pub kind: Option<String>,
7084    /// Pagination token to be used for the next list operation.
7085    #[serde(rename = "nextPageToken")]
7086    pub next_page_token: Option<String>,
7087    /// Targeting template collection.
7088    #[serde(rename = "targetingTemplates")]
7089    pub targeting_templates: Option<Vec<TargetingTemplate>>,
7090}
7091
7092impl common::ResponseResult for TargetingTemplatesListResponse {}
7093
7094/// Technology Targeting.
7095///
7096/// This type is not used in any activity, and only used as *part* of another schema.
7097///
7098#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7099#[serde_with::serde_as]
7100#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7101pub struct TechnologyTargeting {
7102    /// Browsers that this ad targets. For each browser either set browserVersionId or dartId along with the version numbers. If both are specified, only browserVersionId will be used. The other fields are populated automatically when the ad is inserted or updated.
7103    pub browsers: Option<Vec<Browser>>,
7104    /// Connection types that this ad targets. For each connection type only id is required. The other fields are populated automatically when the ad is inserted or updated.
7105    #[serde(rename = "connectionTypes")]
7106    pub connection_types: Option<Vec<ConnectionType>>,
7107    /// Mobile carriers that this ad targets. For each mobile carrier only id is required, and the other fields are populated automatically when the ad is inserted or updated. If targeting a mobile carrier, do not set targeting for any zip codes.
7108    #[serde(rename = "mobileCarriers")]
7109    pub mobile_carriers: Option<Vec<MobileCarrier>>,
7110    /// Operating system versions that this ad targets. To target all versions, use operatingSystems. For each operating system version, only id is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system version, do not set targeting for the corresponding operating system in operatingSystems.
7111    #[serde(rename = "operatingSystemVersions")]
7112    pub operating_system_versions: Option<Vec<OperatingSystemVersion>>,
7113    /// Operating systems that this ad targets. To target specific versions, use operatingSystemVersions. For each operating system only dartId is required. The other fields are populated automatically when the ad is inserted or updated. If targeting an operating system, do not set targeting for operating system versions for the same operating system.
7114    #[serde(rename = "operatingSystems")]
7115    pub operating_systems: Option<Vec<OperatingSystem>>,
7116    /// Platform types that this ad targets. For example, desktop, mobile, or tablet. For each platform type, only id is required, and the other fields are populated automatically when the ad is inserted or updated.
7117    #[serde(rename = "platformTypes")]
7118    pub platform_types: Option<Vec<PlatformType>>,
7119}
7120
7121impl common::Part for TechnologyTargeting {}
7122
7123/// Third Party Authentication Token
7124///
7125/// This type is not used in any activity, and only used as *part* of another schema.
7126///
7127#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7128#[serde_with::serde_as]
7129#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7130pub struct ThirdPartyAuthenticationToken {
7131    /// Name of the third-party authentication token.
7132    pub name: Option<String>,
7133    /// Value of the third-party authentication token. This is a read-only, auto-generated field.
7134    pub value: Option<String>,
7135}
7136
7137impl common::Part for ThirdPartyAuthenticationToken {}
7138
7139/// Third-party Tracking URL.
7140///
7141/// This type is not used in any activity, and only used as *part* of another schema.
7142///
7143#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7144#[serde_with::serde_as]
7145#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7146pub struct ThirdPartyTrackingUrl {
7147    /// Third-party URL type for in-stream video and in-stream audio creatives.
7148    #[serde(rename = "thirdPartyUrlType")]
7149    pub third_party_url_type: Option<String>,
7150    /// URL for the specified third-party URL type.
7151    pub url: Option<String>,
7152}
7153
7154impl common::Part for ThirdPartyTrackingUrl {}
7155
7156/// Transcode Settings
7157///
7158/// This type is not used in any activity, and only used as *part* of another schema.
7159///
7160#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7161#[serde_with::serde_as]
7162#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7163pub struct TranscodeSetting {
7164    /// Whitelist of video formats to be served to this placement. Set this list to null or empty to serve all video formats.
7165    #[serde(rename = "enabledVideoFormats")]
7166    pub enabled_video_formats: Option<Vec<i32>>,
7167    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#transcodeSetting".
7168    pub kind: Option<String>,
7169}
7170
7171impl common::Part for TranscodeSetting {}
7172
7173/// A Universal Ad ID as per the VAST 4.0 spec. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and VPAID.
7174///
7175/// This type is not used in any activity, and only used as *part* of another schema.
7176///
7177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7178#[serde_with::serde_as]
7179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7180pub struct UniversalAdId {
7181    /// Registry used for the Ad ID value.
7182    pub registry: Option<String>,
7183    /// ID value for this creative. Only alphanumeric characters and the following symbols are valid: "_/\-". Maximum length is 64 characters. Read only when registry is DCM.
7184    pub value: Option<String>,
7185}
7186
7187impl common::Part for UniversalAdId {}
7188
7189/// User Defined Variable configuration.
7190///
7191/// This type is not used in any activity, and only used as *part* of another schema.
7192///
7193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7194#[serde_with::serde_as]
7195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7196pub struct UserDefinedVariableConfiguration {
7197    /// Data type for the variable. This is a required field.
7198    #[serde(rename = "dataType")]
7199    pub data_type: Option<String>,
7200    /// User-friendly name for the variable which will appear in reports. This is a required field, must be less than 64 characters long, and cannot contain the following characters: ""<>".
7201    #[serde(rename = "reportName")]
7202    pub report_name: Option<String>,
7203    /// Variable name in the tag. This is a required field.
7204    #[serde(rename = "variableType")]
7205    pub variable_type: Option<String>,
7206}
7207
7208impl common::Part for UserDefinedVariableConfiguration {}
7209
7210/// Represents a UserProfile resource.
7211///
7212/// # Activities
7213///
7214/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7215/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7216///
7217/// * [get user profiles](UserProfileGetCall) (response)
7218/// * [list user profiles](UserProfileListCall) (none)
7219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7220#[serde_with::serde_as]
7221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7222pub struct UserProfile {
7223    /// The account ID to which this profile belongs.
7224    #[serde(rename = "accountId")]
7225    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7226    pub account_id: Option<i64>,
7227    /// The account name this profile belongs to.
7228    #[serde(rename = "accountName")]
7229    pub account_name: Option<String>,
7230    /// The eTag of this response for caching purposes.
7231    pub etag: Option<String>,
7232    /// The kind of resource this is, in this case dfareporting#userProfile.
7233    pub kind: Option<String>,
7234    /// The unique ID of the user profile.
7235    #[serde(rename = "profileId")]
7236    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7237    pub profile_id: Option<i64>,
7238    /// The sub account ID this profile belongs to if applicable.
7239    #[serde(rename = "subAccountId")]
7240    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7241    pub sub_account_id: Option<i64>,
7242    /// The sub account name this profile belongs to if applicable.
7243    #[serde(rename = "subAccountName")]
7244    pub sub_account_name: Option<String>,
7245    /// The user name.
7246    #[serde(rename = "userName")]
7247    pub user_name: Option<String>,
7248}
7249
7250impl common::Resource for UserProfile {}
7251impl common::ResponseResult for UserProfile {}
7252
7253/// Represents the list of user profiles.
7254///
7255/// # Activities
7256///
7257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7259///
7260/// * [list user profiles](UserProfileListCall) (response)
7261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7262#[serde_with::serde_as]
7263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7264pub struct UserProfileList {
7265    /// The eTag of this response for caching purposes.
7266    pub etag: Option<String>,
7267    /// The user profiles returned in this response.
7268    pub items: Option<Vec<UserProfile>>,
7269    /// The kind of list this is, in this case dfareporting#userProfileList.
7270    pub kind: Option<String>,
7271}
7272
7273impl common::ResponseResult for UserProfileList {}
7274
7275/// Contains properties of auser role, which is used to manage user access.
7276///
7277/// # Activities
7278///
7279/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7280/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7281///
7282/// * [delete user roles](UserRoleDeleteCall) (none)
7283/// * [get user roles](UserRoleGetCall) (response)
7284/// * [insert user roles](UserRoleInsertCall) (request|response)
7285/// * [list user roles](UserRoleListCall) (none)
7286/// * [patch user roles](UserRolePatchCall) (request|response)
7287/// * [update user roles](UserRoleUpdateCall) (request|response)
7288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7289#[serde_with::serde_as]
7290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7291pub struct UserRole {
7292    /// Account ID of this user role. This is a read-only field that can be left blank.
7293    #[serde(rename = "accountId")]
7294    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7295    pub account_id: Option<i64>,
7296    /// Whether this is a default user role. Default user roles are created by the system for the account/subaccount and cannot be modified or deleted. Each default user role comes with a basic set of preassigned permissions.
7297    #[serde(rename = "defaultUserRole")]
7298    pub default_user_role: Option<bool>,
7299    /// ID of this user role. This is a read-only, auto-generated field.
7300    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7301    pub id: Option<i64>,
7302    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRole".
7303    pub kind: Option<String>,
7304    /// Name of this user role. This is a required field. Must be less than 256 characters long. If this user role is under a subaccount, the name must be unique among sites of the same subaccount. Otherwise, this user role is a top-level user role, and the name must be unique among top-level user roles of the same account.
7305    pub name: Option<String>,
7306    /// ID of the user role that this user role is based on or copied from. This is a required field.
7307    #[serde(rename = "parentUserRoleId")]
7308    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7309    pub parent_user_role_id: Option<i64>,
7310    /// List of permissions associated with this user role.
7311    pub permissions: Option<Vec<UserRolePermission>>,
7312    /// Subaccount ID of this user role. This is a read-only field that can be left blank.
7313    #[serde(rename = "subaccountId")]
7314    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7315    pub subaccount_id: Option<i64>,
7316}
7317
7318impl common::RequestValue for UserRole {}
7319impl common::Resource for UserRole {}
7320impl common::ResponseResult for UserRole {}
7321
7322/// Contains properties of a user role permission.
7323///
7324/// # Activities
7325///
7326/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7327/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7328///
7329/// * [get user role permissions](UserRolePermissionGetCall) (response)
7330/// * [list user role permissions](UserRolePermissionListCall) (none)
7331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7332#[serde_with::serde_as]
7333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7334pub struct UserRolePermission {
7335    /// Levels of availability for a user role permission.
7336    pub availability: Option<String>,
7337    /// ID of this user role permission.
7338    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7339    pub id: Option<i64>,
7340    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermission".
7341    pub kind: Option<String>,
7342    /// Name of this user role permission.
7343    pub name: Option<String>,
7344    /// ID of the permission group that this user role permission belongs to.
7345    #[serde(rename = "permissionGroupId")]
7346    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7347    pub permission_group_id: Option<i64>,
7348}
7349
7350impl common::Resource for UserRolePermission {}
7351impl common::ResponseResult for UserRolePermission {}
7352
7353/// Represents a grouping of related user role permissions.
7354///
7355/// # Activities
7356///
7357/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7358/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7359///
7360/// * [get user role permission groups](UserRolePermissionGroupGetCall) (response)
7361/// * [list user role permission groups](UserRolePermissionGroupListCall) (none)
7362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7363#[serde_with::serde_as]
7364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7365pub struct UserRolePermissionGroup {
7366    /// ID of this user role permission.
7367    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
7368    pub id: Option<i64>,
7369    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroup".
7370    pub kind: Option<String>,
7371    /// Name of this user role permission group.
7372    pub name: Option<String>,
7373}
7374
7375impl common::Resource for UserRolePermissionGroup {}
7376impl common::ResponseResult for UserRolePermissionGroup {}
7377
7378/// User Role Permission Group List Response
7379///
7380/// # Activities
7381///
7382/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7383/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7384///
7385/// * [list user role permission groups](UserRolePermissionGroupListCall) (response)
7386#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7387#[serde_with::serde_as]
7388#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7389pub struct UserRolePermissionGroupsListResponse {
7390    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse".
7391    pub kind: Option<String>,
7392    /// User role permission group collection.
7393    #[serde(rename = "userRolePermissionGroups")]
7394    pub user_role_permission_groups: Option<Vec<UserRolePermissionGroup>>,
7395}
7396
7397impl common::ResponseResult for UserRolePermissionGroupsListResponse {}
7398
7399/// User Role Permission List Response
7400///
7401/// # Activities
7402///
7403/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7404/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7405///
7406/// * [list user role permissions](UserRolePermissionListCall) (response)
7407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7408#[serde_with::serde_as]
7409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7410pub struct UserRolePermissionsListResponse {
7411    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionsListResponse".
7412    pub kind: Option<String>,
7413    /// User role permission collection.
7414    #[serde(rename = "userRolePermissions")]
7415    pub user_role_permissions: Option<Vec<UserRolePermission>>,
7416}
7417
7418impl common::ResponseResult for UserRolePermissionsListResponse {}
7419
7420/// User Role List Response
7421///
7422/// # Activities
7423///
7424/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7425/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7426///
7427/// * [list user roles](UserRoleListCall) (response)
7428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7429#[serde_with::serde_as]
7430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7431pub struct UserRolesListResponse {
7432    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolesListResponse".
7433    pub kind: Option<String>,
7434    /// Pagination token to be used for the next list operation.
7435    #[serde(rename = "nextPageToken")]
7436    pub next_page_token: Option<String>,
7437    /// User role collection.
7438    #[serde(rename = "userRoles")]
7439    pub user_roles: Option<Vec<UserRole>>,
7440}
7441
7442impl common::ResponseResult for UserRolesListResponse {}
7443
7444/// Contains information about supported video formats.
7445///
7446/// # Activities
7447///
7448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7450///
7451/// * [get video formats](VideoFormatGetCall) (response)
7452/// * [list video formats](VideoFormatListCall) (none)
7453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7454#[serde_with::serde_as]
7455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7456pub struct VideoFormat {
7457    /// File type of the video format.
7458    #[serde(rename = "fileType")]
7459    pub file_type: Option<String>,
7460    /// ID of the video format.
7461    pub id: Option<i32>,
7462    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoFormat".
7463    pub kind: Option<String>,
7464    /// The resolution of this video format.
7465    pub resolution: Option<Size>,
7466    /// The target bit rate of this video format.
7467    #[serde(rename = "targetBitRate")]
7468    pub target_bit_rate: Option<i32>,
7469}
7470
7471impl common::Resource for VideoFormat {}
7472impl common::ResponseResult for VideoFormat {}
7473
7474/// Video Format List Response
7475///
7476/// # Activities
7477///
7478/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
7479/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
7480///
7481/// * [list video formats](VideoFormatListCall) (response)
7482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7483#[serde_with::serde_as]
7484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7485pub struct VideoFormatsListResponse {
7486    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoFormatsListResponse".
7487    pub kind: Option<String>,
7488    /// Video format collection.
7489    #[serde(rename = "videoFormats")]
7490    pub video_formats: Option<Vec<VideoFormat>>,
7491}
7492
7493impl common::ResponseResult for VideoFormatsListResponse {}
7494
7495/// Video Offset
7496///
7497/// This type is not used in any activity, and only used as *part* of another schema.
7498///
7499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7500#[serde_with::serde_as]
7501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7502pub struct VideoOffset {
7503    /// Duration, as a percentage of video duration. Do not set when offsetSeconds is set. Acceptable values are 0 to 100, inclusive.
7504    #[serde(rename = "offsetPercentage")]
7505    pub offset_percentage: Option<i32>,
7506    /// Duration, in seconds. Do not set when offsetPercentage is set. Acceptable values are 0 to 86399, inclusive.
7507    #[serde(rename = "offsetSeconds")]
7508    pub offset_seconds: Option<i32>,
7509}
7510
7511impl common::Part for VideoOffset {}
7512
7513/// Video Settings
7514///
7515/// This type is not used in any activity, and only used as *part* of another schema.
7516///
7517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7518#[serde_with::serde_as]
7519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7520pub struct VideoSettings {
7521    /// Settings for the companion creatives of video creatives served to this placement.
7522    #[serde(rename = "companionSettings")]
7523    pub companion_settings: Option<CompanionSetting>,
7524    /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoSettings".
7525    pub kind: Option<String>,
7526    /// Orientation of a video placement. If this value is set, placement will return assets matching the specified orientation.
7527    pub orientation: Option<String>,
7528    /// Settings for the skippability of video creatives served to this placement. If this object is provided, the creative-level skippable settings will be overridden.
7529    #[serde(rename = "skippableSettings")]
7530    pub skippable_settings: Option<SkippableSetting>,
7531    /// Settings for the transcodes of video creatives served to this placement. If this object is provided, the creative-level transcode settings will be overridden.
7532    #[serde(rename = "transcodeSettings")]
7533    pub transcode_settings: Option<TranscodeSetting>,
7534}
7535
7536impl common::Part for VideoSettings {}
7537
7538/// The URLs where the completed report file can be downloaded.
7539///
7540/// This type is not used in any activity, and only used as *part* of another schema.
7541///
7542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7543#[serde_with::serde_as]
7544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7545pub struct FileUrls {
7546    /// The URL for downloading the report data through the API.
7547    #[serde(rename = "apiUrl")]
7548    pub api_url: Option<String>,
7549    /// The URL for downloading the report data through a browser.
7550    #[serde(rename = "browserUrl")]
7551    pub browser_url: Option<String>,
7552}
7553
7554impl common::NestedType for FileUrls {}
7555impl common::Part for FileUrls {}
7556
7557/// The report criteria for a report of type "STANDARD".
7558///
7559/// This type is not used in any activity, and only used as *part* of another schema.
7560///
7561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7562#[serde_with::serde_as]
7563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7564pub struct ReportCriteria {
7565    /// Activity group.
7566    pub activities: Option<Activities>,
7567    /// Custom Rich Media Events group.
7568    #[serde(rename = "customRichMediaEvents")]
7569    pub custom_rich_media_events: Option<CustomRichMediaEvents>,
7570    /// The date range for which this report should be run.
7571    #[serde(rename = "dateRange")]
7572    pub date_range: Option<DateRange>,
7573    /// The list of filters on which dimensions are filtered.
7574    /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed.
7575    #[serde(rename = "dimensionFilters")]
7576    pub dimension_filters: Option<Vec<DimensionValue>>,
7577    /// The list of standard dimensions the report should include.
7578    pub dimensions: Option<Vec<SortedDimension>>,
7579    /// The list of names of metrics the report should include.
7580    #[serde(rename = "metricNames")]
7581    pub metric_names: Option<Vec<String>>,
7582}
7583
7584impl common::NestedType for ReportCriteria {}
7585impl common::Part for ReportCriteria {}
7586
7587/// The report criteria for a report of type "CROSS_DIMENSION_REACH".
7588///
7589/// This type is not used in any activity, and only used as *part* of another schema.
7590///
7591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7592#[serde_with::serde_as]
7593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7594pub struct ReportCrossDimensionReachCriteria {
7595    /// The list of dimensions the report should include.
7596    pub breakdown: Option<Vec<SortedDimension>>,
7597    /// The date range this report should be run for.
7598    #[serde(rename = "dateRange")]
7599    pub date_range: Option<DateRange>,
7600    /// The dimension option.
7601    pub dimension: Option<String>,
7602    /// The list of filters on which dimensions are filtered.
7603    #[serde(rename = "dimensionFilters")]
7604    pub dimension_filters: Option<Vec<DimensionValue>>,
7605    /// The list of names of metrics the report should include.
7606    #[serde(rename = "metricNames")]
7607    pub metric_names: Option<Vec<String>>,
7608    /// The list of names of overlap metrics the report should include.
7609    #[serde(rename = "overlapMetricNames")]
7610    pub overlap_metric_names: Option<Vec<String>>,
7611    /// Whether the report is pivoted or not. Defaults to true.
7612    pub pivoted: Option<bool>,
7613}
7614
7615impl common::NestedType for ReportCrossDimensionReachCriteria {}
7616impl common::Part for ReportCrossDimensionReachCriteria {}
7617
7618/// The report's email delivery settings.
7619///
7620/// This type is not used in any activity, and only used as *part* of another schema.
7621///
7622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7623#[serde_with::serde_as]
7624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7625pub struct ReportDelivery {
7626    /// Whether the report should be emailed to the report owner.
7627    #[serde(rename = "emailOwner")]
7628    pub email_owner: Option<bool>,
7629    /// The type of delivery for the owner to receive, if enabled.
7630    #[serde(rename = "emailOwnerDeliveryType")]
7631    pub email_owner_delivery_type: Option<String>,
7632    /// The message to be sent with each email.
7633    pub message: Option<String>,
7634    /// The list of recipients to which to email the report.
7635    pub recipients: Option<Vec<Recipient>>,
7636}
7637
7638impl common::NestedType for ReportDelivery {}
7639impl common::Part for ReportDelivery {}
7640
7641/// The report criteria for a report of type "FLOODLIGHT".
7642///
7643/// This type is not used in any activity, and only used as *part* of another schema.
7644///
7645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7646#[serde_with::serde_as]
7647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7648pub struct ReportFloodlightCriteria {
7649    /// The list of custom rich media events to include.
7650    #[serde(rename = "customRichMediaEvents")]
7651    pub custom_rich_media_events: Option<Vec<DimensionValue>>,
7652    /// The date range this report should be run for.
7653    #[serde(rename = "dateRange")]
7654    pub date_range: Option<DateRange>,
7655    /// The list of filters on which dimensions are filtered.
7656    /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed.
7657    #[serde(rename = "dimensionFilters")]
7658    pub dimension_filters: Option<Vec<DimensionValue>>,
7659    /// The list of dimensions the report should include.
7660    pub dimensions: Option<Vec<SortedDimension>>,
7661    /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'.
7662    #[serde(rename = "floodlightConfigId")]
7663    pub floodlight_config_id: Option<DimensionValue>,
7664    /// The list of names of metrics the report should include.
7665    #[serde(rename = "metricNames")]
7666    pub metric_names: Option<Vec<String>>,
7667    /// The properties of the report.
7668    #[serde(rename = "reportProperties")]
7669    pub report_properties: Option<ReportFloodlightCriteriaReportProperties>,
7670}
7671
7672impl common::NestedType for ReportFloodlightCriteria {}
7673impl common::Part for ReportFloodlightCriteria {}
7674
7675/// The properties of the report.
7676///
7677/// This type is not used in any activity, and only used as *part* of another schema.
7678///
7679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7680#[serde_with::serde_as]
7681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7682pub struct ReportFloodlightCriteriaReportProperties {
7683    /// Include conversions that have no cookie, but do have an exposure path.
7684    #[serde(rename = "includeAttributedIPConversions")]
7685    pub include_attributed_ip_conversions: Option<bool>,
7686    /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window.
7687    #[serde(rename = "includeUnattributedCookieConversions")]
7688    pub include_unattributed_cookie_conversions: Option<bool>,
7689    /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion.
7690    #[serde(rename = "includeUnattributedIPConversions")]
7691    pub include_unattributed_ip_conversions: Option<bool>,
7692}
7693
7694impl common::NestedType for ReportFloodlightCriteriaReportProperties {}
7695impl common::Part for ReportFloodlightCriteriaReportProperties {}
7696
7697/// The report criteria for a report of type "PATH_TO_CONVERSION".
7698///
7699/// This type is not used in any activity, and only used as *part* of another schema.
7700///
7701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7702#[serde_with::serde_as]
7703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7704pub struct ReportPathToConversionCriteria {
7705    /// The list of 'dfa:activity' values to filter on.
7706    #[serde(rename = "activityFilters")]
7707    pub activity_filters: Option<Vec<DimensionValue>>,
7708    /// The list of conversion dimensions the report should include.
7709    #[serde(rename = "conversionDimensions")]
7710    pub conversion_dimensions: Option<Vec<SortedDimension>>,
7711    /// The list of custom floodlight variables the report should include.
7712    #[serde(rename = "customFloodlightVariables")]
7713    pub custom_floodlight_variables: Option<Vec<SortedDimension>>,
7714    /// The list of custom rich media events to include.
7715    #[serde(rename = "customRichMediaEvents")]
7716    pub custom_rich_media_events: Option<Vec<DimensionValue>>,
7717    /// The date range this report should be run for.
7718    #[serde(rename = "dateRange")]
7719    pub date_range: Option<DateRange>,
7720    /// The floodlight ID for which to show data in this report. All advertisers associated with that ID will automatically be added. The dimension of the value needs to be 'dfa:floodlightConfigId'.
7721    #[serde(rename = "floodlightConfigId")]
7722    pub floodlight_config_id: Option<DimensionValue>,
7723    /// The list of names of metrics the report should include.
7724    #[serde(rename = "metricNames")]
7725    pub metric_names: Option<Vec<String>>,
7726    /// The list of per interaction dimensions the report should include.
7727    #[serde(rename = "perInteractionDimensions")]
7728    pub per_interaction_dimensions: Option<Vec<SortedDimension>>,
7729    /// The properties of the report.
7730    #[serde(rename = "reportProperties")]
7731    pub report_properties: Option<ReportPathToConversionCriteriaReportProperties>,
7732}
7733
7734impl common::NestedType for ReportPathToConversionCriteria {}
7735impl common::Part for ReportPathToConversionCriteria {}
7736
7737/// The properties of the report.
7738///
7739/// This type is not used in any activity, and only used as *part* of another schema.
7740///
7741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7742#[serde_with::serde_as]
7743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7744pub struct ReportPathToConversionCriteriaReportProperties {
7745    /// DFA checks to see if a click interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90.
7746    #[serde(rename = "clicksLookbackWindow")]
7747    pub clicks_lookback_window: Option<i32>,
7748    /// DFA checks to see if an impression interaction occurred within the specified period of time before a conversion. By default the value is pulled from Floodlight or you can manually enter a custom value. Valid values: 1-90.
7749    #[serde(rename = "impressionsLookbackWindow")]
7750    pub impressions_lookback_window: Option<i32>,
7751    /// Deprecated: has no effect.
7752    #[serde(rename = "includeAttributedIPConversions")]
7753    pub include_attributed_ip_conversions: Option<bool>,
7754    /// Include conversions of users with a DoubleClick cookie but without an exposure. That means the user did not click or see an ad from the advertiser within the Floodlight group, or that the interaction happened outside the lookback window.
7755    #[serde(rename = "includeUnattributedCookieConversions")]
7756    pub include_unattributed_cookie_conversions: Option<bool>,
7757    /// Include conversions that have no associated cookies and no exposures. It’s therefore impossible to know how the user was exposed to your ads during the lookback window prior to a conversion.
7758    #[serde(rename = "includeUnattributedIPConversions")]
7759    pub include_unattributed_ip_conversions: Option<bool>,
7760    /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report.
7761    #[serde(rename = "maximumClickInteractions")]
7762    pub maximum_click_interactions: Option<i32>,
7763    /// The maximum number of click interactions to include in the report. Advertisers currently paying for E2C reports get up to 200 (100 clicks, 100 impressions). If another advertiser in your network is paying for E2C, you can have up to 5 total exposures per report.
7764    #[serde(rename = "maximumImpressionInteractions")]
7765    pub maximum_impression_interactions: Option<i32>,
7766    /// The maximum amount of time that can take place between interactions (clicks or impressions) by the same user. Valid values: 1-90.
7767    #[serde(rename = "maximumInteractionGap")]
7768    pub maximum_interaction_gap: Option<i32>,
7769    /// Enable pivoting on interaction path.
7770    #[serde(rename = "pivotOnInteractionPath")]
7771    pub pivot_on_interaction_path: Option<bool>,
7772}
7773
7774impl common::NestedType for ReportPathToConversionCriteriaReportProperties {}
7775impl common::Part for ReportPathToConversionCriteriaReportProperties {}
7776
7777/// The report criteria for a report of type "REACH".
7778///
7779/// This type is not used in any activity, and only used as *part* of another schema.
7780///
7781#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7782#[serde_with::serde_as]
7783#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7784pub struct ReportReachCriteria {
7785    /// Activity group.
7786    pub activities: Option<Activities>,
7787    /// Custom Rich Media Events group.
7788    #[serde(rename = "customRichMediaEvents")]
7789    pub custom_rich_media_events: Option<CustomRichMediaEvents>,
7790    /// The date range this report should be run for.
7791    #[serde(rename = "dateRange")]
7792    pub date_range: Option<DateRange>,
7793    /// The list of filters on which dimensions are filtered.
7794    /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed.
7795    #[serde(rename = "dimensionFilters")]
7796    pub dimension_filters: Option<Vec<DimensionValue>>,
7797    /// The list of dimensions the report should include.
7798    pub dimensions: Option<Vec<SortedDimension>>,
7799    /// Whether to enable all reach dimension combinations in the report. Defaults to false. If enabled, the date range of the report should be within the last 42 days.
7800    #[serde(rename = "enableAllDimensionCombinations")]
7801    pub enable_all_dimension_combinations: Option<bool>,
7802    /// The list of names of metrics the report should include.
7803    #[serde(rename = "metricNames")]
7804    pub metric_names: Option<Vec<String>>,
7805    /// The list of names of  Reach By Frequency metrics the report should include.
7806    #[serde(rename = "reachByFrequencyMetricNames")]
7807    pub reach_by_frequency_metric_names: Option<Vec<String>>,
7808}
7809
7810impl common::NestedType for ReportReachCriteria {}
7811impl common::Part for ReportReachCriteria {}
7812
7813/// The report's schedule. Can only be set if the report's 'dateRange' is a relative date range and the relative date range is not "TODAY".
7814///
7815/// This type is not used in any activity, and only used as *part* of another schema.
7816///
7817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
7818#[serde_with::serde_as]
7819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7820pub struct ReportSchedule {
7821    /// Whether the schedule is active or not. Must be set to either true or false.
7822    pub active: Option<bool>,
7823    /// Defines every how many days, weeks or months the report should be run. Needs to be set when "repeats" is either "DAILY", "WEEKLY" or "MONTHLY".
7824    pub every: Option<i32>,
7825    /// The expiration date when the scheduled report stops running.
7826    #[serde(rename = "expirationDate")]
7827    pub expiration_date: Option<chrono::NaiveDate>,
7828    /// The interval for which the report is repeated. Note:  
7829    /// - "DAILY" also requires field "every" to be set.
7830    /// - "WEEKLY" also requires fields "every" and "repeatsOnWeekDays" to be set.
7831    /// - "MONTHLY" also requires fields "every" and "runsOnDayOfMonth" to be set.
7832    pub repeats: Option<String>,
7833    /// List of week days "WEEKLY" on which scheduled reports should run.
7834    #[serde(rename = "repeatsOnWeekDays")]
7835    pub repeats_on_week_days: Option<Vec<String>>,
7836    /// Enum to define for "MONTHLY" scheduled reports whether reports should be repeated on the same day of the month as "startDate" or the same day of the week of the month.
7837    /// Example: If 'startDate' is Monday, April 2nd 2012 (2012-04-02), "DAY_OF_MONTH" would run subsequent reports on the 2nd of every Month, and "WEEK_OF_MONTH" would run subsequent reports on the first Monday of the month.
7838    #[serde(rename = "runsOnDayOfMonth")]
7839    pub runs_on_day_of_month: Option<String>,
7840    /// Start date of date range for which scheduled reports should be run.
7841    #[serde(rename = "startDate")]
7842    pub start_date: Option<chrono::NaiveDate>,
7843}
7844
7845impl common::NestedType for ReportSchedule {}
7846impl common::Part for ReportSchedule {}
7847
7848// ###################
7849// MethodBuilders ###
7850// #################
7851
7852/// A builder providing access to all methods supported on *accountActiveAdSummary* resources.
7853/// It is not used directly, but through the [`Dfareporting`] hub.
7854///
7855/// # Example
7856///
7857/// Instantiate a resource builder
7858///
7859/// ```test_harness,no_run
7860/// extern crate hyper;
7861/// extern crate hyper_rustls;
7862/// extern crate google_dfareporting3d2 as dfareporting3d2;
7863///
7864/// # async fn dox() {
7865/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7866///
7867/// let secret: yup_oauth2::ApplicationSecret = Default::default();
7868/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7869///     secret,
7870///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7871/// ).build().await.unwrap();
7872///
7873/// let client = hyper_util::client::legacy::Client::builder(
7874///     hyper_util::rt::TokioExecutor::new()
7875/// )
7876/// .build(
7877///     hyper_rustls::HttpsConnectorBuilder::new()
7878///         .with_native_roots()
7879///         .unwrap()
7880///         .https_or_http()
7881///         .enable_http1()
7882///         .build()
7883/// );
7884/// let mut hub = Dfareporting::new(client, auth);
7885/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
7886/// // like `get(...)`
7887/// // to build up your call.
7888/// let rb = hub.account_active_ad_summaries();
7889/// # }
7890/// ```
7891pub struct AccountActiveAdSummaryMethods<'a, C>
7892where
7893    C: 'a,
7894{
7895    hub: &'a Dfareporting<C>,
7896}
7897
7898impl<'a, C> common::MethodsBuilder for AccountActiveAdSummaryMethods<'a, C> {}
7899
7900impl<'a, C> AccountActiveAdSummaryMethods<'a, C> {
7901    /// Create a builder to help you perform the following task:
7902    ///
7903    /// Gets the account's active ad summary by account ID.
7904    ///
7905    /// # Arguments
7906    ///
7907    /// * `profileId` - User profile ID associated with this request.
7908    /// * `summaryAccountId` - Account ID.
7909    pub fn get(
7910        &self,
7911        profile_id: i64,
7912        summary_account_id: i64,
7913    ) -> AccountActiveAdSummaryGetCall<'a, C> {
7914        AccountActiveAdSummaryGetCall {
7915            hub: self.hub,
7916            _profile_id: profile_id,
7917            _summary_account_id: summary_account_id,
7918            _delegate: Default::default(),
7919            _additional_params: Default::default(),
7920            _scopes: Default::default(),
7921        }
7922    }
7923}
7924
7925/// A builder providing access to all methods supported on *accountPermissionGroup* resources.
7926/// It is not used directly, but through the [`Dfareporting`] hub.
7927///
7928/// # Example
7929///
7930/// Instantiate a resource builder
7931///
7932/// ```test_harness,no_run
7933/// extern crate hyper;
7934/// extern crate hyper_rustls;
7935/// extern crate google_dfareporting3d2 as dfareporting3d2;
7936///
7937/// # async fn dox() {
7938/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7939///
7940/// let secret: yup_oauth2::ApplicationSecret = Default::default();
7941/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7942///     secret,
7943///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7944/// ).build().await.unwrap();
7945///
7946/// let client = hyper_util::client::legacy::Client::builder(
7947///     hyper_util::rt::TokioExecutor::new()
7948/// )
7949/// .build(
7950///     hyper_rustls::HttpsConnectorBuilder::new()
7951///         .with_native_roots()
7952///         .unwrap()
7953///         .https_or_http()
7954///         .enable_http1()
7955///         .build()
7956/// );
7957/// let mut hub = Dfareporting::new(client, auth);
7958/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
7959/// // like `get(...)` and `list(...)`
7960/// // to build up your call.
7961/// let rb = hub.account_permission_groups();
7962/// # }
7963/// ```
7964pub struct AccountPermissionGroupMethods<'a, C>
7965where
7966    C: 'a,
7967{
7968    hub: &'a Dfareporting<C>,
7969}
7970
7971impl<'a, C> common::MethodsBuilder for AccountPermissionGroupMethods<'a, C> {}
7972
7973impl<'a, C> AccountPermissionGroupMethods<'a, C> {
7974    /// Create a builder to help you perform the following task:
7975    ///
7976    /// Gets one account permission group by ID.
7977    ///
7978    /// # Arguments
7979    ///
7980    /// * `profileId` - User profile ID associated with this request.
7981    /// * `id` - Account permission group ID.
7982    pub fn get(&self, profile_id: i64, id: i64) -> AccountPermissionGroupGetCall<'a, C> {
7983        AccountPermissionGroupGetCall {
7984            hub: self.hub,
7985            _profile_id: profile_id,
7986            _id: id,
7987            _delegate: Default::default(),
7988            _additional_params: Default::default(),
7989            _scopes: Default::default(),
7990        }
7991    }
7992
7993    /// Create a builder to help you perform the following task:
7994    ///
7995    /// Retrieves the list of account permission groups.
7996    ///
7997    /// # Arguments
7998    ///
7999    /// * `profileId` - User profile ID associated with this request.
8000    pub fn list(&self, profile_id: i64) -> AccountPermissionGroupListCall<'a, C> {
8001        AccountPermissionGroupListCall {
8002            hub: self.hub,
8003            _profile_id: profile_id,
8004            _delegate: Default::default(),
8005            _additional_params: Default::default(),
8006            _scopes: Default::default(),
8007        }
8008    }
8009}
8010
8011/// A builder providing access to all methods supported on *accountPermission* resources.
8012/// It is not used directly, but through the [`Dfareporting`] hub.
8013///
8014/// # Example
8015///
8016/// Instantiate a resource builder
8017///
8018/// ```test_harness,no_run
8019/// extern crate hyper;
8020/// extern crate hyper_rustls;
8021/// extern crate google_dfareporting3d2 as dfareporting3d2;
8022///
8023/// # async fn dox() {
8024/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8025///
8026/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8027/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8028///     secret,
8029///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8030/// ).build().await.unwrap();
8031///
8032/// let client = hyper_util::client::legacy::Client::builder(
8033///     hyper_util::rt::TokioExecutor::new()
8034/// )
8035/// .build(
8036///     hyper_rustls::HttpsConnectorBuilder::new()
8037///         .with_native_roots()
8038///         .unwrap()
8039///         .https_or_http()
8040///         .enable_http1()
8041///         .build()
8042/// );
8043/// let mut hub = Dfareporting::new(client, auth);
8044/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8045/// // like `get(...)` and `list(...)`
8046/// // to build up your call.
8047/// let rb = hub.account_permissions();
8048/// # }
8049/// ```
8050pub struct AccountPermissionMethods<'a, C>
8051where
8052    C: 'a,
8053{
8054    hub: &'a Dfareporting<C>,
8055}
8056
8057impl<'a, C> common::MethodsBuilder for AccountPermissionMethods<'a, C> {}
8058
8059impl<'a, C> AccountPermissionMethods<'a, C> {
8060    /// Create a builder to help you perform the following task:
8061    ///
8062    /// Gets one account permission by ID.
8063    ///
8064    /// # Arguments
8065    ///
8066    /// * `profileId` - User profile ID associated with this request.
8067    /// * `id` - Account permission ID.
8068    pub fn get(&self, profile_id: i64, id: i64) -> AccountPermissionGetCall<'a, C> {
8069        AccountPermissionGetCall {
8070            hub: self.hub,
8071            _profile_id: profile_id,
8072            _id: id,
8073            _delegate: Default::default(),
8074            _additional_params: Default::default(),
8075            _scopes: Default::default(),
8076        }
8077    }
8078
8079    /// Create a builder to help you perform the following task:
8080    ///
8081    /// Retrieves the list of account permissions.
8082    ///
8083    /// # Arguments
8084    ///
8085    /// * `profileId` - User profile ID associated with this request.
8086    pub fn list(&self, profile_id: i64) -> AccountPermissionListCall<'a, C> {
8087        AccountPermissionListCall {
8088            hub: self.hub,
8089            _profile_id: profile_id,
8090            _delegate: Default::default(),
8091            _additional_params: Default::default(),
8092            _scopes: Default::default(),
8093        }
8094    }
8095}
8096
8097/// A builder providing access to all methods supported on *accountUserProfile* resources.
8098/// It is not used directly, but through the [`Dfareporting`] hub.
8099///
8100/// # Example
8101///
8102/// Instantiate a resource builder
8103///
8104/// ```test_harness,no_run
8105/// extern crate hyper;
8106/// extern crate hyper_rustls;
8107/// extern crate google_dfareporting3d2 as dfareporting3d2;
8108///
8109/// # async fn dox() {
8110/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8111///
8112/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8113/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8114///     secret,
8115///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8116/// ).build().await.unwrap();
8117///
8118/// let client = hyper_util::client::legacy::Client::builder(
8119///     hyper_util::rt::TokioExecutor::new()
8120/// )
8121/// .build(
8122///     hyper_rustls::HttpsConnectorBuilder::new()
8123///         .with_native_roots()
8124///         .unwrap()
8125///         .https_or_http()
8126///         .enable_http1()
8127///         .build()
8128/// );
8129/// let mut hub = Dfareporting::new(client, auth);
8130/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8131/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
8132/// // to build up your call.
8133/// let rb = hub.account_user_profiles();
8134/// # }
8135/// ```
8136pub struct AccountUserProfileMethods<'a, C>
8137where
8138    C: 'a,
8139{
8140    hub: &'a Dfareporting<C>,
8141}
8142
8143impl<'a, C> common::MethodsBuilder for AccountUserProfileMethods<'a, C> {}
8144
8145impl<'a, C> AccountUserProfileMethods<'a, C> {
8146    /// Create a builder to help you perform the following task:
8147    ///
8148    /// Gets one account user profile by ID.
8149    ///
8150    /// # Arguments
8151    ///
8152    /// * `profileId` - User profile ID associated with this request.
8153    /// * `id` - User profile ID.
8154    pub fn get(&self, profile_id: i64, id: i64) -> AccountUserProfileGetCall<'a, C> {
8155        AccountUserProfileGetCall {
8156            hub: self.hub,
8157            _profile_id: profile_id,
8158            _id: id,
8159            _delegate: Default::default(),
8160            _additional_params: Default::default(),
8161            _scopes: Default::default(),
8162        }
8163    }
8164
8165    /// Create a builder to help you perform the following task:
8166    ///
8167    /// Inserts a new account user profile.
8168    ///
8169    /// # Arguments
8170    ///
8171    /// * `request` - No description provided.
8172    /// * `profileId` - User profile ID associated with this request.
8173    pub fn insert(
8174        &self,
8175        request: AccountUserProfile,
8176        profile_id: i64,
8177    ) -> AccountUserProfileInsertCall<'a, C> {
8178        AccountUserProfileInsertCall {
8179            hub: self.hub,
8180            _request: request,
8181            _profile_id: profile_id,
8182            _delegate: Default::default(),
8183            _additional_params: Default::default(),
8184            _scopes: Default::default(),
8185        }
8186    }
8187
8188    /// Create a builder to help you perform the following task:
8189    ///
8190    /// Retrieves a list of account user profiles, possibly filtered. This method supports paging.
8191    ///
8192    /// # Arguments
8193    ///
8194    /// * `profileId` - User profile ID associated with this request.
8195    pub fn list(&self, profile_id: i64) -> AccountUserProfileListCall<'a, C> {
8196        AccountUserProfileListCall {
8197            hub: self.hub,
8198            _profile_id: profile_id,
8199            _user_role_id: Default::default(),
8200            _subaccount_id: Default::default(),
8201            _sort_order: Default::default(),
8202            _sort_field: Default::default(),
8203            _search_string: Default::default(),
8204            _page_token: Default::default(),
8205            _max_results: Default::default(),
8206            _ids: Default::default(),
8207            _active: Default::default(),
8208            _delegate: Default::default(),
8209            _additional_params: Default::default(),
8210            _scopes: Default::default(),
8211        }
8212    }
8213
8214    /// Create a builder to help you perform the following task:
8215    ///
8216    /// Updates an existing account user profile. This method supports patch semantics.
8217    ///
8218    /// # Arguments
8219    ///
8220    /// * `request` - No description provided.
8221    /// * `profileId` - User profile ID associated with this request.
8222    /// * `id` - User profile ID.
8223    pub fn patch(
8224        &self,
8225        request: AccountUserProfile,
8226        profile_id: i64,
8227        id: i64,
8228    ) -> AccountUserProfilePatchCall<'a, C> {
8229        AccountUserProfilePatchCall {
8230            hub: self.hub,
8231            _request: request,
8232            _profile_id: profile_id,
8233            _id: id,
8234            _delegate: Default::default(),
8235            _additional_params: Default::default(),
8236            _scopes: Default::default(),
8237        }
8238    }
8239
8240    /// Create a builder to help you perform the following task:
8241    ///
8242    /// Updates an existing account user profile.
8243    ///
8244    /// # Arguments
8245    ///
8246    /// * `request` - No description provided.
8247    /// * `profileId` - User profile ID associated with this request.
8248    pub fn update(
8249        &self,
8250        request: AccountUserProfile,
8251        profile_id: i64,
8252    ) -> AccountUserProfileUpdateCall<'a, C> {
8253        AccountUserProfileUpdateCall {
8254            hub: self.hub,
8255            _request: request,
8256            _profile_id: profile_id,
8257            _delegate: Default::default(),
8258            _additional_params: Default::default(),
8259            _scopes: Default::default(),
8260        }
8261    }
8262}
8263
8264/// A builder providing access to all methods supported on *account* resources.
8265/// It is not used directly, but through the [`Dfareporting`] hub.
8266///
8267/// # Example
8268///
8269/// Instantiate a resource builder
8270///
8271/// ```test_harness,no_run
8272/// extern crate hyper;
8273/// extern crate hyper_rustls;
8274/// extern crate google_dfareporting3d2 as dfareporting3d2;
8275///
8276/// # async fn dox() {
8277/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8278///
8279/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8280/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8281///     secret,
8282///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8283/// ).build().await.unwrap();
8284///
8285/// let client = hyper_util::client::legacy::Client::builder(
8286///     hyper_util::rt::TokioExecutor::new()
8287/// )
8288/// .build(
8289///     hyper_rustls::HttpsConnectorBuilder::new()
8290///         .with_native_roots()
8291///         .unwrap()
8292///         .https_or_http()
8293///         .enable_http1()
8294///         .build()
8295/// );
8296/// let mut hub = Dfareporting::new(client, auth);
8297/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8298/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)`
8299/// // to build up your call.
8300/// let rb = hub.accounts();
8301/// # }
8302/// ```
8303pub struct AccountMethods<'a, C>
8304where
8305    C: 'a,
8306{
8307    hub: &'a Dfareporting<C>,
8308}
8309
8310impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
8311
8312impl<'a, C> AccountMethods<'a, C> {
8313    /// Create a builder to help you perform the following task:
8314    ///
8315    /// Gets one account by ID.
8316    ///
8317    /// # Arguments
8318    ///
8319    /// * `profileId` - User profile ID associated with this request.
8320    /// * `id` - Account ID.
8321    pub fn get(&self, profile_id: i64, id: i64) -> AccountGetCall<'a, C> {
8322        AccountGetCall {
8323            hub: self.hub,
8324            _profile_id: profile_id,
8325            _id: id,
8326            _delegate: Default::default(),
8327            _additional_params: Default::default(),
8328            _scopes: Default::default(),
8329        }
8330    }
8331
8332    /// Create a builder to help you perform the following task:
8333    ///
8334    /// Retrieves the list of accounts, possibly filtered. This method supports paging.
8335    ///
8336    /// # Arguments
8337    ///
8338    /// * `profileId` - User profile ID associated with this request.
8339    pub fn list(&self, profile_id: i64) -> AccountListCall<'a, C> {
8340        AccountListCall {
8341            hub: self.hub,
8342            _profile_id: profile_id,
8343            _sort_order: Default::default(),
8344            _sort_field: Default::default(),
8345            _search_string: Default::default(),
8346            _page_token: Default::default(),
8347            _max_results: Default::default(),
8348            _ids: Default::default(),
8349            _active: Default::default(),
8350            _delegate: Default::default(),
8351            _additional_params: Default::default(),
8352            _scopes: Default::default(),
8353        }
8354    }
8355
8356    /// Create a builder to help you perform the following task:
8357    ///
8358    /// Updates an existing account. This method supports patch semantics.
8359    ///
8360    /// # Arguments
8361    ///
8362    /// * `request` - No description provided.
8363    /// * `profileId` - User profile ID associated with this request.
8364    /// * `id` - Account ID.
8365    pub fn patch(&self, request: Account, profile_id: i64, id: i64) -> AccountPatchCall<'a, C> {
8366        AccountPatchCall {
8367            hub: self.hub,
8368            _request: request,
8369            _profile_id: profile_id,
8370            _id: id,
8371            _delegate: Default::default(),
8372            _additional_params: Default::default(),
8373            _scopes: Default::default(),
8374        }
8375    }
8376
8377    /// Create a builder to help you perform the following task:
8378    ///
8379    /// Updates an existing account.
8380    ///
8381    /// # Arguments
8382    ///
8383    /// * `request` - No description provided.
8384    /// * `profileId` - User profile ID associated with this request.
8385    pub fn update(&self, request: Account, profile_id: i64) -> AccountUpdateCall<'a, C> {
8386        AccountUpdateCall {
8387            hub: self.hub,
8388            _request: request,
8389            _profile_id: profile_id,
8390            _delegate: Default::default(),
8391            _additional_params: Default::default(),
8392            _scopes: Default::default(),
8393        }
8394    }
8395}
8396
8397/// A builder providing access to all methods supported on *ad* resources.
8398/// It is not used directly, but through the [`Dfareporting`] hub.
8399///
8400/// # Example
8401///
8402/// Instantiate a resource builder
8403///
8404/// ```test_harness,no_run
8405/// extern crate hyper;
8406/// extern crate hyper_rustls;
8407/// extern crate google_dfareporting3d2 as dfareporting3d2;
8408///
8409/// # async fn dox() {
8410/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8411///
8412/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8413/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8414///     secret,
8415///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8416/// ).build().await.unwrap();
8417///
8418/// let client = hyper_util::client::legacy::Client::builder(
8419///     hyper_util::rt::TokioExecutor::new()
8420/// )
8421/// .build(
8422///     hyper_rustls::HttpsConnectorBuilder::new()
8423///         .with_native_roots()
8424///         .unwrap()
8425///         .https_or_http()
8426///         .enable_http1()
8427///         .build()
8428/// );
8429/// let mut hub = Dfareporting::new(client, auth);
8430/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8431/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
8432/// // to build up your call.
8433/// let rb = hub.ads();
8434/// # }
8435/// ```
8436pub struct AdMethods<'a, C>
8437where
8438    C: 'a,
8439{
8440    hub: &'a Dfareporting<C>,
8441}
8442
8443impl<'a, C> common::MethodsBuilder for AdMethods<'a, C> {}
8444
8445impl<'a, C> AdMethods<'a, C> {
8446    /// Create a builder to help you perform the following task:
8447    ///
8448    /// Gets one ad by ID.
8449    ///
8450    /// # Arguments
8451    ///
8452    /// * `profileId` - User profile ID associated with this request.
8453    /// * `id` - Ad ID.
8454    pub fn get(&self, profile_id: i64, id: i64) -> AdGetCall<'a, C> {
8455        AdGetCall {
8456            hub: self.hub,
8457            _profile_id: profile_id,
8458            _id: id,
8459            _delegate: Default::default(),
8460            _additional_params: Default::default(),
8461            _scopes: Default::default(),
8462        }
8463    }
8464
8465    /// Create a builder to help you perform the following task:
8466    ///
8467    /// Inserts a new ad.
8468    ///
8469    /// # Arguments
8470    ///
8471    /// * `request` - No description provided.
8472    /// * `profileId` - User profile ID associated with this request.
8473    pub fn insert(&self, request: Ad, profile_id: i64) -> AdInsertCall<'a, C> {
8474        AdInsertCall {
8475            hub: self.hub,
8476            _request: request,
8477            _profile_id: profile_id,
8478            _delegate: Default::default(),
8479            _additional_params: Default::default(),
8480            _scopes: Default::default(),
8481        }
8482    }
8483
8484    /// Create a builder to help you perform the following task:
8485    ///
8486    /// Retrieves a list of ads, possibly filtered. This method supports paging.
8487    ///
8488    /// # Arguments
8489    ///
8490    /// * `profileId` - User profile ID associated with this request.
8491    pub fn list(&self, profile_id: i64) -> AdListCall<'a, C> {
8492        AdListCall {
8493            hub: self.hub,
8494            _profile_id: profile_id,
8495            _type_: Default::default(),
8496            _ssl_required: Default::default(),
8497            _ssl_compliant: Default::default(),
8498            _sort_order: Default::default(),
8499            _sort_field: Default::default(),
8500            _size_ids: Default::default(),
8501            _search_string: Default::default(),
8502            _remarketing_list_ids: Default::default(),
8503            _placement_ids: Default::default(),
8504            _page_token: Default::default(),
8505            _overridden_event_tag_id: Default::default(),
8506            _max_results: Default::default(),
8507            _landing_page_ids: Default::default(),
8508            _ids: Default::default(),
8509            _dynamic_click_tracker: Default::default(),
8510            _creative_optimization_configuration_ids: Default::default(),
8511            _creative_ids: Default::default(),
8512            _compatibility: Default::default(),
8513            _campaign_ids: Default::default(),
8514            _audience_segment_ids: Default::default(),
8515            _archived: Default::default(),
8516            _advertiser_id: Default::default(),
8517            _active: Default::default(),
8518            _delegate: Default::default(),
8519            _additional_params: Default::default(),
8520            _scopes: Default::default(),
8521        }
8522    }
8523
8524    /// Create a builder to help you perform the following task:
8525    ///
8526    /// Updates an existing ad. This method supports patch semantics.
8527    ///
8528    /// # Arguments
8529    ///
8530    /// * `request` - No description provided.
8531    /// * `profileId` - User profile ID associated with this request.
8532    /// * `id` - Ad ID.
8533    pub fn patch(&self, request: Ad, profile_id: i64, id: i64) -> AdPatchCall<'a, C> {
8534        AdPatchCall {
8535            hub: self.hub,
8536            _request: request,
8537            _profile_id: profile_id,
8538            _id: id,
8539            _delegate: Default::default(),
8540            _additional_params: Default::default(),
8541            _scopes: Default::default(),
8542        }
8543    }
8544
8545    /// Create a builder to help you perform the following task:
8546    ///
8547    /// Updates an existing ad.
8548    ///
8549    /// # Arguments
8550    ///
8551    /// * `request` - No description provided.
8552    /// * `profileId` - User profile ID associated with this request.
8553    pub fn update(&self, request: Ad, profile_id: i64) -> AdUpdateCall<'a, C> {
8554        AdUpdateCall {
8555            hub: self.hub,
8556            _request: request,
8557            _profile_id: profile_id,
8558            _delegate: Default::default(),
8559            _additional_params: Default::default(),
8560            _scopes: Default::default(),
8561        }
8562    }
8563}
8564
8565/// A builder providing access to all methods supported on *advertiserGroup* resources.
8566/// It is not used directly, but through the [`Dfareporting`] hub.
8567///
8568/// # Example
8569///
8570/// Instantiate a resource builder
8571///
8572/// ```test_harness,no_run
8573/// extern crate hyper;
8574/// extern crate hyper_rustls;
8575/// extern crate google_dfareporting3d2 as dfareporting3d2;
8576///
8577/// # async fn dox() {
8578/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8579///
8580/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8581/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8582///     secret,
8583///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8584/// ).build().await.unwrap();
8585///
8586/// let client = hyper_util::client::legacy::Client::builder(
8587///     hyper_util::rt::TokioExecutor::new()
8588/// )
8589/// .build(
8590///     hyper_rustls::HttpsConnectorBuilder::new()
8591///         .with_native_roots()
8592///         .unwrap()
8593///         .https_or_http()
8594///         .enable_http1()
8595///         .build()
8596/// );
8597/// let mut hub = Dfareporting::new(client, auth);
8598/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8599/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
8600/// // to build up your call.
8601/// let rb = hub.advertiser_groups();
8602/// # }
8603/// ```
8604pub struct AdvertiserGroupMethods<'a, C>
8605where
8606    C: 'a,
8607{
8608    hub: &'a Dfareporting<C>,
8609}
8610
8611impl<'a, C> common::MethodsBuilder for AdvertiserGroupMethods<'a, C> {}
8612
8613impl<'a, C> AdvertiserGroupMethods<'a, C> {
8614    /// Create a builder to help you perform the following task:
8615    ///
8616    /// Deletes an existing advertiser group.
8617    ///
8618    /// # Arguments
8619    ///
8620    /// * `profileId` - User profile ID associated with this request.
8621    /// * `id` - Advertiser group ID.
8622    pub fn delete(&self, profile_id: i64, id: i64) -> AdvertiserGroupDeleteCall<'a, C> {
8623        AdvertiserGroupDeleteCall {
8624            hub: self.hub,
8625            _profile_id: profile_id,
8626            _id: id,
8627            _delegate: Default::default(),
8628            _additional_params: Default::default(),
8629            _scopes: Default::default(),
8630        }
8631    }
8632
8633    /// Create a builder to help you perform the following task:
8634    ///
8635    /// Gets one advertiser group by ID.
8636    ///
8637    /// # Arguments
8638    ///
8639    /// * `profileId` - User profile ID associated with this request.
8640    /// * `id` - Advertiser group ID.
8641    pub fn get(&self, profile_id: i64, id: i64) -> AdvertiserGroupGetCall<'a, C> {
8642        AdvertiserGroupGetCall {
8643            hub: self.hub,
8644            _profile_id: profile_id,
8645            _id: id,
8646            _delegate: Default::default(),
8647            _additional_params: Default::default(),
8648            _scopes: Default::default(),
8649        }
8650    }
8651
8652    /// Create a builder to help you perform the following task:
8653    ///
8654    /// Inserts a new advertiser group.
8655    ///
8656    /// # Arguments
8657    ///
8658    /// * `request` - No description provided.
8659    /// * `profileId` - User profile ID associated with this request.
8660    pub fn insert(
8661        &self,
8662        request: AdvertiserGroup,
8663        profile_id: i64,
8664    ) -> AdvertiserGroupInsertCall<'a, C> {
8665        AdvertiserGroupInsertCall {
8666            hub: self.hub,
8667            _request: request,
8668            _profile_id: profile_id,
8669            _delegate: Default::default(),
8670            _additional_params: Default::default(),
8671            _scopes: Default::default(),
8672        }
8673    }
8674
8675    /// Create a builder to help you perform the following task:
8676    ///
8677    /// Retrieves a list of advertiser groups, possibly filtered. This method supports paging.
8678    ///
8679    /// # Arguments
8680    ///
8681    /// * `profileId` - User profile ID associated with this request.
8682    pub fn list(&self, profile_id: i64) -> AdvertiserGroupListCall<'a, C> {
8683        AdvertiserGroupListCall {
8684            hub: self.hub,
8685            _profile_id: profile_id,
8686            _sort_order: Default::default(),
8687            _sort_field: Default::default(),
8688            _search_string: Default::default(),
8689            _page_token: Default::default(),
8690            _max_results: Default::default(),
8691            _ids: Default::default(),
8692            _delegate: Default::default(),
8693            _additional_params: Default::default(),
8694            _scopes: Default::default(),
8695        }
8696    }
8697
8698    /// Create a builder to help you perform the following task:
8699    ///
8700    /// Updates an existing advertiser group. This method supports patch semantics.
8701    ///
8702    /// # Arguments
8703    ///
8704    /// * `request` - No description provided.
8705    /// * `profileId` - User profile ID associated with this request.
8706    /// * `id` - Advertiser group ID.
8707    pub fn patch(
8708        &self,
8709        request: AdvertiserGroup,
8710        profile_id: i64,
8711        id: i64,
8712    ) -> AdvertiserGroupPatchCall<'a, C> {
8713        AdvertiserGroupPatchCall {
8714            hub: self.hub,
8715            _request: request,
8716            _profile_id: profile_id,
8717            _id: id,
8718            _delegate: Default::default(),
8719            _additional_params: Default::default(),
8720            _scopes: Default::default(),
8721        }
8722    }
8723
8724    /// Create a builder to help you perform the following task:
8725    ///
8726    /// Updates an existing advertiser group.
8727    ///
8728    /// # Arguments
8729    ///
8730    /// * `request` - No description provided.
8731    /// * `profileId` - User profile ID associated with this request.
8732    pub fn update(
8733        &self,
8734        request: AdvertiserGroup,
8735        profile_id: i64,
8736    ) -> AdvertiserGroupUpdateCall<'a, C> {
8737        AdvertiserGroupUpdateCall {
8738            hub: self.hub,
8739            _request: request,
8740            _profile_id: profile_id,
8741            _delegate: Default::default(),
8742            _additional_params: Default::default(),
8743            _scopes: Default::default(),
8744        }
8745    }
8746}
8747
8748/// A builder providing access to all methods supported on *advertiserLandingPage* resources.
8749/// It is not used directly, but through the [`Dfareporting`] hub.
8750///
8751/// # Example
8752///
8753/// Instantiate a resource builder
8754///
8755/// ```test_harness,no_run
8756/// extern crate hyper;
8757/// extern crate hyper_rustls;
8758/// extern crate google_dfareporting3d2 as dfareporting3d2;
8759///
8760/// # async fn dox() {
8761/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8762///
8763/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8764/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8765///     secret,
8766///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8767/// ).build().await.unwrap();
8768///
8769/// let client = hyper_util::client::legacy::Client::builder(
8770///     hyper_util::rt::TokioExecutor::new()
8771/// )
8772/// .build(
8773///     hyper_rustls::HttpsConnectorBuilder::new()
8774///         .with_native_roots()
8775///         .unwrap()
8776///         .https_or_http()
8777///         .enable_http1()
8778///         .build()
8779/// );
8780/// let mut hub = Dfareporting::new(client, auth);
8781/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8782/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
8783/// // to build up your call.
8784/// let rb = hub.advertiser_landing_pages();
8785/// # }
8786/// ```
8787pub struct AdvertiserLandingPageMethods<'a, C>
8788where
8789    C: 'a,
8790{
8791    hub: &'a Dfareporting<C>,
8792}
8793
8794impl<'a, C> common::MethodsBuilder for AdvertiserLandingPageMethods<'a, C> {}
8795
8796impl<'a, C> AdvertiserLandingPageMethods<'a, C> {
8797    /// Create a builder to help you perform the following task:
8798    ///
8799    /// Gets one landing page by ID.
8800    ///
8801    /// # Arguments
8802    ///
8803    /// * `profileId` - User profile ID associated with this request.
8804    /// * `id` - Landing page ID.
8805    pub fn get(&self, profile_id: i64, id: i64) -> AdvertiserLandingPageGetCall<'a, C> {
8806        AdvertiserLandingPageGetCall {
8807            hub: self.hub,
8808            _profile_id: profile_id,
8809            _id: id,
8810            _delegate: Default::default(),
8811            _additional_params: Default::default(),
8812            _scopes: Default::default(),
8813        }
8814    }
8815
8816    /// Create a builder to help you perform the following task:
8817    ///
8818    /// Inserts a new landing page.
8819    ///
8820    /// # Arguments
8821    ///
8822    /// * `request` - No description provided.
8823    /// * `profileId` - User profile ID associated with this request.
8824    pub fn insert(
8825        &self,
8826        request: LandingPage,
8827        profile_id: i64,
8828    ) -> AdvertiserLandingPageInsertCall<'a, C> {
8829        AdvertiserLandingPageInsertCall {
8830            hub: self.hub,
8831            _request: request,
8832            _profile_id: profile_id,
8833            _delegate: Default::default(),
8834            _additional_params: Default::default(),
8835            _scopes: Default::default(),
8836        }
8837    }
8838
8839    /// Create a builder to help you perform the following task:
8840    ///
8841    /// Retrieves a list of landing pages.
8842    ///
8843    /// # Arguments
8844    ///
8845    /// * `profileId` - User profile ID associated with this request.
8846    pub fn list(&self, profile_id: i64) -> AdvertiserLandingPageListCall<'a, C> {
8847        AdvertiserLandingPageListCall {
8848            hub: self.hub,
8849            _profile_id: profile_id,
8850            _subaccount_id: Default::default(),
8851            _sort_order: Default::default(),
8852            _sort_field: Default::default(),
8853            _search_string: Default::default(),
8854            _page_token: Default::default(),
8855            _max_results: Default::default(),
8856            _ids: Default::default(),
8857            _campaign_ids: Default::default(),
8858            _archived: Default::default(),
8859            _advertiser_ids: Default::default(),
8860            _delegate: Default::default(),
8861            _additional_params: Default::default(),
8862            _scopes: Default::default(),
8863        }
8864    }
8865
8866    /// Create a builder to help you perform the following task:
8867    ///
8868    /// Updates an existing landing page. This method supports patch semantics.
8869    ///
8870    /// # Arguments
8871    ///
8872    /// * `request` - No description provided.
8873    /// * `profileId` - User profile ID associated with this request.
8874    /// * `id` - Landing page ID.
8875    pub fn patch(
8876        &self,
8877        request: LandingPage,
8878        profile_id: i64,
8879        id: i64,
8880    ) -> AdvertiserLandingPagePatchCall<'a, C> {
8881        AdvertiserLandingPagePatchCall {
8882            hub: self.hub,
8883            _request: request,
8884            _profile_id: profile_id,
8885            _id: id,
8886            _delegate: Default::default(),
8887            _additional_params: Default::default(),
8888            _scopes: Default::default(),
8889        }
8890    }
8891
8892    /// Create a builder to help you perform the following task:
8893    ///
8894    /// Updates an existing landing page.
8895    ///
8896    /// # Arguments
8897    ///
8898    /// * `request` - No description provided.
8899    /// * `profileId` - User profile ID associated with this request.
8900    pub fn update(
8901        &self,
8902        request: LandingPage,
8903        profile_id: i64,
8904    ) -> AdvertiserLandingPageUpdateCall<'a, C> {
8905        AdvertiserLandingPageUpdateCall {
8906            hub: self.hub,
8907            _request: request,
8908            _profile_id: profile_id,
8909            _delegate: Default::default(),
8910            _additional_params: Default::default(),
8911            _scopes: Default::default(),
8912        }
8913    }
8914}
8915
8916/// A builder providing access to all methods supported on *advertiser* resources.
8917/// It is not used directly, but through the [`Dfareporting`] hub.
8918///
8919/// # Example
8920///
8921/// Instantiate a resource builder
8922///
8923/// ```test_harness,no_run
8924/// extern crate hyper;
8925/// extern crate hyper_rustls;
8926/// extern crate google_dfareporting3d2 as dfareporting3d2;
8927///
8928/// # async fn dox() {
8929/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8930///
8931/// let secret: yup_oauth2::ApplicationSecret = Default::default();
8932/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8933///     secret,
8934///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8935/// ).build().await.unwrap();
8936///
8937/// let client = hyper_util::client::legacy::Client::builder(
8938///     hyper_util::rt::TokioExecutor::new()
8939/// )
8940/// .build(
8941///     hyper_rustls::HttpsConnectorBuilder::new()
8942///         .with_native_roots()
8943///         .unwrap()
8944///         .https_or_http()
8945///         .enable_http1()
8946///         .build()
8947/// );
8948/// let mut hub = Dfareporting::new(client, auth);
8949/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
8950/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
8951/// // to build up your call.
8952/// let rb = hub.advertisers();
8953/// # }
8954/// ```
8955pub struct AdvertiserMethods<'a, C>
8956where
8957    C: 'a,
8958{
8959    hub: &'a Dfareporting<C>,
8960}
8961
8962impl<'a, C> common::MethodsBuilder for AdvertiserMethods<'a, C> {}
8963
8964impl<'a, C> AdvertiserMethods<'a, C> {
8965    /// Create a builder to help you perform the following task:
8966    ///
8967    /// Gets one advertiser by ID.
8968    ///
8969    /// # Arguments
8970    ///
8971    /// * `profileId` - User profile ID associated with this request.
8972    /// * `id` - Advertiser ID.
8973    pub fn get(&self, profile_id: i64, id: i64) -> AdvertiserGetCall<'a, C> {
8974        AdvertiserGetCall {
8975            hub: self.hub,
8976            _profile_id: profile_id,
8977            _id: id,
8978            _delegate: Default::default(),
8979            _additional_params: Default::default(),
8980            _scopes: Default::default(),
8981        }
8982    }
8983
8984    /// Create a builder to help you perform the following task:
8985    ///
8986    /// Inserts a new advertiser.
8987    ///
8988    /// # Arguments
8989    ///
8990    /// * `request` - No description provided.
8991    /// * `profileId` - User profile ID associated with this request.
8992    pub fn insert(&self, request: Advertiser, profile_id: i64) -> AdvertiserInsertCall<'a, C> {
8993        AdvertiserInsertCall {
8994            hub: self.hub,
8995            _request: request,
8996            _profile_id: profile_id,
8997            _delegate: Default::default(),
8998            _additional_params: Default::default(),
8999            _scopes: Default::default(),
9000        }
9001    }
9002
9003    /// Create a builder to help you perform the following task:
9004    ///
9005    /// Retrieves a list of advertisers, possibly filtered. This method supports paging.
9006    ///
9007    /// # Arguments
9008    ///
9009    /// * `profileId` - User profile ID associated with this request.
9010    pub fn list(&self, profile_id: i64) -> AdvertiserListCall<'a, C> {
9011        AdvertiserListCall {
9012            hub: self.hub,
9013            _profile_id: profile_id,
9014            _subaccount_id: Default::default(),
9015            _status: Default::default(),
9016            _sort_order: Default::default(),
9017            _sort_field: Default::default(),
9018            _search_string: Default::default(),
9019            _page_token: Default::default(),
9020            _only_parent: Default::default(),
9021            _max_results: Default::default(),
9022            _include_advertisers_without_groups_only: Default::default(),
9023            _ids: Default::default(),
9024            _floodlight_configuration_ids: Default::default(),
9025            _advertiser_group_ids: Default::default(),
9026            _delegate: Default::default(),
9027            _additional_params: Default::default(),
9028            _scopes: Default::default(),
9029        }
9030    }
9031
9032    /// Create a builder to help you perform the following task:
9033    ///
9034    /// Updates an existing advertiser. This method supports patch semantics.
9035    ///
9036    /// # Arguments
9037    ///
9038    /// * `request` - No description provided.
9039    /// * `profileId` - User profile ID associated with this request.
9040    /// * `id` - Advertiser ID.
9041    pub fn patch(
9042        &self,
9043        request: Advertiser,
9044        profile_id: i64,
9045        id: i64,
9046    ) -> AdvertiserPatchCall<'a, C> {
9047        AdvertiserPatchCall {
9048            hub: self.hub,
9049            _request: request,
9050            _profile_id: profile_id,
9051            _id: id,
9052            _delegate: Default::default(),
9053            _additional_params: Default::default(),
9054            _scopes: Default::default(),
9055        }
9056    }
9057
9058    /// Create a builder to help you perform the following task:
9059    ///
9060    /// Updates an existing advertiser.
9061    ///
9062    /// # Arguments
9063    ///
9064    /// * `request` - No description provided.
9065    /// * `profileId` - User profile ID associated with this request.
9066    pub fn update(&self, request: Advertiser, profile_id: i64) -> AdvertiserUpdateCall<'a, C> {
9067        AdvertiserUpdateCall {
9068            hub: self.hub,
9069            _request: request,
9070            _profile_id: profile_id,
9071            _delegate: Default::default(),
9072            _additional_params: Default::default(),
9073            _scopes: Default::default(),
9074        }
9075    }
9076}
9077
9078/// A builder providing access to all methods supported on *browser* resources.
9079/// It is not used directly, but through the [`Dfareporting`] hub.
9080///
9081/// # Example
9082///
9083/// Instantiate a resource builder
9084///
9085/// ```test_harness,no_run
9086/// extern crate hyper;
9087/// extern crate hyper_rustls;
9088/// extern crate google_dfareporting3d2 as dfareporting3d2;
9089///
9090/// # async fn dox() {
9091/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9092///
9093/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9094/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9095///     secret,
9096///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9097/// ).build().await.unwrap();
9098///
9099/// let client = hyper_util::client::legacy::Client::builder(
9100///     hyper_util::rt::TokioExecutor::new()
9101/// )
9102/// .build(
9103///     hyper_rustls::HttpsConnectorBuilder::new()
9104///         .with_native_roots()
9105///         .unwrap()
9106///         .https_or_http()
9107///         .enable_http1()
9108///         .build()
9109/// );
9110/// let mut hub = Dfareporting::new(client, auth);
9111/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9112/// // like `list(...)`
9113/// // to build up your call.
9114/// let rb = hub.browsers();
9115/// # }
9116/// ```
9117pub struct BrowserMethods<'a, C>
9118where
9119    C: 'a,
9120{
9121    hub: &'a Dfareporting<C>,
9122}
9123
9124impl<'a, C> common::MethodsBuilder for BrowserMethods<'a, C> {}
9125
9126impl<'a, C> BrowserMethods<'a, C> {
9127    /// Create a builder to help you perform the following task:
9128    ///
9129    /// Retrieves a list of browsers.
9130    ///
9131    /// # Arguments
9132    ///
9133    /// * `profileId` - User profile ID associated with this request.
9134    pub fn list(&self, profile_id: i64) -> BrowserListCall<'a, C> {
9135        BrowserListCall {
9136            hub: self.hub,
9137            _profile_id: profile_id,
9138            _delegate: Default::default(),
9139            _additional_params: Default::default(),
9140            _scopes: Default::default(),
9141        }
9142    }
9143}
9144
9145/// A builder providing access to all methods supported on *campaignCreativeAssociation* resources.
9146/// It is not used directly, but through the [`Dfareporting`] hub.
9147///
9148/// # Example
9149///
9150/// Instantiate a resource builder
9151///
9152/// ```test_harness,no_run
9153/// extern crate hyper;
9154/// extern crate hyper_rustls;
9155/// extern crate google_dfareporting3d2 as dfareporting3d2;
9156///
9157/// # async fn dox() {
9158/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9159///
9160/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9161/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9162///     secret,
9163///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9164/// ).build().await.unwrap();
9165///
9166/// let client = hyper_util::client::legacy::Client::builder(
9167///     hyper_util::rt::TokioExecutor::new()
9168/// )
9169/// .build(
9170///     hyper_rustls::HttpsConnectorBuilder::new()
9171///         .with_native_roots()
9172///         .unwrap()
9173///         .https_or_http()
9174///         .enable_http1()
9175///         .build()
9176/// );
9177/// let mut hub = Dfareporting::new(client, auth);
9178/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9179/// // like `insert(...)` and `list(...)`
9180/// // to build up your call.
9181/// let rb = hub.campaign_creative_associations();
9182/// # }
9183/// ```
9184pub struct CampaignCreativeAssociationMethods<'a, C>
9185where
9186    C: 'a,
9187{
9188    hub: &'a Dfareporting<C>,
9189}
9190
9191impl<'a, C> common::MethodsBuilder for CampaignCreativeAssociationMethods<'a, C> {}
9192
9193impl<'a, C> CampaignCreativeAssociationMethods<'a, C> {
9194    /// Create a builder to help you perform the following task:
9195    ///
9196    /// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already.
9197    ///
9198    /// # Arguments
9199    ///
9200    /// * `request` - No description provided.
9201    /// * `profileId` - User profile ID associated with this request.
9202    /// * `campaignId` - Campaign ID in this association.
9203    pub fn insert(
9204        &self,
9205        request: CampaignCreativeAssociation,
9206        profile_id: i64,
9207        campaign_id: i64,
9208    ) -> CampaignCreativeAssociationInsertCall<'a, C> {
9209        CampaignCreativeAssociationInsertCall {
9210            hub: self.hub,
9211            _request: request,
9212            _profile_id: profile_id,
9213            _campaign_id: campaign_id,
9214            _delegate: Default::default(),
9215            _additional_params: Default::default(),
9216            _scopes: Default::default(),
9217        }
9218    }
9219
9220    /// Create a builder to help you perform the following task:
9221    ///
9222    /// Retrieves the list of creative IDs associated with the specified campaign. This method supports paging.
9223    ///
9224    /// # Arguments
9225    ///
9226    /// * `profileId` - User profile ID associated with this request.
9227    /// * `campaignId` - Campaign ID in this association.
9228    pub fn list(
9229        &self,
9230        profile_id: i64,
9231        campaign_id: i64,
9232    ) -> CampaignCreativeAssociationListCall<'a, C> {
9233        CampaignCreativeAssociationListCall {
9234            hub: self.hub,
9235            _profile_id: profile_id,
9236            _campaign_id: campaign_id,
9237            _sort_order: Default::default(),
9238            _page_token: Default::default(),
9239            _max_results: Default::default(),
9240            _delegate: Default::default(),
9241            _additional_params: Default::default(),
9242            _scopes: Default::default(),
9243        }
9244    }
9245}
9246
9247/// A builder providing access to all methods supported on *campaign* resources.
9248/// It is not used directly, but through the [`Dfareporting`] hub.
9249///
9250/// # Example
9251///
9252/// Instantiate a resource builder
9253///
9254/// ```test_harness,no_run
9255/// extern crate hyper;
9256/// extern crate hyper_rustls;
9257/// extern crate google_dfareporting3d2 as dfareporting3d2;
9258///
9259/// # async fn dox() {
9260/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9261///
9262/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9263/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9264///     secret,
9265///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9266/// ).build().await.unwrap();
9267///
9268/// let client = hyper_util::client::legacy::Client::builder(
9269///     hyper_util::rt::TokioExecutor::new()
9270/// )
9271/// .build(
9272///     hyper_rustls::HttpsConnectorBuilder::new()
9273///         .with_native_roots()
9274///         .unwrap()
9275///         .https_or_http()
9276///         .enable_http1()
9277///         .build()
9278/// );
9279/// let mut hub = Dfareporting::new(client, auth);
9280/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9281/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
9282/// // to build up your call.
9283/// let rb = hub.campaigns();
9284/// # }
9285/// ```
9286pub struct CampaignMethods<'a, C>
9287where
9288    C: 'a,
9289{
9290    hub: &'a Dfareporting<C>,
9291}
9292
9293impl<'a, C> common::MethodsBuilder for CampaignMethods<'a, C> {}
9294
9295impl<'a, C> CampaignMethods<'a, C> {
9296    /// Create a builder to help you perform the following task:
9297    ///
9298    /// Gets one campaign by ID.
9299    ///
9300    /// # Arguments
9301    ///
9302    /// * `profileId` - User profile ID associated with this request.
9303    /// * `id` - Campaign ID.
9304    pub fn get(&self, profile_id: i64, id: i64) -> CampaignGetCall<'a, C> {
9305        CampaignGetCall {
9306            hub: self.hub,
9307            _profile_id: profile_id,
9308            _id: id,
9309            _delegate: Default::default(),
9310            _additional_params: Default::default(),
9311            _scopes: Default::default(),
9312        }
9313    }
9314
9315    /// Create a builder to help you perform the following task:
9316    ///
9317    /// Inserts a new campaign.
9318    ///
9319    /// # Arguments
9320    ///
9321    /// * `request` - No description provided.
9322    /// * `profileId` - User profile ID associated with this request.
9323    pub fn insert(&self, request: Campaign, profile_id: i64) -> CampaignInsertCall<'a, C> {
9324        CampaignInsertCall {
9325            hub: self.hub,
9326            _request: request,
9327            _profile_id: profile_id,
9328            _delegate: Default::default(),
9329            _additional_params: Default::default(),
9330            _scopes: Default::default(),
9331        }
9332    }
9333
9334    /// Create a builder to help you perform the following task:
9335    ///
9336    /// Retrieves a list of campaigns, possibly filtered. This method supports paging.
9337    ///
9338    /// # Arguments
9339    ///
9340    /// * `profileId` - User profile ID associated with this request.
9341    pub fn list(&self, profile_id: i64) -> CampaignListCall<'a, C> {
9342        CampaignListCall {
9343            hub: self.hub,
9344            _profile_id: profile_id,
9345            _subaccount_id: Default::default(),
9346            _sort_order: Default::default(),
9347            _sort_field: Default::default(),
9348            _search_string: Default::default(),
9349            _page_token: Default::default(),
9350            _overridden_event_tag_id: Default::default(),
9351            _max_results: Default::default(),
9352            _ids: Default::default(),
9353            _excluded_ids: Default::default(),
9354            _at_least_one_optimization_activity: Default::default(),
9355            _archived: Default::default(),
9356            _advertiser_ids: Default::default(),
9357            _advertiser_group_ids: Default::default(),
9358            _delegate: Default::default(),
9359            _additional_params: Default::default(),
9360            _scopes: Default::default(),
9361        }
9362    }
9363
9364    /// Create a builder to help you perform the following task:
9365    ///
9366    /// Updates an existing campaign. This method supports patch semantics.
9367    ///
9368    /// # Arguments
9369    ///
9370    /// * `request` - No description provided.
9371    /// * `profileId` - User profile ID associated with this request.
9372    /// * `id` - Campaign ID.
9373    pub fn patch(&self, request: Campaign, profile_id: i64, id: i64) -> CampaignPatchCall<'a, C> {
9374        CampaignPatchCall {
9375            hub: self.hub,
9376            _request: request,
9377            _profile_id: profile_id,
9378            _id: id,
9379            _delegate: Default::default(),
9380            _additional_params: Default::default(),
9381            _scopes: Default::default(),
9382        }
9383    }
9384
9385    /// Create a builder to help you perform the following task:
9386    ///
9387    /// Updates an existing campaign.
9388    ///
9389    /// # Arguments
9390    ///
9391    /// * `request` - No description provided.
9392    /// * `profileId` - User profile ID associated with this request.
9393    pub fn update(&self, request: Campaign, profile_id: i64) -> CampaignUpdateCall<'a, C> {
9394        CampaignUpdateCall {
9395            hub: self.hub,
9396            _request: request,
9397            _profile_id: profile_id,
9398            _delegate: Default::default(),
9399            _additional_params: Default::default(),
9400            _scopes: Default::default(),
9401        }
9402    }
9403}
9404
9405/// A builder providing access to all methods supported on *changeLog* resources.
9406/// It is not used directly, but through the [`Dfareporting`] hub.
9407///
9408/// # Example
9409///
9410/// Instantiate a resource builder
9411///
9412/// ```test_harness,no_run
9413/// extern crate hyper;
9414/// extern crate hyper_rustls;
9415/// extern crate google_dfareporting3d2 as dfareporting3d2;
9416///
9417/// # async fn dox() {
9418/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9419///
9420/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9421/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9422///     secret,
9423///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9424/// ).build().await.unwrap();
9425///
9426/// let client = hyper_util::client::legacy::Client::builder(
9427///     hyper_util::rt::TokioExecutor::new()
9428/// )
9429/// .build(
9430///     hyper_rustls::HttpsConnectorBuilder::new()
9431///         .with_native_roots()
9432///         .unwrap()
9433///         .https_or_http()
9434///         .enable_http1()
9435///         .build()
9436/// );
9437/// let mut hub = Dfareporting::new(client, auth);
9438/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9439/// // like `get(...)` and `list(...)`
9440/// // to build up your call.
9441/// let rb = hub.change_logs();
9442/// # }
9443/// ```
9444pub struct ChangeLogMethods<'a, C>
9445where
9446    C: 'a,
9447{
9448    hub: &'a Dfareporting<C>,
9449}
9450
9451impl<'a, C> common::MethodsBuilder for ChangeLogMethods<'a, C> {}
9452
9453impl<'a, C> ChangeLogMethods<'a, C> {
9454    /// Create a builder to help you perform the following task:
9455    ///
9456    /// Gets one change log by ID.
9457    ///
9458    /// # Arguments
9459    ///
9460    /// * `profileId` - User profile ID associated with this request.
9461    /// * `id` - Change log ID.
9462    pub fn get(&self, profile_id: i64, id: i64) -> ChangeLogGetCall<'a, C> {
9463        ChangeLogGetCall {
9464            hub: self.hub,
9465            _profile_id: profile_id,
9466            _id: id,
9467            _delegate: Default::default(),
9468            _additional_params: Default::default(),
9469            _scopes: Default::default(),
9470        }
9471    }
9472
9473    /// Create a builder to help you perform the following task:
9474    ///
9475    /// Retrieves a list of change logs. This method supports paging.
9476    ///
9477    /// # Arguments
9478    ///
9479    /// * `profileId` - User profile ID associated with this request.
9480    pub fn list(&self, profile_id: i64) -> ChangeLogListCall<'a, C> {
9481        ChangeLogListCall {
9482            hub: self.hub,
9483            _profile_id: profile_id,
9484            _user_profile_ids: Default::default(),
9485            _search_string: Default::default(),
9486            _page_token: Default::default(),
9487            _object_type: Default::default(),
9488            _object_ids: Default::default(),
9489            _min_change_time: Default::default(),
9490            _max_results: Default::default(),
9491            _max_change_time: Default::default(),
9492            _ids: Default::default(),
9493            _action: Default::default(),
9494            _delegate: Default::default(),
9495            _additional_params: Default::default(),
9496            _scopes: Default::default(),
9497        }
9498    }
9499}
9500
9501/// A builder providing access to all methods supported on *city* resources.
9502/// It is not used directly, but through the [`Dfareporting`] hub.
9503///
9504/// # Example
9505///
9506/// Instantiate a resource builder
9507///
9508/// ```test_harness,no_run
9509/// extern crate hyper;
9510/// extern crate hyper_rustls;
9511/// extern crate google_dfareporting3d2 as dfareporting3d2;
9512///
9513/// # async fn dox() {
9514/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9515///
9516/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9517/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9518///     secret,
9519///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9520/// ).build().await.unwrap();
9521///
9522/// let client = hyper_util::client::legacy::Client::builder(
9523///     hyper_util::rt::TokioExecutor::new()
9524/// )
9525/// .build(
9526///     hyper_rustls::HttpsConnectorBuilder::new()
9527///         .with_native_roots()
9528///         .unwrap()
9529///         .https_or_http()
9530///         .enable_http1()
9531///         .build()
9532/// );
9533/// let mut hub = Dfareporting::new(client, auth);
9534/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9535/// // like `list(...)`
9536/// // to build up your call.
9537/// let rb = hub.cities();
9538/// # }
9539/// ```
9540pub struct CityMethods<'a, C>
9541where
9542    C: 'a,
9543{
9544    hub: &'a Dfareporting<C>,
9545}
9546
9547impl<'a, C> common::MethodsBuilder for CityMethods<'a, C> {}
9548
9549impl<'a, C> CityMethods<'a, C> {
9550    /// Create a builder to help you perform the following task:
9551    ///
9552    /// Retrieves a list of cities, possibly filtered.
9553    ///
9554    /// # Arguments
9555    ///
9556    /// * `profileId` - User profile ID associated with this request.
9557    pub fn list(&self, profile_id: i64) -> CityListCall<'a, C> {
9558        CityListCall {
9559            hub: self.hub,
9560            _profile_id: profile_id,
9561            _region_dart_ids: Default::default(),
9562            _name_prefix: Default::default(),
9563            _dart_ids: Default::default(),
9564            _country_dart_ids: Default::default(),
9565            _delegate: Default::default(),
9566            _additional_params: Default::default(),
9567            _scopes: Default::default(),
9568        }
9569    }
9570}
9571
9572/// A builder providing access to all methods supported on *connectionType* resources.
9573/// It is not used directly, but through the [`Dfareporting`] hub.
9574///
9575/// # Example
9576///
9577/// Instantiate a resource builder
9578///
9579/// ```test_harness,no_run
9580/// extern crate hyper;
9581/// extern crate hyper_rustls;
9582/// extern crate google_dfareporting3d2 as dfareporting3d2;
9583///
9584/// # async fn dox() {
9585/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9586///
9587/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9588/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9589///     secret,
9590///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9591/// ).build().await.unwrap();
9592///
9593/// let client = hyper_util::client::legacy::Client::builder(
9594///     hyper_util::rt::TokioExecutor::new()
9595/// )
9596/// .build(
9597///     hyper_rustls::HttpsConnectorBuilder::new()
9598///         .with_native_roots()
9599///         .unwrap()
9600///         .https_or_http()
9601///         .enable_http1()
9602///         .build()
9603/// );
9604/// let mut hub = Dfareporting::new(client, auth);
9605/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9606/// // like `get(...)` and `list(...)`
9607/// // to build up your call.
9608/// let rb = hub.connection_types();
9609/// # }
9610/// ```
9611pub struct ConnectionTypeMethods<'a, C>
9612where
9613    C: 'a,
9614{
9615    hub: &'a Dfareporting<C>,
9616}
9617
9618impl<'a, C> common::MethodsBuilder for ConnectionTypeMethods<'a, C> {}
9619
9620impl<'a, C> ConnectionTypeMethods<'a, C> {
9621    /// Create a builder to help you perform the following task:
9622    ///
9623    /// Gets one connection type by ID.
9624    ///
9625    /// # Arguments
9626    ///
9627    /// * `profileId` - User profile ID associated with this request.
9628    /// * `id` - Connection type ID.
9629    pub fn get(&self, profile_id: i64, id: i64) -> ConnectionTypeGetCall<'a, C> {
9630        ConnectionTypeGetCall {
9631            hub: self.hub,
9632            _profile_id: profile_id,
9633            _id: id,
9634            _delegate: Default::default(),
9635            _additional_params: Default::default(),
9636            _scopes: Default::default(),
9637        }
9638    }
9639
9640    /// Create a builder to help you perform the following task:
9641    ///
9642    /// Retrieves a list of connection types.
9643    ///
9644    /// # Arguments
9645    ///
9646    /// * `profileId` - User profile ID associated with this request.
9647    pub fn list(&self, profile_id: i64) -> ConnectionTypeListCall<'a, C> {
9648        ConnectionTypeListCall {
9649            hub: self.hub,
9650            _profile_id: profile_id,
9651            _delegate: Default::default(),
9652            _additional_params: Default::default(),
9653            _scopes: Default::default(),
9654        }
9655    }
9656}
9657
9658/// A builder providing access to all methods supported on *contentCategory* resources.
9659/// It is not used directly, but through the [`Dfareporting`] hub.
9660///
9661/// # Example
9662///
9663/// Instantiate a resource builder
9664///
9665/// ```test_harness,no_run
9666/// extern crate hyper;
9667/// extern crate hyper_rustls;
9668/// extern crate google_dfareporting3d2 as dfareporting3d2;
9669///
9670/// # async fn dox() {
9671/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9672///
9673/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9674/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9675///     secret,
9676///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9677/// ).build().await.unwrap();
9678///
9679/// let client = hyper_util::client::legacy::Client::builder(
9680///     hyper_util::rt::TokioExecutor::new()
9681/// )
9682/// .build(
9683///     hyper_rustls::HttpsConnectorBuilder::new()
9684///         .with_native_roots()
9685///         .unwrap()
9686///         .https_or_http()
9687///         .enable_http1()
9688///         .build()
9689/// );
9690/// let mut hub = Dfareporting::new(client, auth);
9691/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9692/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
9693/// // to build up your call.
9694/// let rb = hub.content_categories();
9695/// # }
9696/// ```
9697pub struct ContentCategoryMethods<'a, C>
9698where
9699    C: 'a,
9700{
9701    hub: &'a Dfareporting<C>,
9702}
9703
9704impl<'a, C> common::MethodsBuilder for ContentCategoryMethods<'a, C> {}
9705
9706impl<'a, C> ContentCategoryMethods<'a, C> {
9707    /// Create a builder to help you perform the following task:
9708    ///
9709    /// Deletes an existing content category.
9710    ///
9711    /// # Arguments
9712    ///
9713    /// * `profileId` - User profile ID associated with this request.
9714    /// * `id` - Content category ID.
9715    pub fn delete(&self, profile_id: i64, id: i64) -> ContentCategoryDeleteCall<'a, C> {
9716        ContentCategoryDeleteCall {
9717            hub: self.hub,
9718            _profile_id: profile_id,
9719            _id: id,
9720            _delegate: Default::default(),
9721            _additional_params: Default::default(),
9722            _scopes: Default::default(),
9723        }
9724    }
9725
9726    /// Create a builder to help you perform the following task:
9727    ///
9728    /// Gets one content category by ID.
9729    ///
9730    /// # Arguments
9731    ///
9732    /// * `profileId` - User profile ID associated with this request.
9733    /// * `id` - Content category ID.
9734    pub fn get(&self, profile_id: i64, id: i64) -> ContentCategoryGetCall<'a, C> {
9735        ContentCategoryGetCall {
9736            hub: self.hub,
9737            _profile_id: profile_id,
9738            _id: id,
9739            _delegate: Default::default(),
9740            _additional_params: Default::default(),
9741            _scopes: Default::default(),
9742        }
9743    }
9744
9745    /// Create a builder to help you perform the following task:
9746    ///
9747    /// Inserts a new content category.
9748    ///
9749    /// # Arguments
9750    ///
9751    /// * `request` - No description provided.
9752    /// * `profileId` - User profile ID associated with this request.
9753    pub fn insert(
9754        &self,
9755        request: ContentCategory,
9756        profile_id: i64,
9757    ) -> ContentCategoryInsertCall<'a, C> {
9758        ContentCategoryInsertCall {
9759            hub: self.hub,
9760            _request: request,
9761            _profile_id: profile_id,
9762            _delegate: Default::default(),
9763            _additional_params: Default::default(),
9764            _scopes: Default::default(),
9765        }
9766    }
9767
9768    /// Create a builder to help you perform the following task:
9769    ///
9770    /// Retrieves a list of content categories, possibly filtered. This method supports paging.
9771    ///
9772    /// # Arguments
9773    ///
9774    /// * `profileId` - User profile ID associated with this request.
9775    pub fn list(&self, profile_id: i64) -> ContentCategoryListCall<'a, C> {
9776        ContentCategoryListCall {
9777            hub: self.hub,
9778            _profile_id: profile_id,
9779            _sort_order: Default::default(),
9780            _sort_field: Default::default(),
9781            _search_string: Default::default(),
9782            _page_token: Default::default(),
9783            _max_results: Default::default(),
9784            _ids: Default::default(),
9785            _delegate: Default::default(),
9786            _additional_params: Default::default(),
9787            _scopes: Default::default(),
9788        }
9789    }
9790
9791    /// Create a builder to help you perform the following task:
9792    ///
9793    /// Updates an existing content category. This method supports patch semantics.
9794    ///
9795    /// # Arguments
9796    ///
9797    /// * `request` - No description provided.
9798    /// * `profileId` - User profile ID associated with this request.
9799    /// * `id` - Content category ID.
9800    pub fn patch(
9801        &self,
9802        request: ContentCategory,
9803        profile_id: i64,
9804        id: i64,
9805    ) -> ContentCategoryPatchCall<'a, C> {
9806        ContentCategoryPatchCall {
9807            hub: self.hub,
9808            _request: request,
9809            _profile_id: profile_id,
9810            _id: id,
9811            _delegate: Default::default(),
9812            _additional_params: Default::default(),
9813            _scopes: Default::default(),
9814        }
9815    }
9816
9817    /// Create a builder to help you perform the following task:
9818    ///
9819    /// Updates an existing content category.
9820    ///
9821    /// # Arguments
9822    ///
9823    /// * `request` - No description provided.
9824    /// * `profileId` - User profile ID associated with this request.
9825    pub fn update(
9826        &self,
9827        request: ContentCategory,
9828        profile_id: i64,
9829    ) -> ContentCategoryUpdateCall<'a, C> {
9830        ContentCategoryUpdateCall {
9831            hub: self.hub,
9832            _request: request,
9833            _profile_id: profile_id,
9834            _delegate: Default::default(),
9835            _additional_params: Default::default(),
9836            _scopes: Default::default(),
9837        }
9838    }
9839}
9840
9841/// A builder providing access to all methods supported on *conversion* resources.
9842/// It is not used directly, but through the [`Dfareporting`] hub.
9843///
9844/// # Example
9845///
9846/// Instantiate a resource builder
9847///
9848/// ```test_harness,no_run
9849/// extern crate hyper;
9850/// extern crate hyper_rustls;
9851/// extern crate google_dfareporting3d2 as dfareporting3d2;
9852///
9853/// # async fn dox() {
9854/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9855///
9856/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9857/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9858///     secret,
9859///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9860/// ).build().await.unwrap();
9861///
9862/// let client = hyper_util::client::legacy::Client::builder(
9863///     hyper_util::rt::TokioExecutor::new()
9864/// )
9865/// .build(
9866///     hyper_rustls::HttpsConnectorBuilder::new()
9867///         .with_native_roots()
9868///         .unwrap()
9869///         .https_or_http()
9870///         .enable_http1()
9871///         .build()
9872/// );
9873/// let mut hub = Dfareporting::new(client, auth);
9874/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9875/// // like `batchinsert(...)` and `batchupdate(...)`
9876/// // to build up your call.
9877/// let rb = hub.conversions();
9878/// # }
9879/// ```
9880pub struct ConversionMethods<'a, C>
9881where
9882    C: 'a,
9883{
9884    hub: &'a Dfareporting<C>,
9885}
9886
9887impl<'a, C> common::MethodsBuilder for ConversionMethods<'a, C> {}
9888
9889impl<'a, C> ConversionMethods<'a, C> {
9890    /// Create a builder to help you perform the following task:
9891    ///
9892    /// Inserts conversions.
9893    ///
9894    /// # Arguments
9895    ///
9896    /// * `request` - No description provided.
9897    /// * `profileId` - User profile ID associated with this request.
9898    pub fn batchinsert(
9899        &self,
9900        request: ConversionsBatchInsertRequest,
9901        profile_id: i64,
9902    ) -> ConversionBatchinsertCall<'a, C> {
9903        ConversionBatchinsertCall {
9904            hub: self.hub,
9905            _request: request,
9906            _profile_id: profile_id,
9907            _delegate: Default::default(),
9908            _additional_params: Default::default(),
9909            _scopes: Default::default(),
9910        }
9911    }
9912
9913    /// Create a builder to help you perform the following task:
9914    ///
9915    /// Updates existing conversions.
9916    ///
9917    /// # Arguments
9918    ///
9919    /// * `request` - No description provided.
9920    /// * `profileId` - User profile ID associated with this request.
9921    pub fn batchupdate(
9922        &self,
9923        request: ConversionsBatchUpdateRequest,
9924        profile_id: i64,
9925    ) -> ConversionBatchupdateCall<'a, C> {
9926        ConversionBatchupdateCall {
9927            hub: self.hub,
9928            _request: request,
9929            _profile_id: profile_id,
9930            _delegate: Default::default(),
9931            _additional_params: Default::default(),
9932            _scopes: Default::default(),
9933        }
9934    }
9935}
9936
9937/// A builder providing access to all methods supported on *country* resources.
9938/// It is not used directly, but through the [`Dfareporting`] hub.
9939///
9940/// # Example
9941///
9942/// Instantiate a resource builder
9943///
9944/// ```test_harness,no_run
9945/// extern crate hyper;
9946/// extern crate hyper_rustls;
9947/// extern crate google_dfareporting3d2 as dfareporting3d2;
9948///
9949/// # async fn dox() {
9950/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9951///
9952/// let secret: yup_oauth2::ApplicationSecret = Default::default();
9953/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9954///     secret,
9955///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9956/// ).build().await.unwrap();
9957///
9958/// let client = hyper_util::client::legacy::Client::builder(
9959///     hyper_util::rt::TokioExecutor::new()
9960/// )
9961/// .build(
9962///     hyper_rustls::HttpsConnectorBuilder::new()
9963///         .with_native_roots()
9964///         .unwrap()
9965///         .https_or_http()
9966///         .enable_http1()
9967///         .build()
9968/// );
9969/// let mut hub = Dfareporting::new(client, auth);
9970/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
9971/// // like `get(...)` and `list(...)`
9972/// // to build up your call.
9973/// let rb = hub.countries();
9974/// # }
9975/// ```
9976pub struct CountryMethods<'a, C>
9977where
9978    C: 'a,
9979{
9980    hub: &'a Dfareporting<C>,
9981}
9982
9983impl<'a, C> common::MethodsBuilder for CountryMethods<'a, C> {}
9984
9985impl<'a, C> CountryMethods<'a, C> {
9986    /// Create a builder to help you perform the following task:
9987    ///
9988    /// Gets one country by ID.
9989    ///
9990    /// # Arguments
9991    ///
9992    /// * `profileId` - User profile ID associated with this request.
9993    /// * `dartId` - Country DART ID.
9994    pub fn get(&self, profile_id: i64, dart_id: i64) -> CountryGetCall<'a, C> {
9995        CountryGetCall {
9996            hub: self.hub,
9997            _profile_id: profile_id,
9998            _dart_id: dart_id,
9999            _delegate: Default::default(),
10000            _additional_params: Default::default(),
10001            _scopes: Default::default(),
10002        }
10003    }
10004
10005    /// Create a builder to help you perform the following task:
10006    ///
10007    /// Retrieves a list of countries.
10008    ///
10009    /// # Arguments
10010    ///
10011    /// * `profileId` - User profile ID associated with this request.
10012    pub fn list(&self, profile_id: i64) -> CountryListCall<'a, C> {
10013        CountryListCall {
10014            hub: self.hub,
10015            _profile_id: profile_id,
10016            _delegate: Default::default(),
10017            _additional_params: Default::default(),
10018            _scopes: Default::default(),
10019        }
10020    }
10021}
10022
10023/// A builder providing access to all methods supported on *creativeAsset* resources.
10024/// It is not used directly, but through the [`Dfareporting`] hub.
10025///
10026/// # Example
10027///
10028/// Instantiate a resource builder
10029///
10030/// ```test_harness,no_run
10031/// extern crate hyper;
10032/// extern crate hyper_rustls;
10033/// extern crate google_dfareporting3d2 as dfareporting3d2;
10034///
10035/// # async fn dox() {
10036/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10037///
10038/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10039/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10040///     secret,
10041///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10042/// ).build().await.unwrap();
10043///
10044/// let client = hyper_util::client::legacy::Client::builder(
10045///     hyper_util::rt::TokioExecutor::new()
10046/// )
10047/// .build(
10048///     hyper_rustls::HttpsConnectorBuilder::new()
10049///         .with_native_roots()
10050///         .unwrap()
10051///         .https_or_http()
10052///         .enable_http1()
10053///         .build()
10054/// );
10055/// let mut hub = Dfareporting::new(client, auth);
10056/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10057/// // like `insert(...)`
10058/// // to build up your call.
10059/// let rb = hub.creative_assets();
10060/// # }
10061/// ```
10062pub struct CreativeAssetMethods<'a, C>
10063where
10064    C: 'a,
10065{
10066    hub: &'a Dfareporting<C>,
10067}
10068
10069impl<'a, C> common::MethodsBuilder for CreativeAssetMethods<'a, C> {}
10070
10071impl<'a, C> CreativeAssetMethods<'a, C> {
10072    /// Create a builder to help you perform the following task:
10073    ///
10074    /// Inserts a new creative asset.
10075    ///
10076    /// # Arguments
10077    ///
10078    /// * `request` - No description provided.
10079    /// * `profileId` - User profile ID associated with this request.
10080    /// * `advertiserId` - Advertiser ID of this creative. This is a required field.
10081    pub fn insert(
10082        &self,
10083        request: CreativeAssetMetadata,
10084        profile_id: i64,
10085        advertiser_id: i64,
10086    ) -> CreativeAssetInsertCall<'a, C> {
10087        CreativeAssetInsertCall {
10088            hub: self.hub,
10089            _request: request,
10090            _profile_id: profile_id,
10091            _advertiser_id: advertiser_id,
10092            _delegate: Default::default(),
10093            _additional_params: Default::default(),
10094            _scopes: Default::default(),
10095        }
10096    }
10097}
10098
10099/// A builder providing access to all methods supported on *creativeFieldValue* resources.
10100/// It is not used directly, but through the [`Dfareporting`] hub.
10101///
10102/// # Example
10103///
10104/// Instantiate a resource builder
10105///
10106/// ```test_harness,no_run
10107/// extern crate hyper;
10108/// extern crate hyper_rustls;
10109/// extern crate google_dfareporting3d2 as dfareporting3d2;
10110///
10111/// # async fn dox() {
10112/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10113///
10114/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10115/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10116///     secret,
10117///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10118/// ).build().await.unwrap();
10119///
10120/// let client = hyper_util::client::legacy::Client::builder(
10121///     hyper_util::rt::TokioExecutor::new()
10122/// )
10123/// .build(
10124///     hyper_rustls::HttpsConnectorBuilder::new()
10125///         .with_native_roots()
10126///         .unwrap()
10127///         .https_or_http()
10128///         .enable_http1()
10129///         .build()
10130/// );
10131/// let mut hub = Dfareporting::new(client, auth);
10132/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10133/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
10134/// // to build up your call.
10135/// let rb = hub.creative_field_values();
10136/// # }
10137/// ```
10138pub struct CreativeFieldValueMethods<'a, C>
10139where
10140    C: 'a,
10141{
10142    hub: &'a Dfareporting<C>,
10143}
10144
10145impl<'a, C> common::MethodsBuilder for CreativeFieldValueMethods<'a, C> {}
10146
10147impl<'a, C> CreativeFieldValueMethods<'a, C> {
10148    /// Create a builder to help you perform the following task:
10149    ///
10150    /// Deletes an existing creative field value.
10151    ///
10152    /// # Arguments
10153    ///
10154    /// * `profileId` - User profile ID associated with this request.
10155    /// * `creativeFieldId` - Creative field ID for this creative field value.
10156    /// * `id` - Creative Field Value ID
10157    pub fn delete(
10158        &self,
10159        profile_id: i64,
10160        creative_field_id: i64,
10161        id: i64,
10162    ) -> CreativeFieldValueDeleteCall<'a, C> {
10163        CreativeFieldValueDeleteCall {
10164            hub: self.hub,
10165            _profile_id: profile_id,
10166            _creative_field_id: creative_field_id,
10167            _id: id,
10168            _delegate: Default::default(),
10169            _additional_params: Default::default(),
10170            _scopes: Default::default(),
10171        }
10172    }
10173
10174    /// Create a builder to help you perform the following task:
10175    ///
10176    /// Gets one creative field value by ID.
10177    ///
10178    /// # Arguments
10179    ///
10180    /// * `profileId` - User profile ID associated with this request.
10181    /// * `creativeFieldId` - Creative field ID for this creative field value.
10182    /// * `id` - Creative Field Value ID
10183    pub fn get(
10184        &self,
10185        profile_id: i64,
10186        creative_field_id: i64,
10187        id: i64,
10188    ) -> CreativeFieldValueGetCall<'a, C> {
10189        CreativeFieldValueGetCall {
10190            hub: self.hub,
10191            _profile_id: profile_id,
10192            _creative_field_id: creative_field_id,
10193            _id: id,
10194            _delegate: Default::default(),
10195            _additional_params: Default::default(),
10196            _scopes: Default::default(),
10197        }
10198    }
10199
10200    /// Create a builder to help you perform the following task:
10201    ///
10202    /// Inserts a new creative field value.
10203    ///
10204    /// # Arguments
10205    ///
10206    /// * `request` - No description provided.
10207    /// * `profileId` - User profile ID associated with this request.
10208    /// * `creativeFieldId` - Creative field ID for this creative field value.
10209    pub fn insert(
10210        &self,
10211        request: CreativeFieldValue,
10212        profile_id: i64,
10213        creative_field_id: i64,
10214    ) -> CreativeFieldValueInsertCall<'a, C> {
10215        CreativeFieldValueInsertCall {
10216            hub: self.hub,
10217            _request: request,
10218            _profile_id: profile_id,
10219            _creative_field_id: creative_field_id,
10220            _delegate: Default::default(),
10221            _additional_params: Default::default(),
10222            _scopes: Default::default(),
10223        }
10224    }
10225
10226    /// Create a builder to help you perform the following task:
10227    ///
10228    /// Retrieves a list of creative field values, possibly filtered. This method supports paging.
10229    ///
10230    /// # Arguments
10231    ///
10232    /// * `profileId` - User profile ID associated with this request.
10233    /// * `creativeFieldId` - Creative field ID for this creative field value.
10234    pub fn list(
10235        &self,
10236        profile_id: i64,
10237        creative_field_id: i64,
10238    ) -> CreativeFieldValueListCall<'a, C> {
10239        CreativeFieldValueListCall {
10240            hub: self.hub,
10241            _profile_id: profile_id,
10242            _creative_field_id: creative_field_id,
10243            _sort_order: Default::default(),
10244            _sort_field: Default::default(),
10245            _search_string: Default::default(),
10246            _page_token: Default::default(),
10247            _max_results: Default::default(),
10248            _ids: Default::default(),
10249            _delegate: Default::default(),
10250            _additional_params: Default::default(),
10251            _scopes: Default::default(),
10252        }
10253    }
10254
10255    /// Create a builder to help you perform the following task:
10256    ///
10257    /// Updates an existing creative field value. This method supports patch semantics.
10258    ///
10259    /// # Arguments
10260    ///
10261    /// * `request` - No description provided.
10262    /// * `profileId` - User profile ID associated with this request.
10263    /// * `creativeFieldId` - Creative field ID for this creative field value.
10264    /// * `id` - Creative Field Value ID
10265    pub fn patch(
10266        &self,
10267        request: CreativeFieldValue,
10268        profile_id: i64,
10269        creative_field_id: i64,
10270        id: i64,
10271    ) -> CreativeFieldValuePatchCall<'a, C> {
10272        CreativeFieldValuePatchCall {
10273            hub: self.hub,
10274            _request: request,
10275            _profile_id: profile_id,
10276            _creative_field_id: creative_field_id,
10277            _id: id,
10278            _delegate: Default::default(),
10279            _additional_params: Default::default(),
10280            _scopes: Default::default(),
10281        }
10282    }
10283
10284    /// Create a builder to help you perform the following task:
10285    ///
10286    /// Updates an existing creative field value.
10287    ///
10288    /// # Arguments
10289    ///
10290    /// * `request` - No description provided.
10291    /// * `profileId` - User profile ID associated with this request.
10292    /// * `creativeFieldId` - Creative field ID for this creative field value.
10293    pub fn update(
10294        &self,
10295        request: CreativeFieldValue,
10296        profile_id: i64,
10297        creative_field_id: i64,
10298    ) -> CreativeFieldValueUpdateCall<'a, C> {
10299        CreativeFieldValueUpdateCall {
10300            hub: self.hub,
10301            _request: request,
10302            _profile_id: profile_id,
10303            _creative_field_id: creative_field_id,
10304            _delegate: Default::default(),
10305            _additional_params: Default::default(),
10306            _scopes: Default::default(),
10307        }
10308    }
10309}
10310
10311/// A builder providing access to all methods supported on *creativeField* resources.
10312/// It is not used directly, but through the [`Dfareporting`] hub.
10313///
10314/// # Example
10315///
10316/// Instantiate a resource builder
10317///
10318/// ```test_harness,no_run
10319/// extern crate hyper;
10320/// extern crate hyper_rustls;
10321/// extern crate google_dfareporting3d2 as dfareporting3d2;
10322///
10323/// # async fn dox() {
10324/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10325///
10326/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10327/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10328///     secret,
10329///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10330/// ).build().await.unwrap();
10331///
10332/// let client = hyper_util::client::legacy::Client::builder(
10333///     hyper_util::rt::TokioExecutor::new()
10334/// )
10335/// .build(
10336///     hyper_rustls::HttpsConnectorBuilder::new()
10337///         .with_native_roots()
10338///         .unwrap()
10339///         .https_or_http()
10340///         .enable_http1()
10341///         .build()
10342/// );
10343/// let mut hub = Dfareporting::new(client, auth);
10344/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10345/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
10346/// // to build up your call.
10347/// let rb = hub.creative_fields();
10348/// # }
10349/// ```
10350pub struct CreativeFieldMethods<'a, C>
10351where
10352    C: 'a,
10353{
10354    hub: &'a Dfareporting<C>,
10355}
10356
10357impl<'a, C> common::MethodsBuilder for CreativeFieldMethods<'a, C> {}
10358
10359impl<'a, C> CreativeFieldMethods<'a, C> {
10360    /// Create a builder to help you perform the following task:
10361    ///
10362    /// Deletes an existing creative field.
10363    ///
10364    /// # Arguments
10365    ///
10366    /// * `profileId` - User profile ID associated with this request.
10367    /// * `id` - Creative Field ID
10368    pub fn delete(&self, profile_id: i64, id: i64) -> CreativeFieldDeleteCall<'a, C> {
10369        CreativeFieldDeleteCall {
10370            hub: self.hub,
10371            _profile_id: profile_id,
10372            _id: id,
10373            _delegate: Default::default(),
10374            _additional_params: Default::default(),
10375            _scopes: Default::default(),
10376        }
10377    }
10378
10379    /// Create a builder to help you perform the following task:
10380    ///
10381    /// Gets one creative field by ID.
10382    ///
10383    /// # Arguments
10384    ///
10385    /// * `profileId` - User profile ID associated with this request.
10386    /// * `id` - Creative Field ID
10387    pub fn get(&self, profile_id: i64, id: i64) -> CreativeFieldGetCall<'a, C> {
10388        CreativeFieldGetCall {
10389            hub: self.hub,
10390            _profile_id: profile_id,
10391            _id: id,
10392            _delegate: Default::default(),
10393            _additional_params: Default::default(),
10394            _scopes: Default::default(),
10395        }
10396    }
10397
10398    /// Create a builder to help you perform the following task:
10399    ///
10400    /// Inserts a new creative field.
10401    ///
10402    /// # Arguments
10403    ///
10404    /// * `request` - No description provided.
10405    /// * `profileId` - User profile ID associated with this request.
10406    pub fn insert(
10407        &self,
10408        request: CreativeField,
10409        profile_id: i64,
10410    ) -> CreativeFieldInsertCall<'a, C> {
10411        CreativeFieldInsertCall {
10412            hub: self.hub,
10413            _request: request,
10414            _profile_id: profile_id,
10415            _delegate: Default::default(),
10416            _additional_params: Default::default(),
10417            _scopes: Default::default(),
10418        }
10419    }
10420
10421    /// Create a builder to help you perform the following task:
10422    ///
10423    /// Retrieves a list of creative fields, possibly filtered. This method supports paging.
10424    ///
10425    /// # Arguments
10426    ///
10427    /// * `profileId` - User profile ID associated with this request.
10428    pub fn list(&self, profile_id: i64) -> CreativeFieldListCall<'a, C> {
10429        CreativeFieldListCall {
10430            hub: self.hub,
10431            _profile_id: profile_id,
10432            _sort_order: Default::default(),
10433            _sort_field: Default::default(),
10434            _search_string: Default::default(),
10435            _page_token: Default::default(),
10436            _max_results: Default::default(),
10437            _ids: Default::default(),
10438            _advertiser_ids: Default::default(),
10439            _delegate: Default::default(),
10440            _additional_params: Default::default(),
10441            _scopes: Default::default(),
10442        }
10443    }
10444
10445    /// Create a builder to help you perform the following task:
10446    ///
10447    /// Updates an existing creative field. This method supports patch semantics.
10448    ///
10449    /// # Arguments
10450    ///
10451    /// * `request` - No description provided.
10452    /// * `profileId` - User profile ID associated with this request.
10453    /// * `id` - Creative Field ID
10454    pub fn patch(
10455        &self,
10456        request: CreativeField,
10457        profile_id: i64,
10458        id: i64,
10459    ) -> CreativeFieldPatchCall<'a, C> {
10460        CreativeFieldPatchCall {
10461            hub: self.hub,
10462            _request: request,
10463            _profile_id: profile_id,
10464            _id: id,
10465            _delegate: Default::default(),
10466            _additional_params: Default::default(),
10467            _scopes: Default::default(),
10468        }
10469    }
10470
10471    /// Create a builder to help you perform the following task:
10472    ///
10473    /// Updates an existing creative field.
10474    ///
10475    /// # Arguments
10476    ///
10477    /// * `request` - No description provided.
10478    /// * `profileId` - User profile ID associated with this request.
10479    pub fn update(
10480        &self,
10481        request: CreativeField,
10482        profile_id: i64,
10483    ) -> CreativeFieldUpdateCall<'a, C> {
10484        CreativeFieldUpdateCall {
10485            hub: self.hub,
10486            _request: request,
10487            _profile_id: profile_id,
10488            _delegate: Default::default(),
10489            _additional_params: Default::default(),
10490            _scopes: Default::default(),
10491        }
10492    }
10493}
10494
10495/// A builder providing access to all methods supported on *creativeGroup* resources.
10496/// It is not used directly, but through the [`Dfareporting`] hub.
10497///
10498/// # Example
10499///
10500/// Instantiate a resource builder
10501///
10502/// ```test_harness,no_run
10503/// extern crate hyper;
10504/// extern crate hyper_rustls;
10505/// extern crate google_dfareporting3d2 as dfareporting3d2;
10506///
10507/// # async fn dox() {
10508/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10509///
10510/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10511/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10512///     secret,
10513///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10514/// ).build().await.unwrap();
10515///
10516/// let client = hyper_util::client::legacy::Client::builder(
10517///     hyper_util::rt::TokioExecutor::new()
10518/// )
10519/// .build(
10520///     hyper_rustls::HttpsConnectorBuilder::new()
10521///         .with_native_roots()
10522///         .unwrap()
10523///         .https_or_http()
10524///         .enable_http1()
10525///         .build()
10526/// );
10527/// let mut hub = Dfareporting::new(client, auth);
10528/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10529/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
10530/// // to build up your call.
10531/// let rb = hub.creative_groups();
10532/// # }
10533/// ```
10534pub struct CreativeGroupMethods<'a, C>
10535where
10536    C: 'a,
10537{
10538    hub: &'a Dfareporting<C>,
10539}
10540
10541impl<'a, C> common::MethodsBuilder for CreativeGroupMethods<'a, C> {}
10542
10543impl<'a, C> CreativeGroupMethods<'a, C> {
10544    /// Create a builder to help you perform the following task:
10545    ///
10546    /// Gets one creative group by ID.
10547    ///
10548    /// # Arguments
10549    ///
10550    /// * `profileId` - User profile ID associated with this request.
10551    /// * `id` - Creative group ID.
10552    pub fn get(&self, profile_id: i64, id: i64) -> CreativeGroupGetCall<'a, C> {
10553        CreativeGroupGetCall {
10554            hub: self.hub,
10555            _profile_id: profile_id,
10556            _id: id,
10557            _delegate: Default::default(),
10558            _additional_params: Default::default(),
10559            _scopes: Default::default(),
10560        }
10561    }
10562
10563    /// Create a builder to help you perform the following task:
10564    ///
10565    /// Inserts a new creative group.
10566    ///
10567    /// # Arguments
10568    ///
10569    /// * `request` - No description provided.
10570    /// * `profileId` - User profile ID associated with this request.
10571    pub fn insert(
10572        &self,
10573        request: CreativeGroup,
10574        profile_id: i64,
10575    ) -> CreativeGroupInsertCall<'a, C> {
10576        CreativeGroupInsertCall {
10577            hub: self.hub,
10578            _request: request,
10579            _profile_id: profile_id,
10580            _delegate: Default::default(),
10581            _additional_params: Default::default(),
10582            _scopes: Default::default(),
10583        }
10584    }
10585
10586    /// Create a builder to help you perform the following task:
10587    ///
10588    /// Retrieves a list of creative groups, possibly filtered. This method supports paging.
10589    ///
10590    /// # Arguments
10591    ///
10592    /// * `profileId` - User profile ID associated with this request.
10593    pub fn list(&self, profile_id: i64) -> CreativeGroupListCall<'a, C> {
10594        CreativeGroupListCall {
10595            hub: self.hub,
10596            _profile_id: profile_id,
10597            _sort_order: Default::default(),
10598            _sort_field: Default::default(),
10599            _search_string: Default::default(),
10600            _page_token: Default::default(),
10601            _max_results: Default::default(),
10602            _ids: Default::default(),
10603            _group_number: Default::default(),
10604            _advertiser_ids: Default::default(),
10605            _delegate: Default::default(),
10606            _additional_params: Default::default(),
10607            _scopes: Default::default(),
10608        }
10609    }
10610
10611    /// Create a builder to help you perform the following task:
10612    ///
10613    /// Updates an existing creative group. This method supports patch semantics.
10614    ///
10615    /// # Arguments
10616    ///
10617    /// * `request` - No description provided.
10618    /// * `profileId` - User profile ID associated with this request.
10619    /// * `id` - Creative group ID.
10620    pub fn patch(
10621        &self,
10622        request: CreativeGroup,
10623        profile_id: i64,
10624        id: i64,
10625    ) -> CreativeGroupPatchCall<'a, C> {
10626        CreativeGroupPatchCall {
10627            hub: self.hub,
10628            _request: request,
10629            _profile_id: profile_id,
10630            _id: id,
10631            _delegate: Default::default(),
10632            _additional_params: Default::default(),
10633            _scopes: Default::default(),
10634        }
10635    }
10636
10637    /// Create a builder to help you perform the following task:
10638    ///
10639    /// Updates an existing creative group.
10640    ///
10641    /// # Arguments
10642    ///
10643    /// * `request` - No description provided.
10644    /// * `profileId` - User profile ID associated with this request.
10645    pub fn update(
10646        &self,
10647        request: CreativeGroup,
10648        profile_id: i64,
10649    ) -> CreativeGroupUpdateCall<'a, C> {
10650        CreativeGroupUpdateCall {
10651            hub: self.hub,
10652            _request: request,
10653            _profile_id: profile_id,
10654            _delegate: Default::default(),
10655            _additional_params: Default::default(),
10656            _scopes: Default::default(),
10657        }
10658    }
10659}
10660
10661/// A builder providing access to all methods supported on *creative* resources.
10662/// It is not used directly, but through the [`Dfareporting`] hub.
10663///
10664/// # Example
10665///
10666/// Instantiate a resource builder
10667///
10668/// ```test_harness,no_run
10669/// extern crate hyper;
10670/// extern crate hyper_rustls;
10671/// extern crate google_dfareporting3d2 as dfareporting3d2;
10672///
10673/// # async fn dox() {
10674/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10675///
10676/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10677/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10678///     secret,
10679///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10680/// ).build().await.unwrap();
10681///
10682/// let client = hyper_util::client::legacy::Client::builder(
10683///     hyper_util::rt::TokioExecutor::new()
10684/// )
10685/// .build(
10686///     hyper_rustls::HttpsConnectorBuilder::new()
10687///         .with_native_roots()
10688///         .unwrap()
10689///         .https_or_http()
10690///         .enable_http1()
10691///         .build()
10692/// );
10693/// let mut hub = Dfareporting::new(client, auth);
10694/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10695/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
10696/// // to build up your call.
10697/// let rb = hub.creatives();
10698/// # }
10699/// ```
10700pub struct CreativeMethods<'a, C>
10701where
10702    C: 'a,
10703{
10704    hub: &'a Dfareporting<C>,
10705}
10706
10707impl<'a, C> common::MethodsBuilder for CreativeMethods<'a, C> {}
10708
10709impl<'a, C> CreativeMethods<'a, C> {
10710    /// Create a builder to help you perform the following task:
10711    ///
10712    /// Gets one creative by ID.
10713    ///
10714    /// # Arguments
10715    ///
10716    /// * `profileId` - User profile ID associated with this request.
10717    /// * `id` - Creative ID.
10718    pub fn get(&self, profile_id: i64, id: i64) -> CreativeGetCall<'a, C> {
10719        CreativeGetCall {
10720            hub: self.hub,
10721            _profile_id: profile_id,
10722            _id: id,
10723            _delegate: Default::default(),
10724            _additional_params: Default::default(),
10725            _scopes: Default::default(),
10726        }
10727    }
10728
10729    /// Create a builder to help you perform the following task:
10730    ///
10731    /// Inserts a new creative.
10732    ///
10733    /// # Arguments
10734    ///
10735    /// * `request` - No description provided.
10736    /// * `profileId` - User profile ID associated with this request.
10737    pub fn insert(&self, request: Creative, profile_id: i64) -> CreativeInsertCall<'a, C> {
10738        CreativeInsertCall {
10739            hub: self.hub,
10740            _request: request,
10741            _profile_id: profile_id,
10742            _delegate: Default::default(),
10743            _additional_params: Default::default(),
10744            _scopes: Default::default(),
10745        }
10746    }
10747
10748    /// Create a builder to help you perform the following task:
10749    ///
10750    /// Retrieves a list of creatives, possibly filtered. This method supports paging.
10751    ///
10752    /// # Arguments
10753    ///
10754    /// * `profileId` - User profile ID associated with this request.
10755    pub fn list(&self, profile_id: i64) -> CreativeListCall<'a, C> {
10756        CreativeListCall {
10757            hub: self.hub,
10758            _profile_id: profile_id,
10759            _types: Default::default(),
10760            _studio_creative_id: Default::default(),
10761            _sort_order: Default::default(),
10762            _sort_field: Default::default(),
10763            _size_ids: Default::default(),
10764            _search_string: Default::default(),
10765            _rendering_ids: Default::default(),
10766            _page_token: Default::default(),
10767            _max_results: Default::default(),
10768            _ids: Default::default(),
10769            _creative_field_ids: Default::default(),
10770            _companion_creative_ids: Default::default(),
10771            _campaign_id: Default::default(),
10772            _archived: Default::default(),
10773            _advertiser_id: Default::default(),
10774            _active: Default::default(),
10775            _delegate: Default::default(),
10776            _additional_params: Default::default(),
10777            _scopes: Default::default(),
10778        }
10779    }
10780
10781    /// Create a builder to help you perform the following task:
10782    ///
10783    /// Updates an existing creative. This method supports patch semantics.
10784    ///
10785    /// # Arguments
10786    ///
10787    /// * `request` - No description provided.
10788    /// * `profileId` - User profile ID associated with this request.
10789    /// * `id` - Creative ID.
10790    pub fn patch(&self, request: Creative, profile_id: i64, id: i64) -> CreativePatchCall<'a, C> {
10791        CreativePatchCall {
10792            hub: self.hub,
10793            _request: request,
10794            _profile_id: profile_id,
10795            _id: id,
10796            _delegate: Default::default(),
10797            _additional_params: Default::default(),
10798            _scopes: Default::default(),
10799        }
10800    }
10801
10802    /// Create a builder to help you perform the following task:
10803    ///
10804    /// Updates an existing creative.
10805    ///
10806    /// # Arguments
10807    ///
10808    /// * `request` - No description provided.
10809    /// * `profileId` - User profile ID associated with this request.
10810    pub fn update(&self, request: Creative, profile_id: i64) -> CreativeUpdateCall<'a, C> {
10811        CreativeUpdateCall {
10812            hub: self.hub,
10813            _request: request,
10814            _profile_id: profile_id,
10815            _delegate: Default::default(),
10816            _additional_params: Default::default(),
10817            _scopes: Default::default(),
10818        }
10819    }
10820}
10821
10822/// A builder providing access to all methods supported on *dimensionValue* resources.
10823/// It is not used directly, but through the [`Dfareporting`] hub.
10824///
10825/// # Example
10826///
10827/// Instantiate a resource builder
10828///
10829/// ```test_harness,no_run
10830/// extern crate hyper;
10831/// extern crate hyper_rustls;
10832/// extern crate google_dfareporting3d2 as dfareporting3d2;
10833///
10834/// # async fn dox() {
10835/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10836///
10837/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10838/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10839///     secret,
10840///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10841/// ).build().await.unwrap();
10842///
10843/// let client = hyper_util::client::legacy::Client::builder(
10844///     hyper_util::rt::TokioExecutor::new()
10845/// )
10846/// .build(
10847///     hyper_rustls::HttpsConnectorBuilder::new()
10848///         .with_native_roots()
10849///         .unwrap()
10850///         .https_or_http()
10851///         .enable_http1()
10852///         .build()
10853/// );
10854/// let mut hub = Dfareporting::new(client, auth);
10855/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10856/// // like `query(...)`
10857/// // to build up your call.
10858/// let rb = hub.dimension_values();
10859/// # }
10860/// ```
10861pub struct DimensionValueMethods<'a, C>
10862where
10863    C: 'a,
10864{
10865    hub: &'a Dfareporting<C>,
10866}
10867
10868impl<'a, C> common::MethodsBuilder for DimensionValueMethods<'a, C> {}
10869
10870impl<'a, C> DimensionValueMethods<'a, C> {
10871    /// Create a builder to help you perform the following task:
10872    ///
10873    /// Retrieves list of report dimension values for a list of filters.
10874    ///
10875    /// # Arguments
10876    ///
10877    /// * `request` - No description provided.
10878    /// * `profileId` - The DFA user profile ID.
10879    pub fn query(
10880        &self,
10881        request: DimensionValueRequest,
10882        profile_id: i64,
10883    ) -> DimensionValueQueryCall<'a, C> {
10884        DimensionValueQueryCall {
10885            hub: self.hub,
10886            _request: request,
10887            _profile_id: profile_id,
10888            _page_token: Default::default(),
10889            _max_results: Default::default(),
10890            _delegate: Default::default(),
10891            _additional_params: Default::default(),
10892            _scopes: Default::default(),
10893        }
10894    }
10895}
10896
10897/// A builder providing access to all methods supported on *directorySiteContact* resources.
10898/// It is not used directly, but through the [`Dfareporting`] hub.
10899///
10900/// # Example
10901///
10902/// Instantiate a resource builder
10903///
10904/// ```test_harness,no_run
10905/// extern crate hyper;
10906/// extern crate hyper_rustls;
10907/// extern crate google_dfareporting3d2 as dfareporting3d2;
10908///
10909/// # async fn dox() {
10910/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10911///
10912/// let secret: yup_oauth2::ApplicationSecret = Default::default();
10913/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10914///     secret,
10915///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10916/// ).build().await.unwrap();
10917///
10918/// let client = hyper_util::client::legacy::Client::builder(
10919///     hyper_util::rt::TokioExecutor::new()
10920/// )
10921/// .build(
10922///     hyper_rustls::HttpsConnectorBuilder::new()
10923///         .with_native_roots()
10924///         .unwrap()
10925///         .https_or_http()
10926///         .enable_http1()
10927///         .build()
10928/// );
10929/// let mut hub = Dfareporting::new(client, auth);
10930/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
10931/// // like `get(...)` and `list(...)`
10932/// // to build up your call.
10933/// let rb = hub.directory_site_contacts();
10934/// # }
10935/// ```
10936pub struct DirectorySiteContactMethods<'a, C>
10937where
10938    C: 'a,
10939{
10940    hub: &'a Dfareporting<C>,
10941}
10942
10943impl<'a, C> common::MethodsBuilder for DirectorySiteContactMethods<'a, C> {}
10944
10945impl<'a, C> DirectorySiteContactMethods<'a, C> {
10946    /// Create a builder to help you perform the following task:
10947    ///
10948    /// Gets one directory site contact by ID.
10949    ///
10950    /// # Arguments
10951    ///
10952    /// * `profileId` - User profile ID associated with this request.
10953    /// * `id` - Directory site contact ID.
10954    pub fn get(&self, profile_id: i64, id: i64) -> DirectorySiteContactGetCall<'a, C> {
10955        DirectorySiteContactGetCall {
10956            hub: self.hub,
10957            _profile_id: profile_id,
10958            _id: id,
10959            _delegate: Default::default(),
10960            _additional_params: Default::default(),
10961            _scopes: Default::default(),
10962        }
10963    }
10964
10965    /// Create a builder to help you perform the following task:
10966    ///
10967    /// Retrieves a list of directory site contacts, possibly filtered. This method supports paging.
10968    ///
10969    /// # Arguments
10970    ///
10971    /// * `profileId` - User profile ID associated with this request.
10972    pub fn list(&self, profile_id: i64) -> DirectorySiteContactListCall<'a, C> {
10973        DirectorySiteContactListCall {
10974            hub: self.hub,
10975            _profile_id: profile_id,
10976            _sort_order: Default::default(),
10977            _sort_field: Default::default(),
10978            _search_string: Default::default(),
10979            _page_token: Default::default(),
10980            _max_results: Default::default(),
10981            _ids: Default::default(),
10982            _directory_site_ids: Default::default(),
10983            _delegate: Default::default(),
10984            _additional_params: Default::default(),
10985            _scopes: Default::default(),
10986        }
10987    }
10988}
10989
10990/// A builder providing access to all methods supported on *directorySite* resources.
10991/// It is not used directly, but through the [`Dfareporting`] hub.
10992///
10993/// # Example
10994///
10995/// Instantiate a resource builder
10996///
10997/// ```test_harness,no_run
10998/// extern crate hyper;
10999/// extern crate hyper_rustls;
11000/// extern crate google_dfareporting3d2 as dfareporting3d2;
11001///
11002/// # async fn dox() {
11003/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11004///
11005/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11006/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11007///     secret,
11008///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11009/// ).build().await.unwrap();
11010///
11011/// let client = hyper_util::client::legacy::Client::builder(
11012///     hyper_util::rt::TokioExecutor::new()
11013/// )
11014/// .build(
11015///     hyper_rustls::HttpsConnectorBuilder::new()
11016///         .with_native_roots()
11017///         .unwrap()
11018///         .https_or_http()
11019///         .enable_http1()
11020///         .build()
11021/// );
11022/// let mut hub = Dfareporting::new(client, auth);
11023/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11024/// // like `get(...)`, `insert(...)` and `list(...)`
11025/// // to build up your call.
11026/// let rb = hub.directory_sites();
11027/// # }
11028/// ```
11029pub struct DirectorySiteMethods<'a, C>
11030where
11031    C: 'a,
11032{
11033    hub: &'a Dfareporting<C>,
11034}
11035
11036impl<'a, C> common::MethodsBuilder for DirectorySiteMethods<'a, C> {}
11037
11038impl<'a, C> DirectorySiteMethods<'a, C> {
11039    /// Create a builder to help you perform the following task:
11040    ///
11041    /// Gets one directory site by ID.
11042    ///
11043    /// # Arguments
11044    ///
11045    /// * `profileId` - User profile ID associated with this request.
11046    /// * `id` - Directory site ID.
11047    pub fn get(&self, profile_id: i64, id: i64) -> DirectorySiteGetCall<'a, C> {
11048        DirectorySiteGetCall {
11049            hub: self.hub,
11050            _profile_id: profile_id,
11051            _id: id,
11052            _delegate: Default::default(),
11053            _additional_params: Default::default(),
11054            _scopes: Default::default(),
11055        }
11056    }
11057
11058    /// Create a builder to help you perform the following task:
11059    ///
11060    /// Inserts a new directory site.
11061    ///
11062    /// # Arguments
11063    ///
11064    /// * `request` - No description provided.
11065    /// * `profileId` - User profile ID associated with this request.
11066    pub fn insert(
11067        &self,
11068        request: DirectorySite,
11069        profile_id: i64,
11070    ) -> DirectorySiteInsertCall<'a, C> {
11071        DirectorySiteInsertCall {
11072            hub: self.hub,
11073            _request: request,
11074            _profile_id: profile_id,
11075            _delegate: Default::default(),
11076            _additional_params: Default::default(),
11077            _scopes: Default::default(),
11078        }
11079    }
11080
11081    /// Create a builder to help you perform the following task:
11082    ///
11083    /// Retrieves a list of directory sites, possibly filtered. This method supports paging.
11084    ///
11085    /// # Arguments
11086    ///
11087    /// * `profileId` - User profile ID associated with this request.
11088    pub fn list(&self, profile_id: i64) -> DirectorySiteListCall<'a, C> {
11089        DirectorySiteListCall {
11090            hub: self.hub,
11091            _profile_id: profile_id,
11092            _sort_order: Default::default(),
11093            _sort_field: Default::default(),
11094            _search_string: Default::default(),
11095            _parent_id: Default::default(),
11096            _page_token: Default::default(),
11097            _max_results: Default::default(),
11098            _ids: Default::default(),
11099            _dfp_network_code: Default::default(),
11100            _country_id: Default::default(),
11101            _active: Default::default(),
11102            _accepts_publisher_paid_placements: Default::default(),
11103            _accepts_interstitial_placements: Default::default(),
11104            _accepts_in_stream_video_placements: Default::default(),
11105            _delegate: Default::default(),
11106            _additional_params: Default::default(),
11107            _scopes: Default::default(),
11108        }
11109    }
11110}
11111
11112/// A builder providing access to all methods supported on *dynamicTargetingKey* resources.
11113/// It is not used directly, but through the [`Dfareporting`] hub.
11114///
11115/// # Example
11116///
11117/// Instantiate a resource builder
11118///
11119/// ```test_harness,no_run
11120/// extern crate hyper;
11121/// extern crate hyper_rustls;
11122/// extern crate google_dfareporting3d2 as dfareporting3d2;
11123///
11124/// # async fn dox() {
11125/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11126///
11127/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11128/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11129///     secret,
11130///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11131/// ).build().await.unwrap();
11132///
11133/// let client = hyper_util::client::legacy::Client::builder(
11134///     hyper_util::rt::TokioExecutor::new()
11135/// )
11136/// .build(
11137///     hyper_rustls::HttpsConnectorBuilder::new()
11138///         .with_native_roots()
11139///         .unwrap()
11140///         .https_or_http()
11141///         .enable_http1()
11142///         .build()
11143/// );
11144/// let mut hub = Dfareporting::new(client, auth);
11145/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11146/// // like `delete(...)`, `insert(...)` and `list(...)`
11147/// // to build up your call.
11148/// let rb = hub.dynamic_targeting_keys();
11149/// # }
11150/// ```
11151pub struct DynamicTargetingKeyMethods<'a, C>
11152where
11153    C: 'a,
11154{
11155    hub: &'a Dfareporting<C>,
11156}
11157
11158impl<'a, C> common::MethodsBuilder for DynamicTargetingKeyMethods<'a, C> {}
11159
11160impl<'a, C> DynamicTargetingKeyMethods<'a, C> {
11161    /// Create a builder to help you perform the following task:
11162    ///
11163    /// Deletes an existing dynamic targeting key.
11164    ///
11165    /// # Arguments
11166    ///
11167    /// * `profileId` - User profile ID associated with this request.
11168    /// * `objectId` - ID of the object of this dynamic targeting key. This is a required field.
11169    /// * `name` - Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase.
11170    /// * `objectType` - Type of the object of this dynamic targeting key. This is a required field.
11171    pub fn delete(
11172        &self,
11173        profile_id: i64,
11174        object_id: i64,
11175        name: &str,
11176        object_type: &str,
11177    ) -> DynamicTargetingKeyDeleteCall<'a, C> {
11178        DynamicTargetingKeyDeleteCall {
11179            hub: self.hub,
11180            _profile_id: profile_id,
11181            _object_id: object_id,
11182            _name: name.to_string(),
11183            _object_type: object_type.to_string(),
11184            _delegate: Default::default(),
11185            _additional_params: Default::default(),
11186            _scopes: Default::default(),
11187        }
11188    }
11189
11190    /// Create a builder to help you perform the following task:
11191    ///
11192    /// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement.
11193    ///
11194    /// # Arguments
11195    ///
11196    /// * `request` - No description provided.
11197    /// * `profileId` - User profile ID associated with this request.
11198    pub fn insert(
11199        &self,
11200        request: DynamicTargetingKey,
11201        profile_id: i64,
11202    ) -> DynamicTargetingKeyInsertCall<'a, C> {
11203        DynamicTargetingKeyInsertCall {
11204            hub: self.hub,
11205            _request: request,
11206            _profile_id: profile_id,
11207            _delegate: Default::default(),
11208            _additional_params: Default::default(),
11209            _scopes: Default::default(),
11210        }
11211    }
11212
11213    /// Create a builder to help you perform the following task:
11214    ///
11215    /// Retrieves a list of dynamic targeting keys.
11216    ///
11217    /// # Arguments
11218    ///
11219    /// * `profileId` - User profile ID associated with this request.
11220    pub fn list(&self, profile_id: i64) -> DynamicTargetingKeyListCall<'a, C> {
11221        DynamicTargetingKeyListCall {
11222            hub: self.hub,
11223            _profile_id: profile_id,
11224            _object_type: Default::default(),
11225            _object_id: Default::default(),
11226            _names: Default::default(),
11227            _advertiser_id: Default::default(),
11228            _delegate: Default::default(),
11229            _additional_params: Default::default(),
11230            _scopes: Default::default(),
11231        }
11232    }
11233}
11234
11235/// A builder providing access to all methods supported on *eventTag* resources.
11236/// It is not used directly, but through the [`Dfareporting`] hub.
11237///
11238/// # Example
11239///
11240/// Instantiate a resource builder
11241///
11242/// ```test_harness,no_run
11243/// extern crate hyper;
11244/// extern crate hyper_rustls;
11245/// extern crate google_dfareporting3d2 as dfareporting3d2;
11246///
11247/// # async fn dox() {
11248/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11249///
11250/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11251/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11252///     secret,
11253///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11254/// ).build().await.unwrap();
11255///
11256/// let client = hyper_util::client::legacy::Client::builder(
11257///     hyper_util::rt::TokioExecutor::new()
11258/// )
11259/// .build(
11260///     hyper_rustls::HttpsConnectorBuilder::new()
11261///         .with_native_roots()
11262///         .unwrap()
11263///         .https_or_http()
11264///         .enable_http1()
11265///         .build()
11266/// );
11267/// let mut hub = Dfareporting::new(client, auth);
11268/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11269/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
11270/// // to build up your call.
11271/// let rb = hub.event_tags();
11272/// # }
11273/// ```
11274pub struct EventTagMethods<'a, C>
11275where
11276    C: 'a,
11277{
11278    hub: &'a Dfareporting<C>,
11279}
11280
11281impl<'a, C> common::MethodsBuilder for EventTagMethods<'a, C> {}
11282
11283impl<'a, C> EventTagMethods<'a, C> {
11284    /// Create a builder to help you perform the following task:
11285    ///
11286    /// Deletes an existing event tag.
11287    ///
11288    /// # Arguments
11289    ///
11290    /// * `profileId` - User profile ID associated with this request.
11291    /// * `id` - Event tag ID.
11292    pub fn delete(&self, profile_id: i64, id: i64) -> EventTagDeleteCall<'a, C> {
11293        EventTagDeleteCall {
11294            hub: self.hub,
11295            _profile_id: profile_id,
11296            _id: id,
11297            _delegate: Default::default(),
11298            _additional_params: Default::default(),
11299            _scopes: Default::default(),
11300        }
11301    }
11302
11303    /// Create a builder to help you perform the following task:
11304    ///
11305    /// Gets one event tag by ID.
11306    ///
11307    /// # Arguments
11308    ///
11309    /// * `profileId` - User profile ID associated with this request.
11310    /// * `id` - Event tag ID.
11311    pub fn get(&self, profile_id: i64, id: i64) -> EventTagGetCall<'a, C> {
11312        EventTagGetCall {
11313            hub: self.hub,
11314            _profile_id: profile_id,
11315            _id: id,
11316            _delegate: Default::default(),
11317            _additional_params: Default::default(),
11318            _scopes: Default::default(),
11319        }
11320    }
11321
11322    /// Create a builder to help you perform the following task:
11323    ///
11324    /// Inserts a new event tag.
11325    ///
11326    /// # Arguments
11327    ///
11328    /// * `request` - No description provided.
11329    /// * `profileId` - User profile ID associated with this request.
11330    pub fn insert(&self, request: EventTag, profile_id: i64) -> EventTagInsertCall<'a, C> {
11331        EventTagInsertCall {
11332            hub: self.hub,
11333            _request: request,
11334            _profile_id: profile_id,
11335            _delegate: Default::default(),
11336            _additional_params: Default::default(),
11337            _scopes: Default::default(),
11338        }
11339    }
11340
11341    /// Create a builder to help you perform the following task:
11342    ///
11343    /// Retrieves a list of event tags, possibly filtered.
11344    ///
11345    /// # Arguments
11346    ///
11347    /// * `profileId` - User profile ID associated with this request.
11348    pub fn list(&self, profile_id: i64) -> EventTagListCall<'a, C> {
11349        EventTagListCall {
11350            hub: self.hub,
11351            _profile_id: profile_id,
11352            _sort_order: Default::default(),
11353            _sort_field: Default::default(),
11354            _search_string: Default::default(),
11355            _ids: Default::default(),
11356            _event_tag_types: Default::default(),
11357            _enabled: Default::default(),
11358            _definitions_only: Default::default(),
11359            _campaign_id: Default::default(),
11360            _advertiser_id: Default::default(),
11361            _ad_id: Default::default(),
11362            _delegate: Default::default(),
11363            _additional_params: Default::default(),
11364            _scopes: Default::default(),
11365        }
11366    }
11367
11368    /// Create a builder to help you perform the following task:
11369    ///
11370    /// Updates an existing event tag. This method supports patch semantics.
11371    ///
11372    /// # Arguments
11373    ///
11374    /// * `request` - No description provided.
11375    /// * `profileId` - User profile ID associated with this request.
11376    /// * `id` - Event tag ID.
11377    pub fn patch(&self, request: EventTag, profile_id: i64, id: i64) -> EventTagPatchCall<'a, C> {
11378        EventTagPatchCall {
11379            hub: self.hub,
11380            _request: request,
11381            _profile_id: profile_id,
11382            _id: id,
11383            _delegate: Default::default(),
11384            _additional_params: Default::default(),
11385            _scopes: Default::default(),
11386        }
11387    }
11388
11389    /// Create a builder to help you perform the following task:
11390    ///
11391    /// Updates an existing event tag.
11392    ///
11393    /// # Arguments
11394    ///
11395    /// * `request` - No description provided.
11396    /// * `profileId` - User profile ID associated with this request.
11397    pub fn update(&self, request: EventTag, profile_id: i64) -> EventTagUpdateCall<'a, C> {
11398        EventTagUpdateCall {
11399            hub: self.hub,
11400            _request: request,
11401            _profile_id: profile_id,
11402            _delegate: Default::default(),
11403            _additional_params: Default::default(),
11404            _scopes: Default::default(),
11405        }
11406    }
11407}
11408
11409/// A builder providing access to all methods supported on *file* resources.
11410/// It is not used directly, but through the [`Dfareporting`] hub.
11411///
11412/// # Example
11413///
11414/// Instantiate a resource builder
11415///
11416/// ```test_harness,no_run
11417/// extern crate hyper;
11418/// extern crate hyper_rustls;
11419/// extern crate google_dfareporting3d2 as dfareporting3d2;
11420///
11421/// # async fn dox() {
11422/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11423///
11424/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11425/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11426///     secret,
11427///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11428/// ).build().await.unwrap();
11429///
11430/// let client = hyper_util::client::legacy::Client::builder(
11431///     hyper_util::rt::TokioExecutor::new()
11432/// )
11433/// .build(
11434///     hyper_rustls::HttpsConnectorBuilder::new()
11435///         .with_native_roots()
11436///         .unwrap()
11437///         .https_or_http()
11438///         .enable_http1()
11439///         .build()
11440/// );
11441/// let mut hub = Dfareporting::new(client, auth);
11442/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11443/// // like `get(...)` and `list(...)`
11444/// // to build up your call.
11445/// let rb = hub.files();
11446/// # }
11447/// ```
11448pub struct FileMethods<'a, C>
11449where
11450    C: 'a,
11451{
11452    hub: &'a Dfareporting<C>,
11453}
11454
11455impl<'a, C> common::MethodsBuilder for FileMethods<'a, C> {}
11456
11457impl<'a, C> FileMethods<'a, C> {
11458    /// Create a builder to help you perform the following task:
11459    ///
11460    /// Retrieves a report file by its report ID and file ID. This method supports media download.
11461    ///
11462    /// # Arguments
11463    ///
11464    /// * `reportId` - The ID of the report.
11465    /// * `fileId` - The ID of the report file.
11466    pub fn get(&self, report_id: i64, file_id: i64) -> FileGetCall<'a, C> {
11467        FileGetCall {
11468            hub: self.hub,
11469            _report_id: report_id,
11470            _file_id: file_id,
11471            _delegate: Default::default(),
11472            _additional_params: Default::default(),
11473            _scopes: Default::default(),
11474        }
11475    }
11476
11477    /// Create a builder to help you perform the following task:
11478    ///
11479    /// Lists files for a user profile.
11480    ///
11481    /// # Arguments
11482    ///
11483    /// * `profileId` - The DFA profile ID.
11484    pub fn list(&self, profile_id: i64) -> FileListCall<'a, C> {
11485        FileListCall {
11486            hub: self.hub,
11487            _profile_id: profile_id,
11488            _sort_order: Default::default(),
11489            _sort_field: Default::default(),
11490            _scope: Default::default(),
11491            _page_token: Default::default(),
11492            _max_results: Default::default(),
11493            _delegate: Default::default(),
11494            _additional_params: Default::default(),
11495            _scopes: Default::default(),
11496        }
11497    }
11498}
11499
11500/// A builder providing access to all methods supported on *floodlightActivity* resources.
11501/// It is not used directly, but through the [`Dfareporting`] hub.
11502///
11503/// # Example
11504///
11505/// Instantiate a resource builder
11506///
11507/// ```test_harness,no_run
11508/// extern crate hyper;
11509/// extern crate hyper_rustls;
11510/// extern crate google_dfareporting3d2 as dfareporting3d2;
11511///
11512/// # async fn dox() {
11513/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11514///
11515/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11516/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11517///     secret,
11518///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11519/// ).build().await.unwrap();
11520///
11521/// let client = hyper_util::client::legacy::Client::builder(
11522///     hyper_util::rt::TokioExecutor::new()
11523/// )
11524/// .build(
11525///     hyper_rustls::HttpsConnectorBuilder::new()
11526///         .with_native_roots()
11527///         .unwrap()
11528///         .https_or_http()
11529///         .enable_http1()
11530///         .build()
11531/// );
11532/// let mut hub = Dfareporting::new(client, auth);
11533/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11534/// // like `delete(...)`, `generatetag(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
11535/// // to build up your call.
11536/// let rb = hub.floodlight_activities();
11537/// # }
11538/// ```
11539pub struct FloodlightActivityMethods<'a, C>
11540where
11541    C: 'a,
11542{
11543    hub: &'a Dfareporting<C>,
11544}
11545
11546impl<'a, C> common::MethodsBuilder for FloodlightActivityMethods<'a, C> {}
11547
11548impl<'a, C> FloodlightActivityMethods<'a, C> {
11549    /// Create a builder to help you perform the following task:
11550    ///
11551    /// Deletes an existing floodlight activity.
11552    ///
11553    /// # Arguments
11554    ///
11555    /// * `profileId` - User profile ID associated with this request.
11556    /// * `id` - Floodlight activity ID.
11557    pub fn delete(&self, profile_id: i64, id: i64) -> FloodlightActivityDeleteCall<'a, C> {
11558        FloodlightActivityDeleteCall {
11559            hub: self.hub,
11560            _profile_id: profile_id,
11561            _id: id,
11562            _delegate: Default::default(),
11563            _additional_params: Default::default(),
11564            _scopes: Default::default(),
11565        }
11566    }
11567
11568    /// Create a builder to help you perform the following task:
11569    ///
11570    /// Generates a tag for a floodlight activity.
11571    ///
11572    /// # Arguments
11573    ///
11574    /// * `profileId` - User profile ID associated with this request.
11575    pub fn generatetag(&self, profile_id: i64) -> FloodlightActivityGeneratetagCall<'a, C> {
11576        FloodlightActivityGeneratetagCall {
11577            hub: self.hub,
11578            _profile_id: profile_id,
11579            _floodlight_activity_id: Default::default(),
11580            _delegate: Default::default(),
11581            _additional_params: Default::default(),
11582            _scopes: Default::default(),
11583        }
11584    }
11585
11586    /// Create a builder to help you perform the following task:
11587    ///
11588    /// Gets one floodlight activity by ID.
11589    ///
11590    /// # Arguments
11591    ///
11592    /// * `profileId` - User profile ID associated with this request.
11593    /// * `id` - Floodlight activity ID.
11594    pub fn get(&self, profile_id: i64, id: i64) -> FloodlightActivityGetCall<'a, C> {
11595        FloodlightActivityGetCall {
11596            hub: self.hub,
11597            _profile_id: profile_id,
11598            _id: id,
11599            _delegate: Default::default(),
11600            _additional_params: Default::default(),
11601            _scopes: Default::default(),
11602        }
11603    }
11604
11605    /// Create a builder to help you perform the following task:
11606    ///
11607    /// Inserts a new floodlight activity.
11608    ///
11609    /// # Arguments
11610    ///
11611    /// * `request` - No description provided.
11612    /// * `profileId` - User profile ID associated with this request.
11613    pub fn insert(
11614        &self,
11615        request: FloodlightActivity,
11616        profile_id: i64,
11617    ) -> FloodlightActivityInsertCall<'a, C> {
11618        FloodlightActivityInsertCall {
11619            hub: self.hub,
11620            _request: request,
11621            _profile_id: profile_id,
11622            _delegate: Default::default(),
11623            _additional_params: Default::default(),
11624            _scopes: Default::default(),
11625        }
11626    }
11627
11628    /// Create a builder to help you perform the following task:
11629    ///
11630    /// Retrieves a list of floodlight activities, possibly filtered. This method supports paging.
11631    ///
11632    /// # Arguments
11633    ///
11634    /// * `profileId` - User profile ID associated with this request.
11635    pub fn list(&self, profile_id: i64) -> FloodlightActivityListCall<'a, C> {
11636        FloodlightActivityListCall {
11637            hub: self.hub,
11638            _profile_id: profile_id,
11639            _tag_string: Default::default(),
11640            _sort_order: Default::default(),
11641            _sort_field: Default::default(),
11642            _search_string: Default::default(),
11643            _page_token: Default::default(),
11644            _max_results: Default::default(),
11645            _ids: Default::default(),
11646            _floodlight_configuration_id: Default::default(),
11647            _floodlight_activity_group_type: Default::default(),
11648            _floodlight_activity_group_tag_string: Default::default(),
11649            _floodlight_activity_group_name: Default::default(),
11650            _floodlight_activity_group_ids: Default::default(),
11651            _advertiser_id: Default::default(),
11652            _delegate: Default::default(),
11653            _additional_params: Default::default(),
11654            _scopes: Default::default(),
11655        }
11656    }
11657
11658    /// Create a builder to help you perform the following task:
11659    ///
11660    /// Updates an existing floodlight activity. This method supports patch semantics.
11661    ///
11662    /// # Arguments
11663    ///
11664    /// * `request` - No description provided.
11665    /// * `profileId` - User profile ID associated with this request.
11666    /// * `id` - Floodlight activity ID.
11667    pub fn patch(
11668        &self,
11669        request: FloodlightActivity,
11670        profile_id: i64,
11671        id: i64,
11672    ) -> FloodlightActivityPatchCall<'a, C> {
11673        FloodlightActivityPatchCall {
11674            hub: self.hub,
11675            _request: request,
11676            _profile_id: profile_id,
11677            _id: id,
11678            _delegate: Default::default(),
11679            _additional_params: Default::default(),
11680            _scopes: Default::default(),
11681        }
11682    }
11683
11684    /// Create a builder to help you perform the following task:
11685    ///
11686    /// Updates an existing floodlight activity.
11687    ///
11688    /// # Arguments
11689    ///
11690    /// * `request` - No description provided.
11691    /// * `profileId` - User profile ID associated with this request.
11692    pub fn update(
11693        &self,
11694        request: FloodlightActivity,
11695        profile_id: i64,
11696    ) -> FloodlightActivityUpdateCall<'a, C> {
11697        FloodlightActivityUpdateCall {
11698            hub: self.hub,
11699            _request: request,
11700            _profile_id: profile_id,
11701            _delegate: Default::default(),
11702            _additional_params: Default::default(),
11703            _scopes: Default::default(),
11704        }
11705    }
11706}
11707
11708/// A builder providing access to all methods supported on *floodlightActivityGroup* resources.
11709/// It is not used directly, but through the [`Dfareporting`] hub.
11710///
11711/// # Example
11712///
11713/// Instantiate a resource builder
11714///
11715/// ```test_harness,no_run
11716/// extern crate hyper;
11717/// extern crate hyper_rustls;
11718/// extern crate google_dfareporting3d2 as dfareporting3d2;
11719///
11720/// # async fn dox() {
11721/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11722///
11723/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11724/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11725///     secret,
11726///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11727/// ).build().await.unwrap();
11728///
11729/// let client = hyper_util::client::legacy::Client::builder(
11730///     hyper_util::rt::TokioExecutor::new()
11731/// )
11732/// .build(
11733///     hyper_rustls::HttpsConnectorBuilder::new()
11734///         .with_native_roots()
11735///         .unwrap()
11736///         .https_or_http()
11737///         .enable_http1()
11738///         .build()
11739/// );
11740/// let mut hub = Dfareporting::new(client, auth);
11741/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11742/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
11743/// // to build up your call.
11744/// let rb = hub.floodlight_activity_groups();
11745/// # }
11746/// ```
11747pub struct FloodlightActivityGroupMethods<'a, C>
11748where
11749    C: 'a,
11750{
11751    hub: &'a Dfareporting<C>,
11752}
11753
11754impl<'a, C> common::MethodsBuilder for FloodlightActivityGroupMethods<'a, C> {}
11755
11756impl<'a, C> FloodlightActivityGroupMethods<'a, C> {
11757    /// Create a builder to help you perform the following task:
11758    ///
11759    /// Gets one floodlight activity group by ID.
11760    ///
11761    /// # Arguments
11762    ///
11763    /// * `profileId` - User profile ID associated with this request.
11764    /// * `id` - Floodlight activity Group ID.
11765    pub fn get(&self, profile_id: i64, id: i64) -> FloodlightActivityGroupGetCall<'a, C> {
11766        FloodlightActivityGroupGetCall {
11767            hub: self.hub,
11768            _profile_id: profile_id,
11769            _id: id,
11770            _delegate: Default::default(),
11771            _additional_params: Default::default(),
11772            _scopes: Default::default(),
11773        }
11774    }
11775
11776    /// Create a builder to help you perform the following task:
11777    ///
11778    /// Inserts a new floodlight activity group.
11779    ///
11780    /// # Arguments
11781    ///
11782    /// * `request` - No description provided.
11783    /// * `profileId` - User profile ID associated with this request.
11784    pub fn insert(
11785        &self,
11786        request: FloodlightActivityGroup,
11787        profile_id: i64,
11788    ) -> FloodlightActivityGroupInsertCall<'a, C> {
11789        FloodlightActivityGroupInsertCall {
11790            hub: self.hub,
11791            _request: request,
11792            _profile_id: profile_id,
11793            _delegate: Default::default(),
11794            _additional_params: Default::default(),
11795            _scopes: Default::default(),
11796        }
11797    }
11798
11799    /// Create a builder to help you perform the following task:
11800    ///
11801    /// Retrieves a list of floodlight activity groups, possibly filtered. This method supports paging.
11802    ///
11803    /// # Arguments
11804    ///
11805    /// * `profileId` - User profile ID associated with this request.
11806    pub fn list(&self, profile_id: i64) -> FloodlightActivityGroupListCall<'a, C> {
11807        FloodlightActivityGroupListCall {
11808            hub: self.hub,
11809            _profile_id: profile_id,
11810            _type_: Default::default(),
11811            _sort_order: Default::default(),
11812            _sort_field: Default::default(),
11813            _search_string: Default::default(),
11814            _page_token: Default::default(),
11815            _max_results: Default::default(),
11816            _ids: Default::default(),
11817            _floodlight_configuration_id: Default::default(),
11818            _advertiser_id: Default::default(),
11819            _delegate: Default::default(),
11820            _additional_params: Default::default(),
11821            _scopes: Default::default(),
11822        }
11823    }
11824
11825    /// Create a builder to help you perform the following task:
11826    ///
11827    /// Updates an existing floodlight activity group. This method supports patch semantics.
11828    ///
11829    /// # Arguments
11830    ///
11831    /// * `request` - No description provided.
11832    /// * `profileId` - User profile ID associated with this request.
11833    /// * `id` - Floodlight activity Group ID.
11834    pub fn patch(
11835        &self,
11836        request: FloodlightActivityGroup,
11837        profile_id: i64,
11838        id: i64,
11839    ) -> FloodlightActivityGroupPatchCall<'a, C> {
11840        FloodlightActivityGroupPatchCall {
11841            hub: self.hub,
11842            _request: request,
11843            _profile_id: profile_id,
11844            _id: id,
11845            _delegate: Default::default(),
11846            _additional_params: Default::default(),
11847            _scopes: Default::default(),
11848        }
11849    }
11850
11851    /// Create a builder to help you perform the following task:
11852    ///
11853    /// Updates an existing floodlight activity group.
11854    ///
11855    /// # Arguments
11856    ///
11857    /// * `request` - No description provided.
11858    /// * `profileId` - User profile ID associated with this request.
11859    pub fn update(
11860        &self,
11861        request: FloodlightActivityGroup,
11862        profile_id: i64,
11863    ) -> FloodlightActivityGroupUpdateCall<'a, C> {
11864        FloodlightActivityGroupUpdateCall {
11865            hub: self.hub,
11866            _request: request,
11867            _profile_id: profile_id,
11868            _delegate: Default::default(),
11869            _additional_params: Default::default(),
11870            _scopes: Default::default(),
11871        }
11872    }
11873}
11874
11875/// A builder providing access to all methods supported on *floodlightConfiguration* resources.
11876/// It is not used directly, but through the [`Dfareporting`] hub.
11877///
11878/// # Example
11879///
11880/// Instantiate a resource builder
11881///
11882/// ```test_harness,no_run
11883/// extern crate hyper;
11884/// extern crate hyper_rustls;
11885/// extern crate google_dfareporting3d2 as dfareporting3d2;
11886///
11887/// # async fn dox() {
11888/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11889///
11890/// let secret: yup_oauth2::ApplicationSecret = Default::default();
11891/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11892///     secret,
11893///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11894/// ).build().await.unwrap();
11895///
11896/// let client = hyper_util::client::legacy::Client::builder(
11897///     hyper_util::rt::TokioExecutor::new()
11898/// )
11899/// .build(
11900///     hyper_rustls::HttpsConnectorBuilder::new()
11901///         .with_native_roots()
11902///         .unwrap()
11903///         .https_or_http()
11904///         .enable_http1()
11905///         .build()
11906/// );
11907/// let mut hub = Dfareporting::new(client, auth);
11908/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
11909/// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)`
11910/// // to build up your call.
11911/// let rb = hub.floodlight_configurations();
11912/// # }
11913/// ```
11914pub struct FloodlightConfigurationMethods<'a, C>
11915where
11916    C: 'a,
11917{
11918    hub: &'a Dfareporting<C>,
11919}
11920
11921impl<'a, C> common::MethodsBuilder for FloodlightConfigurationMethods<'a, C> {}
11922
11923impl<'a, C> FloodlightConfigurationMethods<'a, C> {
11924    /// Create a builder to help you perform the following task:
11925    ///
11926    /// Gets one floodlight configuration by ID.
11927    ///
11928    /// # Arguments
11929    ///
11930    /// * `profileId` - User profile ID associated with this request.
11931    /// * `id` - Floodlight configuration ID.
11932    pub fn get(&self, profile_id: i64, id: i64) -> FloodlightConfigurationGetCall<'a, C> {
11933        FloodlightConfigurationGetCall {
11934            hub: self.hub,
11935            _profile_id: profile_id,
11936            _id: id,
11937            _delegate: Default::default(),
11938            _additional_params: Default::default(),
11939            _scopes: Default::default(),
11940        }
11941    }
11942
11943    /// Create a builder to help you perform the following task:
11944    ///
11945    /// Retrieves a list of floodlight configurations, possibly filtered.
11946    ///
11947    /// # Arguments
11948    ///
11949    /// * `profileId` - User profile ID associated with this request.
11950    pub fn list(&self, profile_id: i64) -> FloodlightConfigurationListCall<'a, C> {
11951        FloodlightConfigurationListCall {
11952            hub: self.hub,
11953            _profile_id: profile_id,
11954            _ids: Default::default(),
11955            _delegate: Default::default(),
11956            _additional_params: Default::default(),
11957            _scopes: Default::default(),
11958        }
11959    }
11960
11961    /// Create a builder to help you perform the following task:
11962    ///
11963    /// Updates an existing floodlight configuration. This method supports patch semantics.
11964    ///
11965    /// # Arguments
11966    ///
11967    /// * `request` - No description provided.
11968    /// * `profileId` - User profile ID associated with this request.
11969    /// * `id` - Floodlight configuration ID.
11970    pub fn patch(
11971        &self,
11972        request: FloodlightConfiguration,
11973        profile_id: i64,
11974        id: i64,
11975    ) -> FloodlightConfigurationPatchCall<'a, C> {
11976        FloodlightConfigurationPatchCall {
11977            hub: self.hub,
11978            _request: request,
11979            _profile_id: profile_id,
11980            _id: id,
11981            _delegate: Default::default(),
11982            _additional_params: Default::default(),
11983            _scopes: Default::default(),
11984        }
11985    }
11986
11987    /// Create a builder to help you perform the following task:
11988    ///
11989    /// Updates an existing floodlight configuration.
11990    ///
11991    /// # Arguments
11992    ///
11993    /// * `request` - No description provided.
11994    /// * `profileId` - User profile ID associated with this request.
11995    pub fn update(
11996        &self,
11997        request: FloodlightConfiguration,
11998        profile_id: i64,
11999    ) -> FloodlightConfigurationUpdateCall<'a, C> {
12000        FloodlightConfigurationUpdateCall {
12001            hub: self.hub,
12002            _request: request,
12003            _profile_id: profile_id,
12004            _delegate: Default::default(),
12005            _additional_params: Default::default(),
12006            _scopes: Default::default(),
12007        }
12008    }
12009}
12010
12011/// A builder providing access to all methods supported on *inventoryItem* resources.
12012/// It is not used directly, but through the [`Dfareporting`] hub.
12013///
12014/// # Example
12015///
12016/// Instantiate a resource builder
12017///
12018/// ```test_harness,no_run
12019/// extern crate hyper;
12020/// extern crate hyper_rustls;
12021/// extern crate google_dfareporting3d2 as dfareporting3d2;
12022///
12023/// # async fn dox() {
12024/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12025///
12026/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12027/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12028///     secret,
12029///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12030/// ).build().await.unwrap();
12031///
12032/// let client = hyper_util::client::legacy::Client::builder(
12033///     hyper_util::rt::TokioExecutor::new()
12034/// )
12035/// .build(
12036///     hyper_rustls::HttpsConnectorBuilder::new()
12037///         .with_native_roots()
12038///         .unwrap()
12039///         .https_or_http()
12040///         .enable_http1()
12041///         .build()
12042/// );
12043/// let mut hub = Dfareporting::new(client, auth);
12044/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12045/// // like `get(...)` and `list(...)`
12046/// // to build up your call.
12047/// let rb = hub.inventory_items();
12048/// # }
12049/// ```
12050pub struct InventoryItemMethods<'a, C>
12051where
12052    C: 'a,
12053{
12054    hub: &'a Dfareporting<C>,
12055}
12056
12057impl<'a, C> common::MethodsBuilder for InventoryItemMethods<'a, C> {}
12058
12059impl<'a, C> InventoryItemMethods<'a, C> {
12060    /// Create a builder to help you perform the following task:
12061    ///
12062    /// Gets one inventory item by ID.
12063    ///
12064    /// # Arguments
12065    ///
12066    /// * `profileId` - User profile ID associated with this request.
12067    /// * `projectId` - Project ID for order documents.
12068    /// * `id` - Inventory item ID.
12069    pub fn get(&self, profile_id: i64, project_id: i64, id: i64) -> InventoryItemGetCall<'a, C> {
12070        InventoryItemGetCall {
12071            hub: self.hub,
12072            _profile_id: profile_id,
12073            _project_id: project_id,
12074            _id: id,
12075            _delegate: Default::default(),
12076            _additional_params: Default::default(),
12077            _scopes: Default::default(),
12078        }
12079    }
12080
12081    /// Create a builder to help you perform the following task:
12082    ///
12083    /// Retrieves a list of inventory items, possibly filtered. This method supports paging.
12084    ///
12085    /// # Arguments
12086    ///
12087    /// * `profileId` - User profile ID associated with this request.
12088    /// * `projectId` - Project ID for order documents.
12089    pub fn list(&self, profile_id: i64, project_id: i64) -> InventoryItemListCall<'a, C> {
12090        InventoryItemListCall {
12091            hub: self.hub,
12092            _profile_id: profile_id,
12093            _project_id: project_id,
12094            _type_: Default::default(),
12095            _sort_order: Default::default(),
12096            _sort_field: Default::default(),
12097            _site_id: Default::default(),
12098            _page_token: Default::default(),
12099            _order_id: Default::default(),
12100            _max_results: Default::default(),
12101            _in_plan: Default::default(),
12102            _ids: Default::default(),
12103            _delegate: Default::default(),
12104            _additional_params: Default::default(),
12105            _scopes: Default::default(),
12106        }
12107    }
12108}
12109
12110/// A builder providing access to all methods supported on *language* resources.
12111/// It is not used directly, but through the [`Dfareporting`] hub.
12112///
12113/// # Example
12114///
12115/// Instantiate a resource builder
12116///
12117/// ```test_harness,no_run
12118/// extern crate hyper;
12119/// extern crate hyper_rustls;
12120/// extern crate google_dfareporting3d2 as dfareporting3d2;
12121///
12122/// # async fn dox() {
12123/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12124///
12125/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12126/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12127///     secret,
12128///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12129/// ).build().await.unwrap();
12130///
12131/// let client = hyper_util::client::legacy::Client::builder(
12132///     hyper_util::rt::TokioExecutor::new()
12133/// )
12134/// .build(
12135///     hyper_rustls::HttpsConnectorBuilder::new()
12136///         .with_native_roots()
12137///         .unwrap()
12138///         .https_or_http()
12139///         .enable_http1()
12140///         .build()
12141/// );
12142/// let mut hub = Dfareporting::new(client, auth);
12143/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12144/// // like `list(...)`
12145/// // to build up your call.
12146/// let rb = hub.languages();
12147/// # }
12148/// ```
12149pub struct LanguageMethods<'a, C>
12150where
12151    C: 'a,
12152{
12153    hub: &'a Dfareporting<C>,
12154}
12155
12156impl<'a, C> common::MethodsBuilder for LanguageMethods<'a, C> {}
12157
12158impl<'a, C> LanguageMethods<'a, C> {
12159    /// Create a builder to help you perform the following task:
12160    ///
12161    /// Retrieves a list of languages.
12162    ///
12163    /// # Arguments
12164    ///
12165    /// * `profileId` - User profile ID associated with this request.
12166    pub fn list(&self, profile_id: i64) -> LanguageListCall<'a, C> {
12167        LanguageListCall {
12168            hub: self.hub,
12169            _profile_id: profile_id,
12170            _delegate: Default::default(),
12171            _additional_params: Default::default(),
12172            _scopes: Default::default(),
12173        }
12174    }
12175}
12176
12177/// A builder providing access to all methods supported on *metro* resources.
12178/// It is not used directly, but through the [`Dfareporting`] hub.
12179///
12180/// # Example
12181///
12182/// Instantiate a resource builder
12183///
12184/// ```test_harness,no_run
12185/// extern crate hyper;
12186/// extern crate hyper_rustls;
12187/// extern crate google_dfareporting3d2 as dfareporting3d2;
12188///
12189/// # async fn dox() {
12190/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12191///
12192/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12193/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12194///     secret,
12195///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12196/// ).build().await.unwrap();
12197///
12198/// let client = hyper_util::client::legacy::Client::builder(
12199///     hyper_util::rt::TokioExecutor::new()
12200/// )
12201/// .build(
12202///     hyper_rustls::HttpsConnectorBuilder::new()
12203///         .with_native_roots()
12204///         .unwrap()
12205///         .https_or_http()
12206///         .enable_http1()
12207///         .build()
12208/// );
12209/// let mut hub = Dfareporting::new(client, auth);
12210/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12211/// // like `list(...)`
12212/// // to build up your call.
12213/// let rb = hub.metros();
12214/// # }
12215/// ```
12216pub struct MetroMethods<'a, C>
12217where
12218    C: 'a,
12219{
12220    hub: &'a Dfareporting<C>,
12221}
12222
12223impl<'a, C> common::MethodsBuilder for MetroMethods<'a, C> {}
12224
12225impl<'a, C> MetroMethods<'a, C> {
12226    /// Create a builder to help you perform the following task:
12227    ///
12228    /// Retrieves a list of metros.
12229    ///
12230    /// # Arguments
12231    ///
12232    /// * `profileId` - User profile ID associated with this request.
12233    pub fn list(&self, profile_id: i64) -> MetroListCall<'a, C> {
12234        MetroListCall {
12235            hub: self.hub,
12236            _profile_id: profile_id,
12237            _delegate: Default::default(),
12238            _additional_params: Default::default(),
12239            _scopes: Default::default(),
12240        }
12241    }
12242}
12243
12244/// A builder providing access to all methods supported on *mobileApp* resources.
12245/// It is not used directly, but through the [`Dfareporting`] hub.
12246///
12247/// # Example
12248///
12249/// Instantiate a resource builder
12250///
12251/// ```test_harness,no_run
12252/// extern crate hyper;
12253/// extern crate hyper_rustls;
12254/// extern crate google_dfareporting3d2 as dfareporting3d2;
12255///
12256/// # async fn dox() {
12257/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12258///
12259/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12260/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12261///     secret,
12262///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12263/// ).build().await.unwrap();
12264///
12265/// let client = hyper_util::client::legacy::Client::builder(
12266///     hyper_util::rt::TokioExecutor::new()
12267/// )
12268/// .build(
12269///     hyper_rustls::HttpsConnectorBuilder::new()
12270///         .with_native_roots()
12271///         .unwrap()
12272///         .https_or_http()
12273///         .enable_http1()
12274///         .build()
12275/// );
12276/// let mut hub = Dfareporting::new(client, auth);
12277/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12278/// // like `get(...)` and `list(...)`
12279/// // to build up your call.
12280/// let rb = hub.mobile_apps();
12281/// # }
12282/// ```
12283pub struct MobileAppMethods<'a, C>
12284where
12285    C: 'a,
12286{
12287    hub: &'a Dfareporting<C>,
12288}
12289
12290impl<'a, C> common::MethodsBuilder for MobileAppMethods<'a, C> {}
12291
12292impl<'a, C> MobileAppMethods<'a, C> {
12293    /// Create a builder to help you perform the following task:
12294    ///
12295    /// Gets one mobile app by ID.
12296    ///
12297    /// # Arguments
12298    ///
12299    /// * `profileId` - User profile ID associated with this request.
12300    /// * `id` - Mobile app ID.
12301    pub fn get(&self, profile_id: i64, id: &str) -> MobileAppGetCall<'a, C> {
12302        MobileAppGetCall {
12303            hub: self.hub,
12304            _profile_id: profile_id,
12305            _id: id.to_string(),
12306            _delegate: Default::default(),
12307            _additional_params: Default::default(),
12308            _scopes: Default::default(),
12309        }
12310    }
12311
12312    /// Create a builder to help you perform the following task:
12313    ///
12314    /// Retrieves list of available mobile apps.
12315    ///
12316    /// # Arguments
12317    ///
12318    /// * `profileId` - User profile ID associated with this request.
12319    pub fn list(&self, profile_id: i64) -> MobileAppListCall<'a, C> {
12320        MobileAppListCall {
12321            hub: self.hub,
12322            _profile_id: profile_id,
12323            _search_string: Default::default(),
12324            _page_token: Default::default(),
12325            _max_results: Default::default(),
12326            _ids: Default::default(),
12327            _directories: Default::default(),
12328            _delegate: Default::default(),
12329            _additional_params: Default::default(),
12330            _scopes: Default::default(),
12331        }
12332    }
12333}
12334
12335/// A builder providing access to all methods supported on *mobileCarrier* resources.
12336/// It is not used directly, but through the [`Dfareporting`] hub.
12337///
12338/// # Example
12339///
12340/// Instantiate a resource builder
12341///
12342/// ```test_harness,no_run
12343/// extern crate hyper;
12344/// extern crate hyper_rustls;
12345/// extern crate google_dfareporting3d2 as dfareporting3d2;
12346///
12347/// # async fn dox() {
12348/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12349///
12350/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12351/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12352///     secret,
12353///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12354/// ).build().await.unwrap();
12355///
12356/// let client = hyper_util::client::legacy::Client::builder(
12357///     hyper_util::rt::TokioExecutor::new()
12358/// )
12359/// .build(
12360///     hyper_rustls::HttpsConnectorBuilder::new()
12361///         .with_native_roots()
12362///         .unwrap()
12363///         .https_or_http()
12364///         .enable_http1()
12365///         .build()
12366/// );
12367/// let mut hub = Dfareporting::new(client, auth);
12368/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12369/// // like `get(...)` and `list(...)`
12370/// // to build up your call.
12371/// let rb = hub.mobile_carriers();
12372/// # }
12373/// ```
12374pub struct MobileCarrierMethods<'a, C>
12375where
12376    C: 'a,
12377{
12378    hub: &'a Dfareporting<C>,
12379}
12380
12381impl<'a, C> common::MethodsBuilder for MobileCarrierMethods<'a, C> {}
12382
12383impl<'a, C> MobileCarrierMethods<'a, C> {
12384    /// Create a builder to help you perform the following task:
12385    ///
12386    /// Gets one mobile carrier by ID.
12387    ///
12388    /// # Arguments
12389    ///
12390    /// * `profileId` - User profile ID associated with this request.
12391    /// * `id` - Mobile carrier ID.
12392    pub fn get(&self, profile_id: i64, id: i64) -> MobileCarrierGetCall<'a, C> {
12393        MobileCarrierGetCall {
12394            hub: self.hub,
12395            _profile_id: profile_id,
12396            _id: id,
12397            _delegate: Default::default(),
12398            _additional_params: Default::default(),
12399            _scopes: Default::default(),
12400        }
12401    }
12402
12403    /// Create a builder to help you perform the following task:
12404    ///
12405    /// Retrieves a list of mobile carriers.
12406    ///
12407    /// # Arguments
12408    ///
12409    /// * `profileId` - User profile ID associated with this request.
12410    pub fn list(&self, profile_id: i64) -> MobileCarrierListCall<'a, C> {
12411        MobileCarrierListCall {
12412            hub: self.hub,
12413            _profile_id: profile_id,
12414            _delegate: Default::default(),
12415            _additional_params: Default::default(),
12416            _scopes: Default::default(),
12417        }
12418    }
12419}
12420
12421/// A builder providing access to all methods supported on *operatingSystemVersion* resources.
12422/// It is not used directly, but through the [`Dfareporting`] hub.
12423///
12424/// # Example
12425///
12426/// Instantiate a resource builder
12427///
12428/// ```test_harness,no_run
12429/// extern crate hyper;
12430/// extern crate hyper_rustls;
12431/// extern crate google_dfareporting3d2 as dfareporting3d2;
12432///
12433/// # async fn dox() {
12434/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12435///
12436/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12437/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12438///     secret,
12439///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12440/// ).build().await.unwrap();
12441///
12442/// let client = hyper_util::client::legacy::Client::builder(
12443///     hyper_util::rt::TokioExecutor::new()
12444/// )
12445/// .build(
12446///     hyper_rustls::HttpsConnectorBuilder::new()
12447///         .with_native_roots()
12448///         .unwrap()
12449///         .https_or_http()
12450///         .enable_http1()
12451///         .build()
12452/// );
12453/// let mut hub = Dfareporting::new(client, auth);
12454/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12455/// // like `get(...)` and `list(...)`
12456/// // to build up your call.
12457/// let rb = hub.operating_system_versions();
12458/// # }
12459/// ```
12460pub struct OperatingSystemVersionMethods<'a, C>
12461where
12462    C: 'a,
12463{
12464    hub: &'a Dfareporting<C>,
12465}
12466
12467impl<'a, C> common::MethodsBuilder for OperatingSystemVersionMethods<'a, C> {}
12468
12469impl<'a, C> OperatingSystemVersionMethods<'a, C> {
12470    /// Create a builder to help you perform the following task:
12471    ///
12472    /// Gets one operating system version by ID.
12473    ///
12474    /// # Arguments
12475    ///
12476    /// * `profileId` - User profile ID associated with this request.
12477    /// * `id` - Operating system version ID.
12478    pub fn get(&self, profile_id: i64, id: i64) -> OperatingSystemVersionGetCall<'a, C> {
12479        OperatingSystemVersionGetCall {
12480            hub: self.hub,
12481            _profile_id: profile_id,
12482            _id: id,
12483            _delegate: Default::default(),
12484            _additional_params: Default::default(),
12485            _scopes: Default::default(),
12486        }
12487    }
12488
12489    /// Create a builder to help you perform the following task:
12490    ///
12491    /// Retrieves a list of operating system versions.
12492    ///
12493    /// # Arguments
12494    ///
12495    /// * `profileId` - User profile ID associated with this request.
12496    pub fn list(&self, profile_id: i64) -> OperatingSystemVersionListCall<'a, C> {
12497        OperatingSystemVersionListCall {
12498            hub: self.hub,
12499            _profile_id: profile_id,
12500            _delegate: Default::default(),
12501            _additional_params: Default::default(),
12502            _scopes: Default::default(),
12503        }
12504    }
12505}
12506
12507/// A builder providing access to all methods supported on *operatingSystem* resources.
12508/// It is not used directly, but through the [`Dfareporting`] hub.
12509///
12510/// # Example
12511///
12512/// Instantiate a resource builder
12513///
12514/// ```test_harness,no_run
12515/// extern crate hyper;
12516/// extern crate hyper_rustls;
12517/// extern crate google_dfareporting3d2 as dfareporting3d2;
12518///
12519/// # async fn dox() {
12520/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12521///
12522/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12523/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12524///     secret,
12525///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12526/// ).build().await.unwrap();
12527///
12528/// let client = hyper_util::client::legacy::Client::builder(
12529///     hyper_util::rt::TokioExecutor::new()
12530/// )
12531/// .build(
12532///     hyper_rustls::HttpsConnectorBuilder::new()
12533///         .with_native_roots()
12534///         .unwrap()
12535///         .https_or_http()
12536///         .enable_http1()
12537///         .build()
12538/// );
12539/// let mut hub = Dfareporting::new(client, auth);
12540/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12541/// // like `get(...)` and `list(...)`
12542/// // to build up your call.
12543/// let rb = hub.operating_systems();
12544/// # }
12545/// ```
12546pub struct OperatingSystemMethods<'a, C>
12547where
12548    C: 'a,
12549{
12550    hub: &'a Dfareporting<C>,
12551}
12552
12553impl<'a, C> common::MethodsBuilder for OperatingSystemMethods<'a, C> {}
12554
12555impl<'a, C> OperatingSystemMethods<'a, C> {
12556    /// Create a builder to help you perform the following task:
12557    ///
12558    /// Gets one operating system by DART ID.
12559    ///
12560    /// # Arguments
12561    ///
12562    /// * `profileId` - User profile ID associated with this request.
12563    /// * `dartId` - Operating system DART ID.
12564    pub fn get(&self, profile_id: i64, dart_id: i64) -> OperatingSystemGetCall<'a, C> {
12565        OperatingSystemGetCall {
12566            hub: self.hub,
12567            _profile_id: profile_id,
12568            _dart_id: dart_id,
12569            _delegate: Default::default(),
12570            _additional_params: Default::default(),
12571            _scopes: Default::default(),
12572        }
12573    }
12574
12575    /// Create a builder to help you perform the following task:
12576    ///
12577    /// Retrieves a list of operating systems.
12578    ///
12579    /// # Arguments
12580    ///
12581    /// * `profileId` - User profile ID associated with this request.
12582    pub fn list(&self, profile_id: i64) -> OperatingSystemListCall<'a, C> {
12583        OperatingSystemListCall {
12584            hub: self.hub,
12585            _profile_id: profile_id,
12586            _delegate: Default::default(),
12587            _additional_params: Default::default(),
12588            _scopes: Default::default(),
12589        }
12590    }
12591}
12592
12593/// A builder providing access to all methods supported on *orderDocument* resources.
12594/// It is not used directly, but through the [`Dfareporting`] hub.
12595///
12596/// # Example
12597///
12598/// Instantiate a resource builder
12599///
12600/// ```test_harness,no_run
12601/// extern crate hyper;
12602/// extern crate hyper_rustls;
12603/// extern crate google_dfareporting3d2 as dfareporting3d2;
12604///
12605/// # async fn dox() {
12606/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12607///
12608/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12609/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12610///     secret,
12611///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12612/// ).build().await.unwrap();
12613///
12614/// let client = hyper_util::client::legacy::Client::builder(
12615///     hyper_util::rt::TokioExecutor::new()
12616/// )
12617/// .build(
12618///     hyper_rustls::HttpsConnectorBuilder::new()
12619///         .with_native_roots()
12620///         .unwrap()
12621///         .https_or_http()
12622///         .enable_http1()
12623///         .build()
12624/// );
12625/// let mut hub = Dfareporting::new(client, auth);
12626/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12627/// // like `get(...)` and `list(...)`
12628/// // to build up your call.
12629/// let rb = hub.order_documents();
12630/// # }
12631/// ```
12632pub struct OrderDocumentMethods<'a, C>
12633where
12634    C: 'a,
12635{
12636    hub: &'a Dfareporting<C>,
12637}
12638
12639impl<'a, C> common::MethodsBuilder for OrderDocumentMethods<'a, C> {}
12640
12641impl<'a, C> OrderDocumentMethods<'a, C> {
12642    /// Create a builder to help you perform the following task:
12643    ///
12644    /// Gets one order document by ID.
12645    ///
12646    /// # Arguments
12647    ///
12648    /// * `profileId` - User profile ID associated with this request.
12649    /// * `projectId` - Project ID for order documents.
12650    /// * `id` - Order document ID.
12651    pub fn get(&self, profile_id: i64, project_id: i64, id: i64) -> OrderDocumentGetCall<'a, C> {
12652        OrderDocumentGetCall {
12653            hub: self.hub,
12654            _profile_id: profile_id,
12655            _project_id: project_id,
12656            _id: id,
12657            _delegate: Default::default(),
12658            _additional_params: Default::default(),
12659            _scopes: Default::default(),
12660        }
12661    }
12662
12663    /// Create a builder to help you perform the following task:
12664    ///
12665    /// Retrieves a list of order documents, possibly filtered. This method supports paging.
12666    ///
12667    /// # Arguments
12668    ///
12669    /// * `profileId` - User profile ID associated with this request.
12670    /// * `projectId` - Project ID for order documents.
12671    pub fn list(&self, profile_id: i64, project_id: i64) -> OrderDocumentListCall<'a, C> {
12672        OrderDocumentListCall {
12673            hub: self.hub,
12674            _profile_id: profile_id,
12675            _project_id: project_id,
12676            _sort_order: Default::default(),
12677            _sort_field: Default::default(),
12678            _site_id: Default::default(),
12679            _search_string: Default::default(),
12680            _page_token: Default::default(),
12681            _order_id: Default::default(),
12682            _max_results: Default::default(),
12683            _ids: Default::default(),
12684            _approved: Default::default(),
12685            _delegate: Default::default(),
12686            _additional_params: Default::default(),
12687            _scopes: Default::default(),
12688        }
12689    }
12690}
12691
12692/// A builder providing access to all methods supported on *order* resources.
12693/// It is not used directly, but through the [`Dfareporting`] hub.
12694///
12695/// # Example
12696///
12697/// Instantiate a resource builder
12698///
12699/// ```test_harness,no_run
12700/// extern crate hyper;
12701/// extern crate hyper_rustls;
12702/// extern crate google_dfareporting3d2 as dfareporting3d2;
12703///
12704/// # async fn dox() {
12705/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12706///
12707/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12708/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12709///     secret,
12710///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12711/// ).build().await.unwrap();
12712///
12713/// let client = hyper_util::client::legacy::Client::builder(
12714///     hyper_util::rt::TokioExecutor::new()
12715/// )
12716/// .build(
12717///     hyper_rustls::HttpsConnectorBuilder::new()
12718///         .with_native_roots()
12719///         .unwrap()
12720///         .https_or_http()
12721///         .enable_http1()
12722///         .build()
12723/// );
12724/// let mut hub = Dfareporting::new(client, auth);
12725/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12726/// // like `get(...)` and `list(...)`
12727/// // to build up your call.
12728/// let rb = hub.orders();
12729/// # }
12730/// ```
12731pub struct OrderMethods<'a, C>
12732where
12733    C: 'a,
12734{
12735    hub: &'a Dfareporting<C>,
12736}
12737
12738impl<'a, C> common::MethodsBuilder for OrderMethods<'a, C> {}
12739
12740impl<'a, C> OrderMethods<'a, C> {
12741    /// Create a builder to help you perform the following task:
12742    ///
12743    /// Gets one order by ID.
12744    ///
12745    /// # Arguments
12746    ///
12747    /// * `profileId` - User profile ID associated with this request.
12748    /// * `projectId` - Project ID for orders.
12749    /// * `id` - Order ID.
12750    pub fn get(&self, profile_id: i64, project_id: i64, id: i64) -> OrderGetCall<'a, C> {
12751        OrderGetCall {
12752            hub: self.hub,
12753            _profile_id: profile_id,
12754            _project_id: project_id,
12755            _id: id,
12756            _delegate: Default::default(),
12757            _additional_params: Default::default(),
12758            _scopes: Default::default(),
12759        }
12760    }
12761
12762    /// Create a builder to help you perform the following task:
12763    ///
12764    /// Retrieves a list of orders, possibly filtered. This method supports paging.
12765    ///
12766    /// # Arguments
12767    ///
12768    /// * `profileId` - User profile ID associated with this request.
12769    /// * `projectId` - Project ID for orders.
12770    pub fn list(&self, profile_id: i64, project_id: i64) -> OrderListCall<'a, C> {
12771        OrderListCall {
12772            hub: self.hub,
12773            _profile_id: profile_id,
12774            _project_id: project_id,
12775            _sort_order: Default::default(),
12776            _sort_field: Default::default(),
12777            _site_id: Default::default(),
12778            _search_string: Default::default(),
12779            _page_token: Default::default(),
12780            _max_results: Default::default(),
12781            _ids: Default::default(),
12782            _delegate: Default::default(),
12783            _additional_params: Default::default(),
12784            _scopes: Default::default(),
12785        }
12786    }
12787}
12788
12789/// A builder providing access to all methods supported on *placementGroup* resources.
12790/// It is not used directly, but through the [`Dfareporting`] hub.
12791///
12792/// # Example
12793///
12794/// Instantiate a resource builder
12795///
12796/// ```test_harness,no_run
12797/// extern crate hyper;
12798/// extern crate hyper_rustls;
12799/// extern crate google_dfareporting3d2 as dfareporting3d2;
12800///
12801/// # async fn dox() {
12802/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12803///
12804/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12805/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12806///     secret,
12807///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12808/// ).build().await.unwrap();
12809///
12810/// let client = hyper_util::client::legacy::Client::builder(
12811///     hyper_util::rt::TokioExecutor::new()
12812/// )
12813/// .build(
12814///     hyper_rustls::HttpsConnectorBuilder::new()
12815///         .with_native_roots()
12816///         .unwrap()
12817///         .https_or_http()
12818///         .enable_http1()
12819///         .build()
12820/// );
12821/// let mut hub = Dfareporting::new(client, auth);
12822/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
12823/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
12824/// // to build up your call.
12825/// let rb = hub.placement_groups();
12826/// # }
12827/// ```
12828pub struct PlacementGroupMethods<'a, C>
12829where
12830    C: 'a,
12831{
12832    hub: &'a Dfareporting<C>,
12833}
12834
12835impl<'a, C> common::MethodsBuilder for PlacementGroupMethods<'a, C> {}
12836
12837impl<'a, C> PlacementGroupMethods<'a, C> {
12838    /// Create a builder to help you perform the following task:
12839    ///
12840    /// Gets one placement group by ID.
12841    ///
12842    /// # Arguments
12843    ///
12844    /// * `profileId` - User profile ID associated with this request.
12845    /// * `id` - Placement group ID.
12846    pub fn get(&self, profile_id: i64, id: i64) -> PlacementGroupGetCall<'a, C> {
12847        PlacementGroupGetCall {
12848            hub: self.hub,
12849            _profile_id: profile_id,
12850            _id: id,
12851            _delegate: Default::default(),
12852            _additional_params: Default::default(),
12853            _scopes: Default::default(),
12854        }
12855    }
12856
12857    /// Create a builder to help you perform the following task:
12858    ///
12859    /// Inserts a new placement group.
12860    ///
12861    /// # Arguments
12862    ///
12863    /// * `request` - No description provided.
12864    /// * `profileId` - User profile ID associated with this request.
12865    pub fn insert(
12866        &self,
12867        request: PlacementGroup,
12868        profile_id: i64,
12869    ) -> PlacementGroupInsertCall<'a, C> {
12870        PlacementGroupInsertCall {
12871            hub: self.hub,
12872            _request: request,
12873            _profile_id: profile_id,
12874            _delegate: Default::default(),
12875            _additional_params: Default::default(),
12876            _scopes: Default::default(),
12877        }
12878    }
12879
12880    /// Create a builder to help you perform the following task:
12881    ///
12882    /// Retrieves a list of placement groups, possibly filtered. This method supports paging.
12883    ///
12884    /// # Arguments
12885    ///
12886    /// * `profileId` - User profile ID associated with this request.
12887    pub fn list(&self, profile_id: i64) -> PlacementGroupListCall<'a, C> {
12888        PlacementGroupListCall {
12889            hub: self.hub,
12890            _profile_id: profile_id,
12891            _sort_order: Default::default(),
12892            _sort_field: Default::default(),
12893            _site_ids: Default::default(),
12894            _search_string: Default::default(),
12895            _pricing_types: Default::default(),
12896            _placement_strategy_ids: Default::default(),
12897            _placement_group_type: Default::default(),
12898            _page_token: Default::default(),
12899            _min_start_date: Default::default(),
12900            _min_end_date: Default::default(),
12901            _max_start_date: Default::default(),
12902            _max_results: Default::default(),
12903            _max_end_date: Default::default(),
12904            _ids: Default::default(),
12905            _directory_site_ids: Default::default(),
12906            _content_category_ids: Default::default(),
12907            _campaign_ids: Default::default(),
12908            _archived: Default::default(),
12909            _advertiser_ids: Default::default(),
12910            _delegate: Default::default(),
12911            _additional_params: Default::default(),
12912            _scopes: Default::default(),
12913        }
12914    }
12915
12916    /// Create a builder to help you perform the following task:
12917    ///
12918    /// Updates an existing placement group. This method supports patch semantics.
12919    ///
12920    /// # Arguments
12921    ///
12922    /// * `request` - No description provided.
12923    /// * `profileId` - User profile ID associated with this request.
12924    /// * `id` - Placement group ID.
12925    pub fn patch(
12926        &self,
12927        request: PlacementGroup,
12928        profile_id: i64,
12929        id: i64,
12930    ) -> PlacementGroupPatchCall<'a, C> {
12931        PlacementGroupPatchCall {
12932            hub: self.hub,
12933            _request: request,
12934            _profile_id: profile_id,
12935            _id: id,
12936            _delegate: Default::default(),
12937            _additional_params: Default::default(),
12938            _scopes: Default::default(),
12939        }
12940    }
12941
12942    /// Create a builder to help you perform the following task:
12943    ///
12944    /// Updates an existing placement group.
12945    ///
12946    /// # Arguments
12947    ///
12948    /// * `request` - No description provided.
12949    /// * `profileId` - User profile ID associated with this request.
12950    pub fn update(
12951        &self,
12952        request: PlacementGroup,
12953        profile_id: i64,
12954    ) -> PlacementGroupUpdateCall<'a, C> {
12955        PlacementGroupUpdateCall {
12956            hub: self.hub,
12957            _request: request,
12958            _profile_id: profile_id,
12959            _delegate: Default::default(),
12960            _additional_params: Default::default(),
12961            _scopes: Default::default(),
12962        }
12963    }
12964}
12965
12966/// A builder providing access to all methods supported on *placementStrategy* resources.
12967/// It is not used directly, but through the [`Dfareporting`] hub.
12968///
12969/// # Example
12970///
12971/// Instantiate a resource builder
12972///
12973/// ```test_harness,no_run
12974/// extern crate hyper;
12975/// extern crate hyper_rustls;
12976/// extern crate google_dfareporting3d2 as dfareporting3d2;
12977///
12978/// # async fn dox() {
12979/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12980///
12981/// let secret: yup_oauth2::ApplicationSecret = Default::default();
12982/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12983///     secret,
12984///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12985/// ).build().await.unwrap();
12986///
12987/// let client = hyper_util::client::legacy::Client::builder(
12988///     hyper_util::rt::TokioExecutor::new()
12989/// )
12990/// .build(
12991///     hyper_rustls::HttpsConnectorBuilder::new()
12992///         .with_native_roots()
12993///         .unwrap()
12994///         .https_or_http()
12995///         .enable_http1()
12996///         .build()
12997/// );
12998/// let mut hub = Dfareporting::new(client, auth);
12999/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13000/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
13001/// // to build up your call.
13002/// let rb = hub.placement_strategies();
13003/// # }
13004/// ```
13005pub struct PlacementStrategyMethods<'a, C>
13006where
13007    C: 'a,
13008{
13009    hub: &'a Dfareporting<C>,
13010}
13011
13012impl<'a, C> common::MethodsBuilder for PlacementStrategyMethods<'a, C> {}
13013
13014impl<'a, C> PlacementStrategyMethods<'a, C> {
13015    /// Create a builder to help you perform the following task:
13016    ///
13017    /// Deletes an existing placement strategy.
13018    ///
13019    /// # Arguments
13020    ///
13021    /// * `profileId` - User profile ID associated with this request.
13022    /// * `id` - Placement strategy ID.
13023    pub fn delete(&self, profile_id: i64, id: i64) -> PlacementStrategyDeleteCall<'a, C> {
13024        PlacementStrategyDeleteCall {
13025            hub: self.hub,
13026            _profile_id: profile_id,
13027            _id: id,
13028            _delegate: Default::default(),
13029            _additional_params: Default::default(),
13030            _scopes: Default::default(),
13031        }
13032    }
13033
13034    /// Create a builder to help you perform the following task:
13035    ///
13036    /// Gets one placement strategy by ID.
13037    ///
13038    /// # Arguments
13039    ///
13040    /// * `profileId` - User profile ID associated with this request.
13041    /// * `id` - Placement strategy ID.
13042    pub fn get(&self, profile_id: i64, id: i64) -> PlacementStrategyGetCall<'a, C> {
13043        PlacementStrategyGetCall {
13044            hub: self.hub,
13045            _profile_id: profile_id,
13046            _id: id,
13047            _delegate: Default::default(),
13048            _additional_params: Default::default(),
13049            _scopes: Default::default(),
13050        }
13051    }
13052
13053    /// Create a builder to help you perform the following task:
13054    ///
13055    /// Inserts a new placement strategy.
13056    ///
13057    /// # Arguments
13058    ///
13059    /// * `request` - No description provided.
13060    /// * `profileId` - User profile ID associated with this request.
13061    pub fn insert(
13062        &self,
13063        request: PlacementStrategy,
13064        profile_id: i64,
13065    ) -> PlacementStrategyInsertCall<'a, C> {
13066        PlacementStrategyInsertCall {
13067            hub: self.hub,
13068            _request: request,
13069            _profile_id: profile_id,
13070            _delegate: Default::default(),
13071            _additional_params: Default::default(),
13072            _scopes: Default::default(),
13073        }
13074    }
13075
13076    /// Create a builder to help you perform the following task:
13077    ///
13078    /// Retrieves a list of placement strategies, possibly filtered. This method supports paging.
13079    ///
13080    /// # Arguments
13081    ///
13082    /// * `profileId` - User profile ID associated with this request.
13083    pub fn list(&self, profile_id: i64) -> PlacementStrategyListCall<'a, C> {
13084        PlacementStrategyListCall {
13085            hub: self.hub,
13086            _profile_id: profile_id,
13087            _sort_order: Default::default(),
13088            _sort_field: Default::default(),
13089            _search_string: Default::default(),
13090            _page_token: Default::default(),
13091            _max_results: Default::default(),
13092            _ids: Default::default(),
13093            _delegate: Default::default(),
13094            _additional_params: Default::default(),
13095            _scopes: Default::default(),
13096        }
13097    }
13098
13099    /// Create a builder to help you perform the following task:
13100    ///
13101    /// Updates an existing placement strategy. This method supports patch semantics.
13102    ///
13103    /// # Arguments
13104    ///
13105    /// * `request` - No description provided.
13106    /// * `profileId` - User profile ID associated with this request.
13107    /// * `id` - Placement strategy ID.
13108    pub fn patch(
13109        &self,
13110        request: PlacementStrategy,
13111        profile_id: i64,
13112        id: i64,
13113    ) -> PlacementStrategyPatchCall<'a, C> {
13114        PlacementStrategyPatchCall {
13115            hub: self.hub,
13116            _request: request,
13117            _profile_id: profile_id,
13118            _id: id,
13119            _delegate: Default::default(),
13120            _additional_params: Default::default(),
13121            _scopes: Default::default(),
13122        }
13123    }
13124
13125    /// Create a builder to help you perform the following task:
13126    ///
13127    /// Updates an existing placement strategy.
13128    ///
13129    /// # Arguments
13130    ///
13131    /// * `request` - No description provided.
13132    /// * `profileId` - User profile ID associated with this request.
13133    pub fn update(
13134        &self,
13135        request: PlacementStrategy,
13136        profile_id: i64,
13137    ) -> PlacementStrategyUpdateCall<'a, C> {
13138        PlacementStrategyUpdateCall {
13139            hub: self.hub,
13140            _request: request,
13141            _profile_id: profile_id,
13142            _delegate: Default::default(),
13143            _additional_params: Default::default(),
13144            _scopes: Default::default(),
13145        }
13146    }
13147}
13148
13149/// A builder providing access to all methods supported on *placement* resources.
13150/// It is not used directly, but through the [`Dfareporting`] hub.
13151///
13152/// # Example
13153///
13154/// Instantiate a resource builder
13155///
13156/// ```test_harness,no_run
13157/// extern crate hyper;
13158/// extern crate hyper_rustls;
13159/// extern crate google_dfareporting3d2 as dfareporting3d2;
13160///
13161/// # async fn dox() {
13162/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13163///
13164/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13165/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13166///     secret,
13167///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13168/// ).build().await.unwrap();
13169///
13170/// let client = hyper_util::client::legacy::Client::builder(
13171///     hyper_util::rt::TokioExecutor::new()
13172/// )
13173/// .build(
13174///     hyper_rustls::HttpsConnectorBuilder::new()
13175///         .with_native_roots()
13176///         .unwrap()
13177///         .https_or_http()
13178///         .enable_http1()
13179///         .build()
13180/// );
13181/// let mut hub = Dfareporting::new(client, auth);
13182/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13183/// // like `generatetags(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
13184/// // to build up your call.
13185/// let rb = hub.placements();
13186/// # }
13187/// ```
13188pub struct PlacementMethods<'a, C>
13189where
13190    C: 'a,
13191{
13192    hub: &'a Dfareporting<C>,
13193}
13194
13195impl<'a, C> common::MethodsBuilder for PlacementMethods<'a, C> {}
13196
13197impl<'a, C> PlacementMethods<'a, C> {
13198    /// Create a builder to help you perform the following task:
13199    ///
13200    /// Generates tags for a placement.
13201    ///
13202    /// # Arguments
13203    ///
13204    /// * `profileId` - User profile ID associated with this request.
13205    pub fn generatetags(&self, profile_id: i64) -> PlacementGeneratetagCall<'a, C> {
13206        PlacementGeneratetagCall {
13207            hub: self.hub,
13208            _profile_id: profile_id,
13209            _tag_formats: Default::default(),
13210            _placement_ids: Default::default(),
13211            _campaign_id: Default::default(),
13212            _delegate: Default::default(),
13213            _additional_params: Default::default(),
13214            _scopes: Default::default(),
13215        }
13216    }
13217
13218    /// Create a builder to help you perform the following task:
13219    ///
13220    /// Gets one placement by ID.
13221    ///
13222    /// # Arguments
13223    ///
13224    /// * `profileId` - User profile ID associated with this request.
13225    /// * `id` - Placement ID.
13226    pub fn get(&self, profile_id: i64, id: i64) -> PlacementGetCall<'a, C> {
13227        PlacementGetCall {
13228            hub: self.hub,
13229            _profile_id: profile_id,
13230            _id: id,
13231            _delegate: Default::default(),
13232            _additional_params: Default::default(),
13233            _scopes: Default::default(),
13234        }
13235    }
13236
13237    /// Create a builder to help you perform the following task:
13238    ///
13239    /// Inserts a new placement.
13240    ///
13241    /// # Arguments
13242    ///
13243    /// * `request` - No description provided.
13244    /// * `profileId` - User profile ID associated with this request.
13245    pub fn insert(&self, request: Placement, profile_id: i64) -> PlacementInsertCall<'a, C> {
13246        PlacementInsertCall {
13247            hub: self.hub,
13248            _request: request,
13249            _profile_id: profile_id,
13250            _delegate: Default::default(),
13251            _additional_params: Default::default(),
13252            _scopes: Default::default(),
13253        }
13254    }
13255
13256    /// Create a builder to help you perform the following task:
13257    ///
13258    /// Retrieves a list of placements, possibly filtered. This method supports paging.
13259    ///
13260    /// # Arguments
13261    ///
13262    /// * `profileId` - User profile ID associated with this request.
13263    pub fn list(&self, profile_id: i64) -> PlacementListCall<'a, C> {
13264        PlacementListCall {
13265            hub: self.hub,
13266            _profile_id: profile_id,
13267            _sort_order: Default::default(),
13268            _sort_field: Default::default(),
13269            _size_ids: Default::default(),
13270            _site_ids: Default::default(),
13271            _search_string: Default::default(),
13272            _pricing_types: Default::default(),
13273            _placement_strategy_ids: Default::default(),
13274            _payment_source: Default::default(),
13275            _page_token: Default::default(),
13276            _min_start_date: Default::default(),
13277            _min_end_date: Default::default(),
13278            _max_start_date: Default::default(),
13279            _max_results: Default::default(),
13280            _max_end_date: Default::default(),
13281            _ids: Default::default(),
13282            _group_ids: Default::default(),
13283            _directory_site_ids: Default::default(),
13284            _content_category_ids: Default::default(),
13285            _compatibilities: Default::default(),
13286            _campaign_ids: Default::default(),
13287            _archived: Default::default(),
13288            _advertiser_ids: Default::default(),
13289            _delegate: Default::default(),
13290            _additional_params: Default::default(),
13291            _scopes: Default::default(),
13292        }
13293    }
13294
13295    /// Create a builder to help you perform the following task:
13296    ///
13297    /// Updates an existing placement. This method supports patch semantics.
13298    ///
13299    /// # Arguments
13300    ///
13301    /// * `request` - No description provided.
13302    /// * `profileId` - User profile ID associated with this request.
13303    /// * `id` - Placement ID.
13304    pub fn patch(&self, request: Placement, profile_id: i64, id: i64) -> PlacementPatchCall<'a, C> {
13305        PlacementPatchCall {
13306            hub: self.hub,
13307            _request: request,
13308            _profile_id: profile_id,
13309            _id: id,
13310            _delegate: Default::default(),
13311            _additional_params: Default::default(),
13312            _scopes: Default::default(),
13313        }
13314    }
13315
13316    /// Create a builder to help you perform the following task:
13317    ///
13318    /// Updates an existing placement.
13319    ///
13320    /// # Arguments
13321    ///
13322    /// * `request` - No description provided.
13323    /// * `profileId` - User profile ID associated with this request.
13324    pub fn update(&self, request: Placement, profile_id: i64) -> PlacementUpdateCall<'a, C> {
13325        PlacementUpdateCall {
13326            hub: self.hub,
13327            _request: request,
13328            _profile_id: profile_id,
13329            _delegate: Default::default(),
13330            _additional_params: Default::default(),
13331            _scopes: Default::default(),
13332        }
13333    }
13334}
13335
13336/// A builder providing access to all methods supported on *platformType* resources.
13337/// It is not used directly, but through the [`Dfareporting`] hub.
13338///
13339/// # Example
13340///
13341/// Instantiate a resource builder
13342///
13343/// ```test_harness,no_run
13344/// extern crate hyper;
13345/// extern crate hyper_rustls;
13346/// extern crate google_dfareporting3d2 as dfareporting3d2;
13347///
13348/// # async fn dox() {
13349/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13350///
13351/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13352/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13353///     secret,
13354///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13355/// ).build().await.unwrap();
13356///
13357/// let client = hyper_util::client::legacy::Client::builder(
13358///     hyper_util::rt::TokioExecutor::new()
13359/// )
13360/// .build(
13361///     hyper_rustls::HttpsConnectorBuilder::new()
13362///         .with_native_roots()
13363///         .unwrap()
13364///         .https_or_http()
13365///         .enable_http1()
13366///         .build()
13367/// );
13368/// let mut hub = Dfareporting::new(client, auth);
13369/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13370/// // like `get(...)` and `list(...)`
13371/// // to build up your call.
13372/// let rb = hub.platform_types();
13373/// # }
13374/// ```
13375pub struct PlatformTypeMethods<'a, C>
13376where
13377    C: 'a,
13378{
13379    hub: &'a Dfareporting<C>,
13380}
13381
13382impl<'a, C> common::MethodsBuilder for PlatformTypeMethods<'a, C> {}
13383
13384impl<'a, C> PlatformTypeMethods<'a, C> {
13385    /// Create a builder to help you perform the following task:
13386    ///
13387    /// Gets one platform type by ID.
13388    ///
13389    /// # Arguments
13390    ///
13391    /// * `profileId` - User profile ID associated with this request.
13392    /// * `id` - Platform type ID.
13393    pub fn get(&self, profile_id: i64, id: i64) -> PlatformTypeGetCall<'a, C> {
13394        PlatformTypeGetCall {
13395            hub: self.hub,
13396            _profile_id: profile_id,
13397            _id: id,
13398            _delegate: Default::default(),
13399            _additional_params: Default::default(),
13400            _scopes: Default::default(),
13401        }
13402    }
13403
13404    /// Create a builder to help you perform the following task:
13405    ///
13406    /// Retrieves a list of platform types.
13407    ///
13408    /// # Arguments
13409    ///
13410    /// * `profileId` - User profile ID associated with this request.
13411    pub fn list(&self, profile_id: i64) -> PlatformTypeListCall<'a, C> {
13412        PlatformTypeListCall {
13413            hub: self.hub,
13414            _profile_id: profile_id,
13415            _delegate: Default::default(),
13416            _additional_params: Default::default(),
13417            _scopes: Default::default(),
13418        }
13419    }
13420}
13421
13422/// A builder providing access to all methods supported on *postalCode* resources.
13423/// It is not used directly, but through the [`Dfareporting`] hub.
13424///
13425/// # Example
13426///
13427/// Instantiate a resource builder
13428///
13429/// ```test_harness,no_run
13430/// extern crate hyper;
13431/// extern crate hyper_rustls;
13432/// extern crate google_dfareporting3d2 as dfareporting3d2;
13433///
13434/// # async fn dox() {
13435/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13436///
13437/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13438/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13439///     secret,
13440///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13441/// ).build().await.unwrap();
13442///
13443/// let client = hyper_util::client::legacy::Client::builder(
13444///     hyper_util::rt::TokioExecutor::new()
13445/// )
13446/// .build(
13447///     hyper_rustls::HttpsConnectorBuilder::new()
13448///         .with_native_roots()
13449///         .unwrap()
13450///         .https_or_http()
13451///         .enable_http1()
13452///         .build()
13453/// );
13454/// let mut hub = Dfareporting::new(client, auth);
13455/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13456/// // like `get(...)` and `list(...)`
13457/// // to build up your call.
13458/// let rb = hub.postal_codes();
13459/// # }
13460/// ```
13461pub struct PostalCodeMethods<'a, C>
13462where
13463    C: 'a,
13464{
13465    hub: &'a Dfareporting<C>,
13466}
13467
13468impl<'a, C> common::MethodsBuilder for PostalCodeMethods<'a, C> {}
13469
13470impl<'a, C> PostalCodeMethods<'a, C> {
13471    /// Create a builder to help you perform the following task:
13472    ///
13473    /// Gets one postal code by ID.
13474    ///
13475    /// # Arguments
13476    ///
13477    /// * `profileId` - User profile ID associated with this request.
13478    /// * `code` - Postal code ID.
13479    pub fn get(&self, profile_id: i64, code: &str) -> PostalCodeGetCall<'a, C> {
13480        PostalCodeGetCall {
13481            hub: self.hub,
13482            _profile_id: profile_id,
13483            _code: code.to_string(),
13484            _delegate: Default::default(),
13485            _additional_params: Default::default(),
13486            _scopes: Default::default(),
13487        }
13488    }
13489
13490    /// Create a builder to help you perform the following task:
13491    ///
13492    /// Retrieves a list of postal codes.
13493    ///
13494    /// # Arguments
13495    ///
13496    /// * `profileId` - User profile ID associated with this request.
13497    pub fn list(&self, profile_id: i64) -> PostalCodeListCall<'a, C> {
13498        PostalCodeListCall {
13499            hub: self.hub,
13500            _profile_id: profile_id,
13501            _delegate: Default::default(),
13502            _additional_params: Default::default(),
13503            _scopes: Default::default(),
13504        }
13505    }
13506}
13507
13508/// A builder providing access to all methods supported on *project* resources.
13509/// It is not used directly, but through the [`Dfareporting`] hub.
13510///
13511/// # Example
13512///
13513/// Instantiate a resource builder
13514///
13515/// ```test_harness,no_run
13516/// extern crate hyper;
13517/// extern crate hyper_rustls;
13518/// extern crate google_dfareporting3d2 as dfareporting3d2;
13519///
13520/// # async fn dox() {
13521/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13522///
13523/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13524/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13525///     secret,
13526///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13527/// ).build().await.unwrap();
13528///
13529/// let client = hyper_util::client::legacy::Client::builder(
13530///     hyper_util::rt::TokioExecutor::new()
13531/// )
13532/// .build(
13533///     hyper_rustls::HttpsConnectorBuilder::new()
13534///         .with_native_roots()
13535///         .unwrap()
13536///         .https_or_http()
13537///         .enable_http1()
13538///         .build()
13539/// );
13540/// let mut hub = Dfareporting::new(client, auth);
13541/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13542/// // like `get(...)` and `list(...)`
13543/// // to build up your call.
13544/// let rb = hub.projects();
13545/// # }
13546/// ```
13547pub struct ProjectMethods<'a, C>
13548where
13549    C: 'a,
13550{
13551    hub: &'a Dfareporting<C>,
13552}
13553
13554impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
13555
13556impl<'a, C> ProjectMethods<'a, C> {
13557    /// Create a builder to help you perform the following task:
13558    ///
13559    /// Gets one project by ID.
13560    ///
13561    /// # Arguments
13562    ///
13563    /// * `profileId` - User profile ID associated with this request.
13564    /// * `id` - Project ID.
13565    pub fn get(&self, profile_id: i64, id: i64) -> ProjectGetCall<'a, C> {
13566        ProjectGetCall {
13567            hub: self.hub,
13568            _profile_id: profile_id,
13569            _id: id,
13570            _delegate: Default::default(),
13571            _additional_params: Default::default(),
13572            _scopes: Default::default(),
13573        }
13574    }
13575
13576    /// Create a builder to help you perform the following task:
13577    ///
13578    /// Retrieves a list of projects, possibly filtered. This method supports paging.
13579    ///
13580    /// # Arguments
13581    ///
13582    /// * `profileId` - User profile ID associated with this request.
13583    pub fn list(&self, profile_id: i64) -> ProjectListCall<'a, C> {
13584        ProjectListCall {
13585            hub: self.hub,
13586            _profile_id: profile_id,
13587            _sort_order: Default::default(),
13588            _sort_field: Default::default(),
13589            _search_string: Default::default(),
13590            _page_token: Default::default(),
13591            _max_results: Default::default(),
13592            _ids: Default::default(),
13593            _advertiser_ids: Default::default(),
13594            _delegate: Default::default(),
13595            _additional_params: Default::default(),
13596            _scopes: Default::default(),
13597        }
13598    }
13599}
13600
13601/// A builder providing access to all methods supported on *region* resources.
13602/// It is not used directly, but through the [`Dfareporting`] hub.
13603///
13604/// # Example
13605///
13606/// Instantiate a resource builder
13607///
13608/// ```test_harness,no_run
13609/// extern crate hyper;
13610/// extern crate hyper_rustls;
13611/// extern crate google_dfareporting3d2 as dfareporting3d2;
13612///
13613/// # async fn dox() {
13614/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13615///
13616/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13617/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13618///     secret,
13619///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13620/// ).build().await.unwrap();
13621///
13622/// let client = hyper_util::client::legacy::Client::builder(
13623///     hyper_util::rt::TokioExecutor::new()
13624/// )
13625/// .build(
13626///     hyper_rustls::HttpsConnectorBuilder::new()
13627///         .with_native_roots()
13628///         .unwrap()
13629///         .https_or_http()
13630///         .enable_http1()
13631///         .build()
13632/// );
13633/// let mut hub = Dfareporting::new(client, auth);
13634/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13635/// // like `list(...)`
13636/// // to build up your call.
13637/// let rb = hub.regions();
13638/// # }
13639/// ```
13640pub struct RegionMethods<'a, C>
13641where
13642    C: 'a,
13643{
13644    hub: &'a Dfareporting<C>,
13645}
13646
13647impl<'a, C> common::MethodsBuilder for RegionMethods<'a, C> {}
13648
13649impl<'a, C> RegionMethods<'a, C> {
13650    /// Create a builder to help you perform the following task:
13651    ///
13652    /// Retrieves a list of regions.
13653    ///
13654    /// # Arguments
13655    ///
13656    /// * `profileId` - User profile ID associated with this request.
13657    pub fn list(&self, profile_id: i64) -> RegionListCall<'a, C> {
13658        RegionListCall {
13659            hub: self.hub,
13660            _profile_id: profile_id,
13661            _delegate: Default::default(),
13662            _additional_params: Default::default(),
13663            _scopes: Default::default(),
13664        }
13665    }
13666}
13667
13668/// A builder providing access to all methods supported on *remarketingListShare* resources.
13669/// It is not used directly, but through the [`Dfareporting`] hub.
13670///
13671/// # Example
13672///
13673/// Instantiate a resource builder
13674///
13675/// ```test_harness,no_run
13676/// extern crate hyper;
13677/// extern crate hyper_rustls;
13678/// extern crate google_dfareporting3d2 as dfareporting3d2;
13679///
13680/// # async fn dox() {
13681/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13682///
13683/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13684/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13685///     secret,
13686///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13687/// ).build().await.unwrap();
13688///
13689/// let client = hyper_util::client::legacy::Client::builder(
13690///     hyper_util::rt::TokioExecutor::new()
13691/// )
13692/// .build(
13693///     hyper_rustls::HttpsConnectorBuilder::new()
13694///         .with_native_roots()
13695///         .unwrap()
13696///         .https_or_http()
13697///         .enable_http1()
13698///         .build()
13699/// );
13700/// let mut hub = Dfareporting::new(client, auth);
13701/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13702/// // like `get(...)`, `patch(...)` and `update(...)`
13703/// // to build up your call.
13704/// let rb = hub.remarketing_list_shares();
13705/// # }
13706/// ```
13707pub struct RemarketingListShareMethods<'a, C>
13708where
13709    C: 'a,
13710{
13711    hub: &'a Dfareporting<C>,
13712}
13713
13714impl<'a, C> common::MethodsBuilder for RemarketingListShareMethods<'a, C> {}
13715
13716impl<'a, C> RemarketingListShareMethods<'a, C> {
13717    /// Create a builder to help you perform the following task:
13718    ///
13719    /// Gets one remarketing list share by remarketing list ID.
13720    ///
13721    /// # Arguments
13722    ///
13723    /// * `profileId` - User profile ID associated with this request.
13724    /// * `remarketingListId` - Remarketing list ID.
13725    pub fn get(
13726        &self,
13727        profile_id: i64,
13728        remarketing_list_id: i64,
13729    ) -> RemarketingListShareGetCall<'a, C> {
13730        RemarketingListShareGetCall {
13731            hub: self.hub,
13732            _profile_id: profile_id,
13733            _remarketing_list_id: remarketing_list_id,
13734            _delegate: Default::default(),
13735            _additional_params: Default::default(),
13736            _scopes: Default::default(),
13737        }
13738    }
13739
13740    /// Create a builder to help you perform the following task:
13741    ///
13742    /// Updates an existing remarketing list share. This method supports patch semantics.
13743    ///
13744    /// # Arguments
13745    ///
13746    /// * `request` - No description provided.
13747    /// * `profileId` - User profile ID associated with this request.
13748    /// * `remarketingListId` - Remarketing list ID.
13749    pub fn patch(
13750        &self,
13751        request: RemarketingListShare,
13752        profile_id: i64,
13753        remarketing_list_id: i64,
13754    ) -> RemarketingListSharePatchCall<'a, C> {
13755        RemarketingListSharePatchCall {
13756            hub: self.hub,
13757            _request: request,
13758            _profile_id: profile_id,
13759            _remarketing_list_id: remarketing_list_id,
13760            _delegate: Default::default(),
13761            _additional_params: Default::default(),
13762            _scopes: Default::default(),
13763        }
13764    }
13765
13766    /// Create a builder to help you perform the following task:
13767    ///
13768    /// Updates an existing remarketing list share.
13769    ///
13770    /// # Arguments
13771    ///
13772    /// * `request` - No description provided.
13773    /// * `profileId` - User profile ID associated with this request.
13774    pub fn update(
13775        &self,
13776        request: RemarketingListShare,
13777        profile_id: i64,
13778    ) -> RemarketingListShareUpdateCall<'a, C> {
13779        RemarketingListShareUpdateCall {
13780            hub: self.hub,
13781            _request: request,
13782            _profile_id: profile_id,
13783            _delegate: Default::default(),
13784            _additional_params: Default::default(),
13785            _scopes: Default::default(),
13786        }
13787    }
13788}
13789
13790/// A builder providing access to all methods supported on *remarketingList* resources.
13791/// It is not used directly, but through the [`Dfareporting`] hub.
13792///
13793/// # Example
13794///
13795/// Instantiate a resource builder
13796///
13797/// ```test_harness,no_run
13798/// extern crate hyper;
13799/// extern crate hyper_rustls;
13800/// extern crate google_dfareporting3d2 as dfareporting3d2;
13801///
13802/// # async fn dox() {
13803/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13804///
13805/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13806/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13807///     secret,
13808///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13809/// ).build().await.unwrap();
13810///
13811/// let client = hyper_util::client::legacy::Client::builder(
13812///     hyper_util::rt::TokioExecutor::new()
13813/// )
13814/// .build(
13815///     hyper_rustls::HttpsConnectorBuilder::new()
13816///         .with_native_roots()
13817///         .unwrap()
13818///         .https_or_http()
13819///         .enable_http1()
13820///         .build()
13821/// );
13822/// let mut hub = Dfareporting::new(client, auth);
13823/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13824/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
13825/// // to build up your call.
13826/// let rb = hub.remarketing_lists();
13827/// # }
13828/// ```
13829pub struct RemarketingListMethods<'a, C>
13830where
13831    C: 'a,
13832{
13833    hub: &'a Dfareporting<C>,
13834}
13835
13836impl<'a, C> common::MethodsBuilder for RemarketingListMethods<'a, C> {}
13837
13838impl<'a, C> RemarketingListMethods<'a, C> {
13839    /// Create a builder to help you perform the following task:
13840    ///
13841    /// Gets one remarketing list by ID.
13842    ///
13843    /// # Arguments
13844    ///
13845    /// * `profileId` - User profile ID associated with this request.
13846    /// * `id` - Remarketing list ID.
13847    pub fn get(&self, profile_id: i64, id: i64) -> RemarketingListGetCall<'a, C> {
13848        RemarketingListGetCall {
13849            hub: self.hub,
13850            _profile_id: profile_id,
13851            _id: id,
13852            _delegate: Default::default(),
13853            _additional_params: Default::default(),
13854            _scopes: Default::default(),
13855        }
13856    }
13857
13858    /// Create a builder to help you perform the following task:
13859    ///
13860    /// Inserts a new remarketing list.
13861    ///
13862    /// # Arguments
13863    ///
13864    /// * `request` - No description provided.
13865    /// * `profileId` - User profile ID associated with this request.
13866    pub fn insert(
13867        &self,
13868        request: RemarketingList,
13869        profile_id: i64,
13870    ) -> RemarketingListInsertCall<'a, C> {
13871        RemarketingListInsertCall {
13872            hub: self.hub,
13873            _request: request,
13874            _profile_id: profile_id,
13875            _delegate: Default::default(),
13876            _additional_params: Default::default(),
13877            _scopes: Default::default(),
13878        }
13879    }
13880
13881    /// Create a builder to help you perform the following task:
13882    ///
13883    /// Retrieves a list of remarketing lists, possibly filtered. This method supports paging.
13884    ///
13885    /// # Arguments
13886    ///
13887    /// * `profileId` - User profile ID associated with this request.
13888    /// * `advertiserId` - Select only remarketing lists owned by this advertiser.
13889    pub fn list(&self, profile_id: i64, advertiser_id: i64) -> RemarketingListListCall<'a, C> {
13890        RemarketingListListCall {
13891            hub: self.hub,
13892            _profile_id: profile_id,
13893            _advertiser_id: advertiser_id,
13894            _sort_order: Default::default(),
13895            _sort_field: Default::default(),
13896            _page_token: Default::default(),
13897            _name: Default::default(),
13898            _max_results: Default::default(),
13899            _floodlight_activity_id: Default::default(),
13900            _active: Default::default(),
13901            _delegate: Default::default(),
13902            _additional_params: Default::default(),
13903            _scopes: Default::default(),
13904        }
13905    }
13906
13907    /// Create a builder to help you perform the following task:
13908    ///
13909    /// Updates an existing remarketing list. This method supports patch semantics.
13910    ///
13911    /// # Arguments
13912    ///
13913    /// * `request` - No description provided.
13914    /// * `profileId` - User profile ID associated with this request.
13915    /// * `id` - Remarketing list ID.
13916    pub fn patch(
13917        &self,
13918        request: RemarketingList,
13919        profile_id: i64,
13920        id: i64,
13921    ) -> RemarketingListPatchCall<'a, C> {
13922        RemarketingListPatchCall {
13923            hub: self.hub,
13924            _request: request,
13925            _profile_id: profile_id,
13926            _id: id,
13927            _delegate: Default::default(),
13928            _additional_params: Default::default(),
13929            _scopes: Default::default(),
13930        }
13931    }
13932
13933    /// Create a builder to help you perform the following task:
13934    ///
13935    /// Updates an existing remarketing list.
13936    ///
13937    /// # Arguments
13938    ///
13939    /// * `request` - No description provided.
13940    /// * `profileId` - User profile ID associated with this request.
13941    pub fn update(
13942        &self,
13943        request: RemarketingList,
13944        profile_id: i64,
13945    ) -> RemarketingListUpdateCall<'a, C> {
13946        RemarketingListUpdateCall {
13947            hub: self.hub,
13948            _request: request,
13949            _profile_id: profile_id,
13950            _delegate: Default::default(),
13951            _additional_params: Default::default(),
13952            _scopes: Default::default(),
13953        }
13954    }
13955}
13956
13957/// A builder providing access to all methods supported on *report* resources.
13958/// It is not used directly, but through the [`Dfareporting`] hub.
13959///
13960/// # Example
13961///
13962/// Instantiate a resource builder
13963///
13964/// ```test_harness,no_run
13965/// extern crate hyper;
13966/// extern crate hyper_rustls;
13967/// extern crate google_dfareporting3d2 as dfareporting3d2;
13968///
13969/// # async fn dox() {
13970/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13971///
13972/// let secret: yup_oauth2::ApplicationSecret = Default::default();
13973/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13974///     secret,
13975///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13976/// ).build().await.unwrap();
13977///
13978/// let client = hyper_util::client::legacy::Client::builder(
13979///     hyper_util::rt::TokioExecutor::new()
13980/// )
13981/// .build(
13982///     hyper_rustls::HttpsConnectorBuilder::new()
13983///         .with_native_roots()
13984///         .unwrap()
13985///         .https_or_http()
13986///         .enable_http1()
13987///         .build()
13988/// );
13989/// let mut hub = Dfareporting::new(client, auth);
13990/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
13991/// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)`
13992/// // to build up your call.
13993/// let rb = hub.reports();
13994/// # }
13995/// ```
13996pub struct ReportMethods<'a, C>
13997where
13998    C: 'a,
13999{
14000    hub: &'a Dfareporting<C>,
14001}
14002
14003impl<'a, C> common::MethodsBuilder for ReportMethods<'a, C> {}
14004
14005impl<'a, C> ReportMethods<'a, C> {
14006    /// Create a builder to help you perform the following task:
14007    ///
14008    /// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions.
14009    ///
14010    /// # Arguments
14011    ///
14012    /// * `request` - No description provided.
14013    /// * `profileId` - The DFA user profile ID.
14014    pub fn compatible_fields_query(
14015        &self,
14016        request: Report,
14017        profile_id: i64,
14018    ) -> ReportCompatibleFieldQueryCall<'a, C> {
14019        ReportCompatibleFieldQueryCall {
14020            hub: self.hub,
14021            _request: request,
14022            _profile_id: profile_id,
14023            _delegate: Default::default(),
14024            _additional_params: Default::default(),
14025            _scopes: Default::default(),
14026        }
14027    }
14028
14029    /// Create a builder to help you perform the following task:
14030    ///
14031    /// Retrieves a report file. This method supports media download.
14032    ///
14033    /// # Arguments
14034    ///
14035    /// * `profileId` - The DFA profile ID.
14036    /// * `reportId` - The ID of the report.
14037    /// * `fileId` - The ID of the report file.
14038    pub fn files_get(
14039        &self,
14040        profile_id: i64,
14041        report_id: i64,
14042        file_id: i64,
14043    ) -> ReportFileGetCall<'a, C> {
14044        ReportFileGetCall {
14045            hub: self.hub,
14046            _profile_id: profile_id,
14047            _report_id: report_id,
14048            _file_id: file_id,
14049            _delegate: Default::default(),
14050            _additional_params: Default::default(),
14051            _scopes: Default::default(),
14052        }
14053    }
14054
14055    /// Create a builder to help you perform the following task:
14056    ///
14057    /// Lists files for a report.
14058    ///
14059    /// # Arguments
14060    ///
14061    /// * `profileId` - The DFA profile ID.
14062    /// * `reportId` - The ID of the parent report.
14063    pub fn files_list(&self, profile_id: i64, report_id: i64) -> ReportFileListCall<'a, C> {
14064        ReportFileListCall {
14065            hub: self.hub,
14066            _profile_id: profile_id,
14067            _report_id: report_id,
14068            _sort_order: Default::default(),
14069            _sort_field: Default::default(),
14070            _page_token: Default::default(),
14071            _max_results: Default::default(),
14072            _delegate: Default::default(),
14073            _additional_params: Default::default(),
14074            _scopes: Default::default(),
14075        }
14076    }
14077
14078    /// Create a builder to help you perform the following task:
14079    ///
14080    /// Deletes a report by its ID.
14081    ///
14082    /// # Arguments
14083    ///
14084    /// * `profileId` - The DFA user profile ID.
14085    /// * `reportId` - The ID of the report.
14086    pub fn delete(&self, profile_id: i64, report_id: i64) -> ReportDeleteCall<'a, C> {
14087        ReportDeleteCall {
14088            hub: self.hub,
14089            _profile_id: profile_id,
14090            _report_id: report_id,
14091            _delegate: Default::default(),
14092            _additional_params: Default::default(),
14093            _scopes: Default::default(),
14094        }
14095    }
14096
14097    /// Create a builder to help you perform the following task:
14098    ///
14099    /// Retrieves a report by its ID.
14100    ///
14101    /// # Arguments
14102    ///
14103    /// * `profileId` - The DFA user profile ID.
14104    /// * `reportId` - The ID of the report.
14105    pub fn get(&self, profile_id: i64, report_id: i64) -> ReportGetCall<'a, C> {
14106        ReportGetCall {
14107            hub: self.hub,
14108            _profile_id: profile_id,
14109            _report_id: report_id,
14110            _delegate: Default::default(),
14111            _additional_params: Default::default(),
14112            _scopes: Default::default(),
14113        }
14114    }
14115
14116    /// Create a builder to help you perform the following task:
14117    ///
14118    /// Creates a report.
14119    ///
14120    /// # Arguments
14121    ///
14122    /// * `request` - No description provided.
14123    /// * `profileId` - The DFA user profile ID.
14124    pub fn insert(&self, request: Report, profile_id: i64) -> ReportInsertCall<'a, C> {
14125        ReportInsertCall {
14126            hub: self.hub,
14127            _request: request,
14128            _profile_id: profile_id,
14129            _delegate: Default::default(),
14130            _additional_params: Default::default(),
14131            _scopes: Default::default(),
14132        }
14133    }
14134
14135    /// Create a builder to help you perform the following task:
14136    ///
14137    /// Retrieves list of reports.
14138    ///
14139    /// # Arguments
14140    ///
14141    /// * `profileId` - The DFA user profile ID.
14142    pub fn list(&self, profile_id: i64) -> ReportListCall<'a, C> {
14143        ReportListCall {
14144            hub: self.hub,
14145            _profile_id: profile_id,
14146            _sort_order: Default::default(),
14147            _sort_field: Default::default(),
14148            _scope: Default::default(),
14149            _page_token: Default::default(),
14150            _max_results: Default::default(),
14151            _delegate: Default::default(),
14152            _additional_params: Default::default(),
14153            _scopes: Default::default(),
14154        }
14155    }
14156
14157    /// Create a builder to help you perform the following task:
14158    ///
14159    /// Updates a report. This method supports patch semantics.
14160    ///
14161    /// # Arguments
14162    ///
14163    /// * `request` - No description provided.
14164    /// * `profileId` - The DFA user profile ID.
14165    /// * `reportId` - The ID of the report.
14166    pub fn patch(
14167        &self,
14168        request: Report,
14169        profile_id: i64,
14170        report_id: i64,
14171    ) -> ReportPatchCall<'a, C> {
14172        ReportPatchCall {
14173            hub: self.hub,
14174            _request: request,
14175            _profile_id: profile_id,
14176            _report_id: report_id,
14177            _delegate: Default::default(),
14178            _additional_params: Default::default(),
14179            _scopes: Default::default(),
14180        }
14181    }
14182
14183    /// Create a builder to help you perform the following task:
14184    ///
14185    /// Runs a report.
14186    ///
14187    /// # Arguments
14188    ///
14189    /// * `profileId` - The DFA profile ID.
14190    /// * `reportId` - The ID of the report.
14191    pub fn run(&self, profile_id: i64, report_id: i64) -> ReportRunCall<'a, C> {
14192        ReportRunCall {
14193            hub: self.hub,
14194            _profile_id: profile_id,
14195            _report_id: report_id,
14196            _synchronous: Default::default(),
14197            _delegate: Default::default(),
14198            _additional_params: Default::default(),
14199            _scopes: Default::default(),
14200        }
14201    }
14202
14203    /// Create a builder to help you perform the following task:
14204    ///
14205    /// Updates a report.
14206    ///
14207    /// # Arguments
14208    ///
14209    /// * `request` - No description provided.
14210    /// * `profileId` - The DFA user profile ID.
14211    /// * `reportId` - The ID of the report.
14212    pub fn update(
14213        &self,
14214        request: Report,
14215        profile_id: i64,
14216        report_id: i64,
14217    ) -> ReportUpdateCall<'a, C> {
14218        ReportUpdateCall {
14219            hub: self.hub,
14220            _request: request,
14221            _profile_id: profile_id,
14222            _report_id: report_id,
14223            _delegate: Default::default(),
14224            _additional_params: Default::default(),
14225            _scopes: Default::default(),
14226        }
14227    }
14228}
14229
14230/// A builder providing access to all methods supported on *site* resources.
14231/// It is not used directly, but through the [`Dfareporting`] hub.
14232///
14233/// # Example
14234///
14235/// Instantiate a resource builder
14236///
14237/// ```test_harness,no_run
14238/// extern crate hyper;
14239/// extern crate hyper_rustls;
14240/// extern crate google_dfareporting3d2 as dfareporting3d2;
14241///
14242/// # async fn dox() {
14243/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14244///
14245/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14246/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14247///     secret,
14248///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14249/// ).build().await.unwrap();
14250///
14251/// let client = hyper_util::client::legacy::Client::builder(
14252///     hyper_util::rt::TokioExecutor::new()
14253/// )
14254/// .build(
14255///     hyper_rustls::HttpsConnectorBuilder::new()
14256///         .with_native_roots()
14257///         .unwrap()
14258///         .https_or_http()
14259///         .enable_http1()
14260///         .build()
14261/// );
14262/// let mut hub = Dfareporting::new(client, auth);
14263/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14264/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
14265/// // to build up your call.
14266/// let rb = hub.sites();
14267/// # }
14268/// ```
14269pub struct SiteMethods<'a, C>
14270where
14271    C: 'a,
14272{
14273    hub: &'a Dfareporting<C>,
14274}
14275
14276impl<'a, C> common::MethodsBuilder for SiteMethods<'a, C> {}
14277
14278impl<'a, C> SiteMethods<'a, C> {
14279    /// Create a builder to help you perform the following task:
14280    ///
14281    /// Gets one site by ID.
14282    ///
14283    /// # Arguments
14284    ///
14285    /// * `profileId` - User profile ID associated with this request.
14286    /// * `id` - Site ID.
14287    pub fn get(&self, profile_id: i64, id: i64) -> SiteGetCall<'a, C> {
14288        SiteGetCall {
14289            hub: self.hub,
14290            _profile_id: profile_id,
14291            _id: id,
14292            _delegate: Default::default(),
14293            _additional_params: Default::default(),
14294            _scopes: Default::default(),
14295        }
14296    }
14297
14298    /// Create a builder to help you perform the following task:
14299    ///
14300    /// Inserts a new site.
14301    ///
14302    /// # Arguments
14303    ///
14304    /// * `request` - No description provided.
14305    /// * `profileId` - User profile ID associated with this request.
14306    pub fn insert(&self, request: Site, profile_id: i64) -> SiteInsertCall<'a, C> {
14307        SiteInsertCall {
14308            hub: self.hub,
14309            _request: request,
14310            _profile_id: profile_id,
14311            _delegate: Default::default(),
14312            _additional_params: Default::default(),
14313            _scopes: Default::default(),
14314        }
14315    }
14316
14317    /// Create a builder to help you perform the following task:
14318    ///
14319    /// Retrieves a list of sites, possibly filtered. This method supports paging.
14320    ///
14321    /// # Arguments
14322    ///
14323    /// * `profileId` - User profile ID associated with this request.
14324    pub fn list(&self, profile_id: i64) -> SiteListCall<'a, C> {
14325        SiteListCall {
14326            hub: self.hub,
14327            _profile_id: profile_id,
14328            _unmapped_site: Default::default(),
14329            _subaccount_id: Default::default(),
14330            _sort_order: Default::default(),
14331            _sort_field: Default::default(),
14332            _search_string: Default::default(),
14333            _page_token: Default::default(),
14334            _max_results: Default::default(),
14335            _ids: Default::default(),
14336            _directory_site_ids: Default::default(),
14337            _campaign_ids: Default::default(),
14338            _approved: Default::default(),
14339            _ad_words_site: Default::default(),
14340            _accepts_publisher_paid_placements: Default::default(),
14341            _accepts_interstitial_placements: Default::default(),
14342            _accepts_in_stream_video_placements: Default::default(),
14343            _delegate: Default::default(),
14344            _additional_params: Default::default(),
14345            _scopes: Default::default(),
14346        }
14347    }
14348
14349    /// Create a builder to help you perform the following task:
14350    ///
14351    /// Updates an existing site. This method supports patch semantics.
14352    ///
14353    /// # Arguments
14354    ///
14355    /// * `request` - No description provided.
14356    /// * `profileId` - User profile ID associated with this request.
14357    /// * `id` - Site ID.
14358    pub fn patch(&self, request: Site, profile_id: i64, id: i64) -> SitePatchCall<'a, C> {
14359        SitePatchCall {
14360            hub: self.hub,
14361            _request: request,
14362            _profile_id: profile_id,
14363            _id: id,
14364            _delegate: Default::default(),
14365            _additional_params: Default::default(),
14366            _scopes: Default::default(),
14367        }
14368    }
14369
14370    /// Create a builder to help you perform the following task:
14371    ///
14372    /// Updates an existing site.
14373    ///
14374    /// # Arguments
14375    ///
14376    /// * `request` - No description provided.
14377    /// * `profileId` - User profile ID associated with this request.
14378    pub fn update(&self, request: Site, profile_id: i64) -> SiteUpdateCall<'a, C> {
14379        SiteUpdateCall {
14380            hub: self.hub,
14381            _request: request,
14382            _profile_id: profile_id,
14383            _delegate: Default::default(),
14384            _additional_params: Default::default(),
14385            _scopes: Default::default(),
14386        }
14387    }
14388}
14389
14390/// A builder providing access to all methods supported on *size* resources.
14391/// It is not used directly, but through the [`Dfareporting`] hub.
14392///
14393/// # Example
14394///
14395/// Instantiate a resource builder
14396///
14397/// ```test_harness,no_run
14398/// extern crate hyper;
14399/// extern crate hyper_rustls;
14400/// extern crate google_dfareporting3d2 as dfareporting3d2;
14401///
14402/// # async fn dox() {
14403/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14404///
14405/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14406/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14407///     secret,
14408///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14409/// ).build().await.unwrap();
14410///
14411/// let client = hyper_util::client::legacy::Client::builder(
14412///     hyper_util::rt::TokioExecutor::new()
14413/// )
14414/// .build(
14415///     hyper_rustls::HttpsConnectorBuilder::new()
14416///         .with_native_roots()
14417///         .unwrap()
14418///         .https_or_http()
14419///         .enable_http1()
14420///         .build()
14421/// );
14422/// let mut hub = Dfareporting::new(client, auth);
14423/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14424/// // like `get(...)`, `insert(...)` and `list(...)`
14425/// // to build up your call.
14426/// let rb = hub.sizes();
14427/// # }
14428/// ```
14429pub struct SizeMethods<'a, C>
14430where
14431    C: 'a,
14432{
14433    hub: &'a Dfareporting<C>,
14434}
14435
14436impl<'a, C> common::MethodsBuilder for SizeMethods<'a, C> {}
14437
14438impl<'a, C> SizeMethods<'a, C> {
14439    /// Create a builder to help you perform the following task:
14440    ///
14441    /// Gets one size by ID.
14442    ///
14443    /// # Arguments
14444    ///
14445    /// * `profileId` - User profile ID associated with this request.
14446    /// * `id` - Size ID.
14447    pub fn get(&self, profile_id: i64, id: i64) -> SizeGetCall<'a, C> {
14448        SizeGetCall {
14449            hub: self.hub,
14450            _profile_id: profile_id,
14451            _id: id,
14452            _delegate: Default::default(),
14453            _additional_params: Default::default(),
14454            _scopes: Default::default(),
14455        }
14456    }
14457
14458    /// Create a builder to help you perform the following task:
14459    ///
14460    /// Inserts a new size.
14461    ///
14462    /// # Arguments
14463    ///
14464    /// * `request` - No description provided.
14465    /// * `profileId` - User profile ID associated with this request.
14466    pub fn insert(&self, request: Size, profile_id: i64) -> SizeInsertCall<'a, C> {
14467        SizeInsertCall {
14468            hub: self.hub,
14469            _request: request,
14470            _profile_id: profile_id,
14471            _delegate: Default::default(),
14472            _additional_params: Default::default(),
14473            _scopes: Default::default(),
14474        }
14475    }
14476
14477    /// Create a builder to help you perform the following task:
14478    ///
14479    /// Retrieves a list of sizes, possibly filtered. Retrieved sizes are globally unique and may include values not currently in use by your account. Due to this, the list of sizes returned by this method may differ from the list seen in the Trafficking UI.
14480    ///
14481    /// # Arguments
14482    ///
14483    /// * `profileId` - User profile ID associated with this request.
14484    pub fn list(&self, profile_id: i64) -> SizeListCall<'a, C> {
14485        SizeListCall {
14486            hub: self.hub,
14487            _profile_id: profile_id,
14488            _width: Default::default(),
14489            _ids: Default::default(),
14490            _iab_standard: Default::default(),
14491            _height: Default::default(),
14492            _delegate: Default::default(),
14493            _additional_params: Default::default(),
14494            _scopes: Default::default(),
14495        }
14496    }
14497}
14498
14499/// A builder providing access to all methods supported on *subaccount* resources.
14500/// It is not used directly, but through the [`Dfareporting`] hub.
14501///
14502/// # Example
14503///
14504/// Instantiate a resource builder
14505///
14506/// ```test_harness,no_run
14507/// extern crate hyper;
14508/// extern crate hyper_rustls;
14509/// extern crate google_dfareporting3d2 as dfareporting3d2;
14510///
14511/// # async fn dox() {
14512/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14513///
14514/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14515/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14516///     secret,
14517///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14518/// ).build().await.unwrap();
14519///
14520/// let client = hyper_util::client::legacy::Client::builder(
14521///     hyper_util::rt::TokioExecutor::new()
14522/// )
14523/// .build(
14524///     hyper_rustls::HttpsConnectorBuilder::new()
14525///         .with_native_roots()
14526///         .unwrap()
14527///         .https_or_http()
14528///         .enable_http1()
14529///         .build()
14530/// );
14531/// let mut hub = Dfareporting::new(client, auth);
14532/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14533/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
14534/// // to build up your call.
14535/// let rb = hub.subaccounts();
14536/// # }
14537/// ```
14538pub struct SubaccountMethods<'a, C>
14539where
14540    C: 'a,
14541{
14542    hub: &'a Dfareporting<C>,
14543}
14544
14545impl<'a, C> common::MethodsBuilder for SubaccountMethods<'a, C> {}
14546
14547impl<'a, C> SubaccountMethods<'a, C> {
14548    /// Create a builder to help you perform the following task:
14549    ///
14550    /// Gets one subaccount by ID.
14551    ///
14552    /// # Arguments
14553    ///
14554    /// * `profileId` - User profile ID associated with this request.
14555    /// * `id` - Subaccount ID.
14556    pub fn get(&self, profile_id: i64, id: i64) -> SubaccountGetCall<'a, C> {
14557        SubaccountGetCall {
14558            hub: self.hub,
14559            _profile_id: profile_id,
14560            _id: id,
14561            _delegate: Default::default(),
14562            _additional_params: Default::default(),
14563            _scopes: Default::default(),
14564        }
14565    }
14566
14567    /// Create a builder to help you perform the following task:
14568    ///
14569    /// Inserts a new subaccount.
14570    ///
14571    /// # Arguments
14572    ///
14573    /// * `request` - No description provided.
14574    /// * `profileId` - User profile ID associated with this request.
14575    pub fn insert(&self, request: Subaccount, profile_id: i64) -> SubaccountInsertCall<'a, C> {
14576        SubaccountInsertCall {
14577            hub: self.hub,
14578            _request: request,
14579            _profile_id: profile_id,
14580            _delegate: Default::default(),
14581            _additional_params: Default::default(),
14582            _scopes: Default::default(),
14583        }
14584    }
14585
14586    /// Create a builder to help you perform the following task:
14587    ///
14588    /// Gets a list of subaccounts, possibly filtered. This method supports paging.
14589    ///
14590    /// # Arguments
14591    ///
14592    /// * `profileId` - User profile ID associated with this request.
14593    pub fn list(&self, profile_id: i64) -> SubaccountListCall<'a, C> {
14594        SubaccountListCall {
14595            hub: self.hub,
14596            _profile_id: profile_id,
14597            _sort_order: Default::default(),
14598            _sort_field: Default::default(),
14599            _search_string: Default::default(),
14600            _page_token: Default::default(),
14601            _max_results: Default::default(),
14602            _ids: Default::default(),
14603            _delegate: Default::default(),
14604            _additional_params: Default::default(),
14605            _scopes: Default::default(),
14606        }
14607    }
14608
14609    /// Create a builder to help you perform the following task:
14610    ///
14611    /// Updates an existing subaccount. This method supports patch semantics.
14612    ///
14613    /// # Arguments
14614    ///
14615    /// * `request` - No description provided.
14616    /// * `profileId` - User profile ID associated with this request.
14617    /// * `id` - Subaccount ID.
14618    pub fn patch(
14619        &self,
14620        request: Subaccount,
14621        profile_id: i64,
14622        id: i64,
14623    ) -> SubaccountPatchCall<'a, C> {
14624        SubaccountPatchCall {
14625            hub: self.hub,
14626            _request: request,
14627            _profile_id: profile_id,
14628            _id: id,
14629            _delegate: Default::default(),
14630            _additional_params: Default::default(),
14631            _scopes: Default::default(),
14632        }
14633    }
14634
14635    /// Create a builder to help you perform the following task:
14636    ///
14637    /// Updates an existing subaccount.
14638    ///
14639    /// # Arguments
14640    ///
14641    /// * `request` - No description provided.
14642    /// * `profileId` - User profile ID associated with this request.
14643    pub fn update(&self, request: Subaccount, profile_id: i64) -> SubaccountUpdateCall<'a, C> {
14644        SubaccountUpdateCall {
14645            hub: self.hub,
14646            _request: request,
14647            _profile_id: profile_id,
14648            _delegate: Default::default(),
14649            _additional_params: Default::default(),
14650            _scopes: Default::default(),
14651        }
14652    }
14653}
14654
14655/// A builder providing access to all methods supported on *targetableRemarketingList* resources.
14656/// It is not used directly, but through the [`Dfareporting`] hub.
14657///
14658/// # Example
14659///
14660/// Instantiate a resource builder
14661///
14662/// ```test_harness,no_run
14663/// extern crate hyper;
14664/// extern crate hyper_rustls;
14665/// extern crate google_dfareporting3d2 as dfareporting3d2;
14666///
14667/// # async fn dox() {
14668/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14669///
14670/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14671/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14672///     secret,
14673///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14674/// ).build().await.unwrap();
14675///
14676/// let client = hyper_util::client::legacy::Client::builder(
14677///     hyper_util::rt::TokioExecutor::new()
14678/// )
14679/// .build(
14680///     hyper_rustls::HttpsConnectorBuilder::new()
14681///         .with_native_roots()
14682///         .unwrap()
14683///         .https_or_http()
14684///         .enable_http1()
14685///         .build()
14686/// );
14687/// let mut hub = Dfareporting::new(client, auth);
14688/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14689/// // like `get(...)` and `list(...)`
14690/// // to build up your call.
14691/// let rb = hub.targetable_remarketing_lists();
14692/// # }
14693/// ```
14694pub struct TargetableRemarketingListMethods<'a, C>
14695where
14696    C: 'a,
14697{
14698    hub: &'a Dfareporting<C>,
14699}
14700
14701impl<'a, C> common::MethodsBuilder for TargetableRemarketingListMethods<'a, C> {}
14702
14703impl<'a, C> TargetableRemarketingListMethods<'a, C> {
14704    /// Create a builder to help you perform the following task:
14705    ///
14706    /// Gets one remarketing list by ID.
14707    ///
14708    /// # Arguments
14709    ///
14710    /// * `profileId` - User profile ID associated with this request.
14711    /// * `id` - Remarketing list ID.
14712    pub fn get(&self, profile_id: i64, id: i64) -> TargetableRemarketingListGetCall<'a, C> {
14713        TargetableRemarketingListGetCall {
14714            hub: self.hub,
14715            _profile_id: profile_id,
14716            _id: id,
14717            _delegate: Default::default(),
14718            _additional_params: Default::default(),
14719            _scopes: Default::default(),
14720        }
14721    }
14722
14723    /// Create a builder to help you perform the following task:
14724    ///
14725    /// Retrieves a list of targetable remarketing lists, possibly filtered. This method supports paging.
14726    ///
14727    /// # Arguments
14728    ///
14729    /// * `profileId` - User profile ID associated with this request.
14730    /// * `advertiserId` - Select only targetable remarketing lists targetable by these advertisers.
14731    pub fn list(
14732        &self,
14733        profile_id: i64,
14734        advertiser_id: i64,
14735    ) -> TargetableRemarketingListListCall<'a, C> {
14736        TargetableRemarketingListListCall {
14737            hub: self.hub,
14738            _profile_id: profile_id,
14739            _advertiser_id: advertiser_id,
14740            _sort_order: Default::default(),
14741            _sort_field: Default::default(),
14742            _page_token: Default::default(),
14743            _name: Default::default(),
14744            _max_results: Default::default(),
14745            _active: Default::default(),
14746            _delegate: Default::default(),
14747            _additional_params: Default::default(),
14748            _scopes: Default::default(),
14749        }
14750    }
14751}
14752
14753/// A builder providing access to all methods supported on *targetingTemplate* resources.
14754/// It is not used directly, but through the [`Dfareporting`] hub.
14755///
14756/// # Example
14757///
14758/// Instantiate a resource builder
14759///
14760/// ```test_harness,no_run
14761/// extern crate hyper;
14762/// extern crate hyper_rustls;
14763/// extern crate google_dfareporting3d2 as dfareporting3d2;
14764///
14765/// # async fn dox() {
14766/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14767///
14768/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14769/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14770///     secret,
14771///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14772/// ).build().await.unwrap();
14773///
14774/// let client = hyper_util::client::legacy::Client::builder(
14775///     hyper_util::rt::TokioExecutor::new()
14776/// )
14777/// .build(
14778///     hyper_rustls::HttpsConnectorBuilder::new()
14779///         .with_native_roots()
14780///         .unwrap()
14781///         .https_or_http()
14782///         .enable_http1()
14783///         .build()
14784/// );
14785/// let mut hub = Dfareporting::new(client, auth);
14786/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14787/// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
14788/// // to build up your call.
14789/// let rb = hub.targeting_templates();
14790/// # }
14791/// ```
14792pub struct TargetingTemplateMethods<'a, C>
14793where
14794    C: 'a,
14795{
14796    hub: &'a Dfareporting<C>,
14797}
14798
14799impl<'a, C> common::MethodsBuilder for TargetingTemplateMethods<'a, C> {}
14800
14801impl<'a, C> TargetingTemplateMethods<'a, C> {
14802    /// Create a builder to help you perform the following task:
14803    ///
14804    /// Gets one targeting template by ID.
14805    ///
14806    /// # Arguments
14807    ///
14808    /// * `profileId` - User profile ID associated with this request.
14809    /// * `id` - Targeting template ID.
14810    pub fn get(&self, profile_id: i64, id: i64) -> TargetingTemplateGetCall<'a, C> {
14811        TargetingTemplateGetCall {
14812            hub: self.hub,
14813            _profile_id: profile_id,
14814            _id: id,
14815            _delegate: Default::default(),
14816            _additional_params: Default::default(),
14817            _scopes: Default::default(),
14818        }
14819    }
14820
14821    /// Create a builder to help you perform the following task:
14822    ///
14823    /// Inserts a new targeting template.
14824    ///
14825    /// # Arguments
14826    ///
14827    /// * `request` - No description provided.
14828    /// * `profileId` - User profile ID associated with this request.
14829    pub fn insert(
14830        &self,
14831        request: TargetingTemplate,
14832        profile_id: i64,
14833    ) -> TargetingTemplateInsertCall<'a, C> {
14834        TargetingTemplateInsertCall {
14835            hub: self.hub,
14836            _request: request,
14837            _profile_id: profile_id,
14838            _delegate: Default::default(),
14839            _additional_params: Default::default(),
14840            _scopes: Default::default(),
14841        }
14842    }
14843
14844    /// Create a builder to help you perform the following task:
14845    ///
14846    /// Retrieves a list of targeting templates, optionally filtered. This method supports paging.
14847    ///
14848    /// # Arguments
14849    ///
14850    /// * `profileId` - User profile ID associated with this request.
14851    pub fn list(&self, profile_id: i64) -> TargetingTemplateListCall<'a, C> {
14852        TargetingTemplateListCall {
14853            hub: self.hub,
14854            _profile_id: profile_id,
14855            _sort_order: Default::default(),
14856            _sort_field: Default::default(),
14857            _search_string: Default::default(),
14858            _page_token: Default::default(),
14859            _max_results: Default::default(),
14860            _ids: Default::default(),
14861            _advertiser_id: Default::default(),
14862            _delegate: Default::default(),
14863            _additional_params: Default::default(),
14864            _scopes: Default::default(),
14865        }
14866    }
14867
14868    /// Create a builder to help you perform the following task:
14869    ///
14870    /// Updates an existing targeting template. This method supports patch semantics.
14871    ///
14872    /// # Arguments
14873    ///
14874    /// * `request` - No description provided.
14875    /// * `profileId` - User profile ID associated with this request.
14876    /// * `id` - Targeting template ID.
14877    pub fn patch(
14878        &self,
14879        request: TargetingTemplate,
14880        profile_id: i64,
14881        id: i64,
14882    ) -> TargetingTemplatePatchCall<'a, C> {
14883        TargetingTemplatePatchCall {
14884            hub: self.hub,
14885            _request: request,
14886            _profile_id: profile_id,
14887            _id: id,
14888            _delegate: Default::default(),
14889            _additional_params: Default::default(),
14890            _scopes: Default::default(),
14891        }
14892    }
14893
14894    /// Create a builder to help you perform the following task:
14895    ///
14896    /// Updates an existing targeting template.
14897    ///
14898    /// # Arguments
14899    ///
14900    /// * `request` - No description provided.
14901    /// * `profileId` - User profile ID associated with this request.
14902    pub fn update(
14903        &self,
14904        request: TargetingTemplate,
14905        profile_id: i64,
14906    ) -> TargetingTemplateUpdateCall<'a, C> {
14907        TargetingTemplateUpdateCall {
14908            hub: self.hub,
14909            _request: request,
14910            _profile_id: profile_id,
14911            _delegate: Default::default(),
14912            _additional_params: Default::default(),
14913            _scopes: Default::default(),
14914        }
14915    }
14916}
14917
14918/// A builder providing access to all methods supported on *userProfile* resources.
14919/// It is not used directly, but through the [`Dfareporting`] hub.
14920///
14921/// # Example
14922///
14923/// Instantiate a resource builder
14924///
14925/// ```test_harness,no_run
14926/// extern crate hyper;
14927/// extern crate hyper_rustls;
14928/// extern crate google_dfareporting3d2 as dfareporting3d2;
14929///
14930/// # async fn dox() {
14931/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14932///
14933/// let secret: yup_oauth2::ApplicationSecret = Default::default();
14934/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14935///     secret,
14936///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14937/// ).build().await.unwrap();
14938///
14939/// let client = hyper_util::client::legacy::Client::builder(
14940///     hyper_util::rt::TokioExecutor::new()
14941/// )
14942/// .build(
14943///     hyper_rustls::HttpsConnectorBuilder::new()
14944///         .with_native_roots()
14945///         .unwrap()
14946///         .https_or_http()
14947///         .enable_http1()
14948///         .build()
14949/// );
14950/// let mut hub = Dfareporting::new(client, auth);
14951/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
14952/// // like `get(...)` and `list(...)`
14953/// // to build up your call.
14954/// let rb = hub.user_profiles();
14955/// # }
14956/// ```
14957pub struct UserProfileMethods<'a, C>
14958where
14959    C: 'a,
14960{
14961    hub: &'a Dfareporting<C>,
14962}
14963
14964impl<'a, C> common::MethodsBuilder for UserProfileMethods<'a, C> {}
14965
14966impl<'a, C> UserProfileMethods<'a, C> {
14967    /// Create a builder to help you perform the following task:
14968    ///
14969    /// Gets one user profile by ID.
14970    ///
14971    /// # Arguments
14972    ///
14973    /// * `profileId` - The user profile ID.
14974    pub fn get(&self, profile_id: i64) -> UserProfileGetCall<'a, C> {
14975        UserProfileGetCall {
14976            hub: self.hub,
14977            _profile_id: profile_id,
14978            _delegate: Default::default(),
14979            _additional_params: Default::default(),
14980            _scopes: Default::default(),
14981        }
14982    }
14983
14984    /// Create a builder to help you perform the following task:
14985    ///
14986    /// Retrieves list of user profiles for a user.
14987    pub fn list(&self) -> UserProfileListCall<'a, C> {
14988        UserProfileListCall {
14989            hub: self.hub,
14990            _delegate: Default::default(),
14991            _additional_params: Default::default(),
14992            _scopes: Default::default(),
14993        }
14994    }
14995}
14996
14997/// A builder providing access to all methods supported on *userRolePermissionGroup* resources.
14998/// It is not used directly, but through the [`Dfareporting`] hub.
14999///
15000/// # Example
15001///
15002/// Instantiate a resource builder
15003///
15004/// ```test_harness,no_run
15005/// extern crate hyper;
15006/// extern crate hyper_rustls;
15007/// extern crate google_dfareporting3d2 as dfareporting3d2;
15008///
15009/// # async fn dox() {
15010/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15011///
15012/// let secret: yup_oauth2::ApplicationSecret = Default::default();
15013/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15014///     secret,
15015///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15016/// ).build().await.unwrap();
15017///
15018/// let client = hyper_util::client::legacy::Client::builder(
15019///     hyper_util::rt::TokioExecutor::new()
15020/// )
15021/// .build(
15022///     hyper_rustls::HttpsConnectorBuilder::new()
15023///         .with_native_roots()
15024///         .unwrap()
15025///         .https_or_http()
15026///         .enable_http1()
15027///         .build()
15028/// );
15029/// let mut hub = Dfareporting::new(client, auth);
15030/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
15031/// // like `get(...)` and `list(...)`
15032/// // to build up your call.
15033/// let rb = hub.user_role_permission_groups();
15034/// # }
15035/// ```
15036pub struct UserRolePermissionGroupMethods<'a, C>
15037where
15038    C: 'a,
15039{
15040    hub: &'a Dfareporting<C>,
15041}
15042
15043impl<'a, C> common::MethodsBuilder for UserRolePermissionGroupMethods<'a, C> {}
15044
15045impl<'a, C> UserRolePermissionGroupMethods<'a, C> {
15046    /// Create a builder to help you perform the following task:
15047    ///
15048    /// Gets one user role permission group by ID.
15049    ///
15050    /// # Arguments
15051    ///
15052    /// * `profileId` - User profile ID associated with this request.
15053    /// * `id` - User role permission group ID.
15054    pub fn get(&self, profile_id: i64, id: i64) -> UserRolePermissionGroupGetCall<'a, C> {
15055        UserRolePermissionGroupGetCall {
15056            hub: self.hub,
15057            _profile_id: profile_id,
15058            _id: id,
15059            _delegate: Default::default(),
15060            _additional_params: Default::default(),
15061            _scopes: Default::default(),
15062        }
15063    }
15064
15065    /// Create a builder to help you perform the following task:
15066    ///
15067    /// Gets a list of all supported user role permission groups.
15068    ///
15069    /// # Arguments
15070    ///
15071    /// * `profileId` - User profile ID associated with this request.
15072    pub fn list(&self, profile_id: i64) -> UserRolePermissionGroupListCall<'a, C> {
15073        UserRolePermissionGroupListCall {
15074            hub: self.hub,
15075            _profile_id: profile_id,
15076            _delegate: Default::default(),
15077            _additional_params: Default::default(),
15078            _scopes: Default::default(),
15079        }
15080    }
15081}
15082
15083/// A builder providing access to all methods supported on *userRolePermission* resources.
15084/// It is not used directly, but through the [`Dfareporting`] hub.
15085///
15086/// # Example
15087///
15088/// Instantiate a resource builder
15089///
15090/// ```test_harness,no_run
15091/// extern crate hyper;
15092/// extern crate hyper_rustls;
15093/// extern crate google_dfareporting3d2 as dfareporting3d2;
15094///
15095/// # async fn dox() {
15096/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15097///
15098/// let secret: yup_oauth2::ApplicationSecret = Default::default();
15099/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15100///     secret,
15101///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15102/// ).build().await.unwrap();
15103///
15104/// let client = hyper_util::client::legacy::Client::builder(
15105///     hyper_util::rt::TokioExecutor::new()
15106/// )
15107/// .build(
15108///     hyper_rustls::HttpsConnectorBuilder::new()
15109///         .with_native_roots()
15110///         .unwrap()
15111///         .https_or_http()
15112///         .enable_http1()
15113///         .build()
15114/// );
15115/// let mut hub = Dfareporting::new(client, auth);
15116/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
15117/// // like `get(...)` and `list(...)`
15118/// // to build up your call.
15119/// let rb = hub.user_role_permissions();
15120/// # }
15121/// ```
15122pub struct UserRolePermissionMethods<'a, C>
15123where
15124    C: 'a,
15125{
15126    hub: &'a Dfareporting<C>,
15127}
15128
15129impl<'a, C> common::MethodsBuilder for UserRolePermissionMethods<'a, C> {}
15130
15131impl<'a, C> UserRolePermissionMethods<'a, C> {
15132    /// Create a builder to help you perform the following task:
15133    ///
15134    /// Gets one user role permission by ID.
15135    ///
15136    /// # Arguments
15137    ///
15138    /// * `profileId` - User profile ID associated with this request.
15139    /// * `id` - User role permission ID.
15140    pub fn get(&self, profile_id: i64, id: i64) -> UserRolePermissionGetCall<'a, C> {
15141        UserRolePermissionGetCall {
15142            hub: self.hub,
15143            _profile_id: profile_id,
15144            _id: id,
15145            _delegate: Default::default(),
15146            _additional_params: Default::default(),
15147            _scopes: Default::default(),
15148        }
15149    }
15150
15151    /// Create a builder to help you perform the following task:
15152    ///
15153    /// Gets a list of user role permissions, possibly filtered.
15154    ///
15155    /// # Arguments
15156    ///
15157    /// * `profileId` - User profile ID associated with this request.
15158    pub fn list(&self, profile_id: i64) -> UserRolePermissionListCall<'a, C> {
15159        UserRolePermissionListCall {
15160            hub: self.hub,
15161            _profile_id: profile_id,
15162            _ids: Default::default(),
15163            _delegate: Default::default(),
15164            _additional_params: Default::default(),
15165            _scopes: Default::default(),
15166        }
15167    }
15168}
15169
15170/// A builder providing access to all methods supported on *userRole* resources.
15171/// It is not used directly, but through the [`Dfareporting`] hub.
15172///
15173/// # Example
15174///
15175/// Instantiate a resource builder
15176///
15177/// ```test_harness,no_run
15178/// extern crate hyper;
15179/// extern crate hyper_rustls;
15180/// extern crate google_dfareporting3d2 as dfareporting3d2;
15181///
15182/// # async fn dox() {
15183/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15184///
15185/// let secret: yup_oauth2::ApplicationSecret = Default::default();
15186/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15187///     secret,
15188///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15189/// ).build().await.unwrap();
15190///
15191/// let client = hyper_util::client::legacy::Client::builder(
15192///     hyper_util::rt::TokioExecutor::new()
15193/// )
15194/// .build(
15195///     hyper_rustls::HttpsConnectorBuilder::new()
15196///         .with_native_roots()
15197///         .unwrap()
15198///         .https_or_http()
15199///         .enable_http1()
15200///         .build()
15201/// );
15202/// let mut hub = Dfareporting::new(client, auth);
15203/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
15204/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
15205/// // to build up your call.
15206/// let rb = hub.user_roles();
15207/// # }
15208/// ```
15209pub struct UserRoleMethods<'a, C>
15210where
15211    C: 'a,
15212{
15213    hub: &'a Dfareporting<C>,
15214}
15215
15216impl<'a, C> common::MethodsBuilder for UserRoleMethods<'a, C> {}
15217
15218impl<'a, C> UserRoleMethods<'a, C> {
15219    /// Create a builder to help you perform the following task:
15220    ///
15221    /// Deletes an existing user role.
15222    ///
15223    /// # Arguments
15224    ///
15225    /// * `profileId` - User profile ID associated with this request.
15226    /// * `id` - User role ID.
15227    pub fn delete(&self, profile_id: i64, id: i64) -> UserRoleDeleteCall<'a, C> {
15228        UserRoleDeleteCall {
15229            hub: self.hub,
15230            _profile_id: profile_id,
15231            _id: id,
15232            _delegate: Default::default(),
15233            _additional_params: Default::default(),
15234            _scopes: Default::default(),
15235        }
15236    }
15237
15238    /// Create a builder to help you perform the following task:
15239    ///
15240    /// Gets one user role by ID.
15241    ///
15242    /// # Arguments
15243    ///
15244    /// * `profileId` - User profile ID associated with this request.
15245    /// * `id` - User role ID.
15246    pub fn get(&self, profile_id: i64, id: i64) -> UserRoleGetCall<'a, C> {
15247        UserRoleGetCall {
15248            hub: self.hub,
15249            _profile_id: profile_id,
15250            _id: id,
15251            _delegate: Default::default(),
15252            _additional_params: Default::default(),
15253            _scopes: Default::default(),
15254        }
15255    }
15256
15257    /// Create a builder to help you perform the following task:
15258    ///
15259    /// Inserts a new user role.
15260    ///
15261    /// # Arguments
15262    ///
15263    /// * `request` - No description provided.
15264    /// * `profileId` - User profile ID associated with this request.
15265    pub fn insert(&self, request: UserRole, profile_id: i64) -> UserRoleInsertCall<'a, C> {
15266        UserRoleInsertCall {
15267            hub: self.hub,
15268            _request: request,
15269            _profile_id: profile_id,
15270            _delegate: Default::default(),
15271            _additional_params: Default::default(),
15272            _scopes: Default::default(),
15273        }
15274    }
15275
15276    /// Create a builder to help you perform the following task:
15277    ///
15278    /// Retrieves a list of user roles, possibly filtered. This method supports paging.
15279    ///
15280    /// # Arguments
15281    ///
15282    /// * `profileId` - User profile ID associated with this request.
15283    pub fn list(&self, profile_id: i64) -> UserRoleListCall<'a, C> {
15284        UserRoleListCall {
15285            hub: self.hub,
15286            _profile_id: profile_id,
15287            _subaccount_id: Default::default(),
15288            _sort_order: Default::default(),
15289            _sort_field: Default::default(),
15290            _search_string: Default::default(),
15291            _page_token: Default::default(),
15292            _max_results: Default::default(),
15293            _ids: Default::default(),
15294            _account_user_role_only: Default::default(),
15295            _delegate: Default::default(),
15296            _additional_params: Default::default(),
15297            _scopes: Default::default(),
15298        }
15299    }
15300
15301    /// Create a builder to help you perform the following task:
15302    ///
15303    /// Updates an existing user role. This method supports patch semantics.
15304    ///
15305    /// # Arguments
15306    ///
15307    /// * `request` - No description provided.
15308    /// * `profileId` - User profile ID associated with this request.
15309    /// * `id` - User role ID.
15310    pub fn patch(&self, request: UserRole, profile_id: i64, id: i64) -> UserRolePatchCall<'a, C> {
15311        UserRolePatchCall {
15312            hub: self.hub,
15313            _request: request,
15314            _profile_id: profile_id,
15315            _id: id,
15316            _delegate: Default::default(),
15317            _additional_params: Default::default(),
15318            _scopes: Default::default(),
15319        }
15320    }
15321
15322    /// Create a builder to help you perform the following task:
15323    ///
15324    /// Updates an existing user role.
15325    ///
15326    /// # Arguments
15327    ///
15328    /// * `request` - No description provided.
15329    /// * `profileId` - User profile ID associated with this request.
15330    pub fn update(&self, request: UserRole, profile_id: i64) -> UserRoleUpdateCall<'a, C> {
15331        UserRoleUpdateCall {
15332            hub: self.hub,
15333            _request: request,
15334            _profile_id: profile_id,
15335            _delegate: Default::default(),
15336            _additional_params: Default::default(),
15337            _scopes: Default::default(),
15338        }
15339    }
15340}
15341
15342/// A builder providing access to all methods supported on *videoFormat* resources.
15343/// It is not used directly, but through the [`Dfareporting`] hub.
15344///
15345/// # Example
15346///
15347/// Instantiate a resource builder
15348///
15349/// ```test_harness,no_run
15350/// extern crate hyper;
15351/// extern crate hyper_rustls;
15352/// extern crate google_dfareporting3d2 as dfareporting3d2;
15353///
15354/// # async fn dox() {
15355/// use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15356///
15357/// let secret: yup_oauth2::ApplicationSecret = Default::default();
15358/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15359///     secret,
15360///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15361/// ).build().await.unwrap();
15362///
15363/// let client = hyper_util::client::legacy::Client::builder(
15364///     hyper_util::rt::TokioExecutor::new()
15365/// )
15366/// .build(
15367///     hyper_rustls::HttpsConnectorBuilder::new()
15368///         .with_native_roots()
15369///         .unwrap()
15370///         .https_or_http()
15371///         .enable_http1()
15372///         .build()
15373/// );
15374/// let mut hub = Dfareporting::new(client, auth);
15375/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
15376/// // like `get(...)` and `list(...)`
15377/// // to build up your call.
15378/// let rb = hub.video_formats();
15379/// # }
15380/// ```
15381pub struct VideoFormatMethods<'a, C>
15382where
15383    C: 'a,
15384{
15385    hub: &'a Dfareporting<C>,
15386}
15387
15388impl<'a, C> common::MethodsBuilder for VideoFormatMethods<'a, C> {}
15389
15390impl<'a, C> VideoFormatMethods<'a, C> {
15391    /// Create a builder to help you perform the following task:
15392    ///
15393    /// Gets one video format by ID.
15394    ///
15395    /// # Arguments
15396    ///
15397    /// * `profileId` - User profile ID associated with this request.
15398    /// * `id` - Video format ID.
15399    pub fn get(&self, profile_id: i64, id: i32) -> VideoFormatGetCall<'a, C> {
15400        VideoFormatGetCall {
15401            hub: self.hub,
15402            _profile_id: profile_id,
15403            _id: id,
15404            _delegate: Default::default(),
15405            _additional_params: Default::default(),
15406            _scopes: Default::default(),
15407        }
15408    }
15409
15410    /// Create a builder to help you perform the following task:
15411    ///
15412    /// Lists available video formats.
15413    ///
15414    /// # Arguments
15415    ///
15416    /// * `profileId` - User profile ID associated with this request.
15417    pub fn list(&self, profile_id: i64) -> VideoFormatListCall<'a, C> {
15418        VideoFormatListCall {
15419            hub: self.hub,
15420            _profile_id: profile_id,
15421            _delegate: Default::default(),
15422            _additional_params: Default::default(),
15423            _scopes: Default::default(),
15424        }
15425    }
15426}
15427
15428// ###################
15429// CallBuilders   ###
15430// #################
15431
15432/// Gets the account's active ad summary by account ID.
15433///
15434/// A builder for the *get* method supported by a *accountActiveAdSummary* resource.
15435/// It is not used directly, but through a [`AccountActiveAdSummaryMethods`] instance.
15436///
15437/// # Example
15438///
15439/// Instantiate a resource method builder
15440///
15441/// ```test_harness,no_run
15442/// # extern crate hyper;
15443/// # extern crate hyper_rustls;
15444/// # extern crate google_dfareporting3d2 as dfareporting3d2;
15445/// # async fn dox() {
15446/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15447///
15448/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15449/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15450/// #     secret,
15451/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15452/// # ).build().await.unwrap();
15453///
15454/// # let client = hyper_util::client::legacy::Client::builder(
15455/// #     hyper_util::rt::TokioExecutor::new()
15456/// # )
15457/// # .build(
15458/// #     hyper_rustls::HttpsConnectorBuilder::new()
15459/// #         .with_native_roots()
15460/// #         .unwrap()
15461/// #         .https_or_http()
15462/// #         .enable_http1()
15463/// #         .build()
15464/// # );
15465/// # let mut hub = Dfareporting::new(client, auth);
15466/// // You can configure optional parameters by calling the respective setters at will, and
15467/// // execute the final call using `doit()`.
15468/// // Values shown here are possibly random and not representative !
15469/// let result = hub.account_active_ad_summaries().get(-17, -55)
15470///              .doit().await;
15471/// # }
15472/// ```
15473pub struct AccountActiveAdSummaryGetCall<'a, C>
15474where
15475    C: 'a,
15476{
15477    hub: &'a Dfareporting<C>,
15478    _profile_id: i64,
15479    _summary_account_id: i64,
15480    _delegate: Option<&'a mut dyn common::Delegate>,
15481    _additional_params: HashMap<String, String>,
15482    _scopes: BTreeSet<String>,
15483}
15484
15485impl<'a, C> common::CallBuilder for AccountActiveAdSummaryGetCall<'a, C> {}
15486
15487impl<'a, C> AccountActiveAdSummaryGetCall<'a, C>
15488where
15489    C: common::Connector,
15490{
15491    /// Perform the operation you have build so far.
15492    pub async fn doit(mut self) -> common::Result<(common::Response, AccountActiveAdSummary)> {
15493        use std::borrow::Cow;
15494        use std::io::{Read, Seek};
15495
15496        use common::{url::Params, ToParts};
15497        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15498
15499        let mut dd = common::DefaultDelegate;
15500        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15501        dlg.begin(common::MethodInfo {
15502            id: "dfareporting.accountActiveAdSummaries.get",
15503            http_method: hyper::Method::GET,
15504        });
15505
15506        for &field in ["alt", "profileId", "summaryAccountId"].iter() {
15507            if self._additional_params.contains_key(field) {
15508                dlg.finished(false);
15509                return Err(common::Error::FieldClash(field));
15510            }
15511        }
15512
15513        let mut params = Params::with_capacity(4 + self._additional_params.len());
15514        params.push("profileId", self._profile_id.to_string());
15515        params.push("summaryAccountId", self._summary_account_id.to_string());
15516
15517        params.extend(self._additional_params.iter());
15518
15519        params.push("alt", "json");
15520        let mut url = self.hub._base_url.clone()
15521            + "userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}";
15522        if self._scopes.is_empty() {
15523            self._scopes
15524                .insert(Scope::Dfatrafficking.as_ref().to_string());
15525        }
15526
15527        #[allow(clippy::single_element_loop)]
15528        for &(find_this, param_name) in [
15529            ("{profileId}", "profileId"),
15530            ("{summaryAccountId}", "summaryAccountId"),
15531        ]
15532        .iter()
15533        {
15534            url = params.uri_replacement(url, param_name, find_this, false);
15535        }
15536        {
15537            let to_remove = ["summaryAccountId", "profileId"];
15538            params.remove_params(&to_remove);
15539        }
15540
15541        let url = params.parse_with_url(&url);
15542
15543        loop {
15544            let token = match self
15545                .hub
15546                .auth
15547                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15548                .await
15549            {
15550                Ok(token) => token,
15551                Err(e) => match dlg.token(e) {
15552                    Ok(token) => token,
15553                    Err(e) => {
15554                        dlg.finished(false);
15555                        return Err(common::Error::MissingToken(e));
15556                    }
15557                },
15558            };
15559            let mut req_result = {
15560                let client = &self.hub.client;
15561                dlg.pre_request();
15562                let mut req_builder = hyper::Request::builder()
15563                    .method(hyper::Method::GET)
15564                    .uri(url.as_str())
15565                    .header(USER_AGENT, self.hub._user_agent.clone());
15566
15567                if let Some(token) = token.as_ref() {
15568                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15569                }
15570
15571                let request = req_builder
15572                    .header(CONTENT_LENGTH, 0_u64)
15573                    .body(common::to_body::<String>(None));
15574
15575                client.request(request.unwrap()).await
15576            };
15577
15578            match req_result {
15579                Err(err) => {
15580                    if let common::Retry::After(d) = dlg.http_error(&err) {
15581                        sleep(d).await;
15582                        continue;
15583                    }
15584                    dlg.finished(false);
15585                    return Err(common::Error::HttpError(err));
15586                }
15587                Ok(res) => {
15588                    let (mut parts, body) = res.into_parts();
15589                    let mut body = common::Body::new(body);
15590                    if !parts.status.is_success() {
15591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15592                        let error = serde_json::from_str(&common::to_string(&bytes));
15593                        let response = common::to_response(parts, bytes.into());
15594
15595                        if let common::Retry::After(d) =
15596                            dlg.http_failure(&response, error.as_ref().ok())
15597                        {
15598                            sleep(d).await;
15599                            continue;
15600                        }
15601
15602                        dlg.finished(false);
15603
15604                        return Err(match error {
15605                            Ok(value) => common::Error::BadRequest(value),
15606                            _ => common::Error::Failure(response),
15607                        });
15608                    }
15609                    let response = {
15610                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15611                        let encoded = common::to_string(&bytes);
15612                        match serde_json::from_str(&encoded) {
15613                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15614                            Err(error) => {
15615                                dlg.response_json_decode_error(&encoded, &error);
15616                                return Err(common::Error::JsonDecodeError(
15617                                    encoded.to_string(),
15618                                    error,
15619                                ));
15620                            }
15621                        }
15622                    };
15623
15624                    dlg.finished(true);
15625                    return Ok(response);
15626                }
15627            }
15628        }
15629    }
15630
15631    /// User profile ID associated with this request.
15632    ///
15633    /// Sets the *profile id* path property to the given value.
15634    ///
15635    /// Even though the property as already been set when instantiating this call,
15636    /// we provide this method for API completeness.
15637    pub fn profile_id(mut self, new_value: i64) -> AccountActiveAdSummaryGetCall<'a, C> {
15638        self._profile_id = new_value;
15639        self
15640    }
15641    /// Account ID.
15642    ///
15643    /// Sets the *summary account id* path property to the given value.
15644    ///
15645    /// Even though the property as already been set when instantiating this call,
15646    /// we provide this method for API completeness.
15647    pub fn summary_account_id(mut self, new_value: i64) -> AccountActiveAdSummaryGetCall<'a, C> {
15648        self._summary_account_id = new_value;
15649        self
15650    }
15651    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15652    /// while executing the actual API request.
15653    ///
15654    /// ````text
15655    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15656    /// ````
15657    ///
15658    /// Sets the *delegate* property to the given value.
15659    pub fn delegate(
15660        mut self,
15661        new_value: &'a mut dyn common::Delegate,
15662    ) -> AccountActiveAdSummaryGetCall<'a, C> {
15663        self._delegate = Some(new_value);
15664        self
15665    }
15666
15667    /// Set any additional parameter of the query string used in the request.
15668    /// It should be used to set parameters which are not yet available through their own
15669    /// setters.
15670    ///
15671    /// Please note that this method must not be used to set any of the known parameters
15672    /// which have their own setter method. If done anyway, the request will fail.
15673    ///
15674    /// # Additional Parameters
15675    ///
15676    /// * *alt* (query-string) - Data format for the response.
15677    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15678    /// * *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.
15679    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15680    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15681    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15682    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15683    pub fn param<T>(mut self, name: T, value: T) -> AccountActiveAdSummaryGetCall<'a, C>
15684    where
15685        T: AsRef<str>,
15686    {
15687        self._additional_params
15688            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15689        self
15690    }
15691
15692    /// Identifies the authorization scope for the method you are building.
15693    ///
15694    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15695    /// [`Scope::Dfatrafficking`].
15696    ///
15697    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15698    /// tokens for more than one scope.
15699    ///
15700    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15701    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15702    /// sufficient, a read-write scope will do as well.
15703    pub fn add_scope<St>(mut self, scope: St) -> AccountActiveAdSummaryGetCall<'a, C>
15704    where
15705        St: AsRef<str>,
15706    {
15707        self._scopes.insert(String::from(scope.as_ref()));
15708        self
15709    }
15710    /// Identifies the authorization scope(s) for the method you are building.
15711    ///
15712    /// See [`Self::add_scope()`] for details.
15713    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountActiveAdSummaryGetCall<'a, C>
15714    where
15715        I: IntoIterator<Item = St>,
15716        St: AsRef<str>,
15717    {
15718        self._scopes
15719            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15720        self
15721    }
15722
15723    /// Removes all scopes, and no default scope will be used either.
15724    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15725    /// for details).
15726    pub fn clear_scopes(mut self) -> AccountActiveAdSummaryGetCall<'a, C> {
15727        self._scopes.clear();
15728        self
15729    }
15730}
15731
15732/// Gets one account permission group by ID.
15733///
15734/// A builder for the *get* method supported by a *accountPermissionGroup* resource.
15735/// It is not used directly, but through a [`AccountPermissionGroupMethods`] instance.
15736///
15737/// # Example
15738///
15739/// Instantiate a resource method builder
15740///
15741/// ```test_harness,no_run
15742/// # extern crate hyper;
15743/// # extern crate hyper_rustls;
15744/// # extern crate google_dfareporting3d2 as dfareporting3d2;
15745/// # async fn dox() {
15746/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15747///
15748/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15749/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15750/// #     secret,
15751/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15752/// # ).build().await.unwrap();
15753///
15754/// # let client = hyper_util::client::legacy::Client::builder(
15755/// #     hyper_util::rt::TokioExecutor::new()
15756/// # )
15757/// # .build(
15758/// #     hyper_rustls::HttpsConnectorBuilder::new()
15759/// #         .with_native_roots()
15760/// #         .unwrap()
15761/// #         .https_or_http()
15762/// #         .enable_http1()
15763/// #         .build()
15764/// # );
15765/// # let mut hub = Dfareporting::new(client, auth);
15766/// // You can configure optional parameters by calling the respective setters at will, and
15767/// // execute the final call using `doit()`.
15768/// // Values shown here are possibly random and not representative !
15769/// let result = hub.account_permission_groups().get(-88, -47)
15770///              .doit().await;
15771/// # }
15772/// ```
15773pub struct AccountPermissionGroupGetCall<'a, C>
15774where
15775    C: 'a,
15776{
15777    hub: &'a Dfareporting<C>,
15778    _profile_id: i64,
15779    _id: i64,
15780    _delegate: Option<&'a mut dyn common::Delegate>,
15781    _additional_params: HashMap<String, String>,
15782    _scopes: BTreeSet<String>,
15783}
15784
15785impl<'a, C> common::CallBuilder for AccountPermissionGroupGetCall<'a, C> {}
15786
15787impl<'a, C> AccountPermissionGroupGetCall<'a, C>
15788where
15789    C: common::Connector,
15790{
15791    /// Perform the operation you have build so far.
15792    pub async fn doit(mut self) -> common::Result<(common::Response, AccountPermissionGroup)> {
15793        use std::borrow::Cow;
15794        use std::io::{Read, Seek};
15795
15796        use common::{url::Params, ToParts};
15797        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15798
15799        let mut dd = common::DefaultDelegate;
15800        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15801        dlg.begin(common::MethodInfo {
15802            id: "dfareporting.accountPermissionGroups.get",
15803            http_method: hyper::Method::GET,
15804        });
15805
15806        for &field in ["alt", "profileId", "id"].iter() {
15807            if self._additional_params.contains_key(field) {
15808                dlg.finished(false);
15809                return Err(common::Error::FieldClash(field));
15810            }
15811        }
15812
15813        let mut params = Params::with_capacity(4 + self._additional_params.len());
15814        params.push("profileId", self._profile_id.to_string());
15815        params.push("id", self._id.to_string());
15816
15817        params.extend(self._additional_params.iter());
15818
15819        params.push("alt", "json");
15820        let mut url =
15821            self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissionGroups/{id}";
15822        if self._scopes.is_empty() {
15823            self._scopes
15824                .insert(Scope::Dfatrafficking.as_ref().to_string());
15825        }
15826
15827        #[allow(clippy::single_element_loop)]
15828        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
15829            url = params.uri_replacement(url, param_name, find_this, false);
15830        }
15831        {
15832            let to_remove = ["id", "profileId"];
15833            params.remove_params(&to_remove);
15834        }
15835
15836        let url = params.parse_with_url(&url);
15837
15838        loop {
15839            let token = match self
15840                .hub
15841                .auth
15842                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15843                .await
15844            {
15845                Ok(token) => token,
15846                Err(e) => match dlg.token(e) {
15847                    Ok(token) => token,
15848                    Err(e) => {
15849                        dlg.finished(false);
15850                        return Err(common::Error::MissingToken(e));
15851                    }
15852                },
15853            };
15854            let mut req_result = {
15855                let client = &self.hub.client;
15856                dlg.pre_request();
15857                let mut req_builder = hyper::Request::builder()
15858                    .method(hyper::Method::GET)
15859                    .uri(url.as_str())
15860                    .header(USER_AGENT, self.hub._user_agent.clone());
15861
15862                if let Some(token) = token.as_ref() {
15863                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15864                }
15865
15866                let request = req_builder
15867                    .header(CONTENT_LENGTH, 0_u64)
15868                    .body(common::to_body::<String>(None));
15869
15870                client.request(request.unwrap()).await
15871            };
15872
15873            match req_result {
15874                Err(err) => {
15875                    if let common::Retry::After(d) = dlg.http_error(&err) {
15876                        sleep(d).await;
15877                        continue;
15878                    }
15879                    dlg.finished(false);
15880                    return Err(common::Error::HttpError(err));
15881                }
15882                Ok(res) => {
15883                    let (mut parts, body) = res.into_parts();
15884                    let mut body = common::Body::new(body);
15885                    if !parts.status.is_success() {
15886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15887                        let error = serde_json::from_str(&common::to_string(&bytes));
15888                        let response = common::to_response(parts, bytes.into());
15889
15890                        if let common::Retry::After(d) =
15891                            dlg.http_failure(&response, error.as_ref().ok())
15892                        {
15893                            sleep(d).await;
15894                            continue;
15895                        }
15896
15897                        dlg.finished(false);
15898
15899                        return Err(match error {
15900                            Ok(value) => common::Error::BadRequest(value),
15901                            _ => common::Error::Failure(response),
15902                        });
15903                    }
15904                    let response = {
15905                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15906                        let encoded = common::to_string(&bytes);
15907                        match serde_json::from_str(&encoded) {
15908                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15909                            Err(error) => {
15910                                dlg.response_json_decode_error(&encoded, &error);
15911                                return Err(common::Error::JsonDecodeError(
15912                                    encoded.to_string(),
15913                                    error,
15914                                ));
15915                            }
15916                        }
15917                    };
15918
15919                    dlg.finished(true);
15920                    return Ok(response);
15921                }
15922            }
15923        }
15924    }
15925
15926    /// User profile ID associated with this request.
15927    ///
15928    /// Sets the *profile id* path property to the given value.
15929    ///
15930    /// Even though the property as already been set when instantiating this call,
15931    /// we provide this method for API completeness.
15932    pub fn profile_id(mut self, new_value: i64) -> AccountPermissionGroupGetCall<'a, C> {
15933        self._profile_id = new_value;
15934        self
15935    }
15936    /// Account permission group ID.
15937    ///
15938    /// Sets the *id* path property to the given value.
15939    ///
15940    /// Even though the property as already been set when instantiating this call,
15941    /// we provide this method for API completeness.
15942    pub fn id(mut self, new_value: i64) -> AccountPermissionGroupGetCall<'a, C> {
15943        self._id = new_value;
15944        self
15945    }
15946    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15947    /// while executing the actual API request.
15948    ///
15949    /// ````text
15950    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15951    /// ````
15952    ///
15953    /// Sets the *delegate* property to the given value.
15954    pub fn delegate(
15955        mut self,
15956        new_value: &'a mut dyn common::Delegate,
15957    ) -> AccountPermissionGroupGetCall<'a, C> {
15958        self._delegate = Some(new_value);
15959        self
15960    }
15961
15962    /// Set any additional parameter of the query string used in the request.
15963    /// It should be used to set parameters which are not yet available through their own
15964    /// setters.
15965    ///
15966    /// Please note that this method must not be used to set any of the known parameters
15967    /// which have their own setter method. If done anyway, the request will fail.
15968    ///
15969    /// # Additional Parameters
15970    ///
15971    /// * *alt* (query-string) - Data format for the response.
15972    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15973    /// * *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.
15974    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15975    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15976    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15977    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15978    pub fn param<T>(mut self, name: T, value: T) -> AccountPermissionGroupGetCall<'a, C>
15979    where
15980        T: AsRef<str>,
15981    {
15982        self._additional_params
15983            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15984        self
15985    }
15986
15987    /// Identifies the authorization scope for the method you are building.
15988    ///
15989    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15990    /// [`Scope::Dfatrafficking`].
15991    ///
15992    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15993    /// tokens for more than one scope.
15994    ///
15995    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15996    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15997    /// sufficient, a read-write scope will do as well.
15998    pub fn add_scope<St>(mut self, scope: St) -> AccountPermissionGroupGetCall<'a, C>
15999    where
16000        St: AsRef<str>,
16001    {
16002        self._scopes.insert(String::from(scope.as_ref()));
16003        self
16004    }
16005    /// Identifies the authorization scope(s) for the method you are building.
16006    ///
16007    /// See [`Self::add_scope()`] for details.
16008    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPermissionGroupGetCall<'a, C>
16009    where
16010        I: IntoIterator<Item = St>,
16011        St: AsRef<str>,
16012    {
16013        self._scopes
16014            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16015        self
16016    }
16017
16018    /// Removes all scopes, and no default scope will be used either.
16019    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16020    /// for details).
16021    pub fn clear_scopes(mut self) -> AccountPermissionGroupGetCall<'a, C> {
16022        self._scopes.clear();
16023        self
16024    }
16025}
16026
16027/// Retrieves the list of account permission groups.
16028///
16029/// A builder for the *list* method supported by a *accountPermissionGroup* resource.
16030/// It is not used directly, but through a [`AccountPermissionGroupMethods`] instance.
16031///
16032/// # Example
16033///
16034/// Instantiate a resource method builder
16035///
16036/// ```test_harness,no_run
16037/// # extern crate hyper;
16038/// # extern crate hyper_rustls;
16039/// # extern crate google_dfareporting3d2 as dfareporting3d2;
16040/// # async fn dox() {
16041/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16042///
16043/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16044/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16045/// #     secret,
16046/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16047/// # ).build().await.unwrap();
16048///
16049/// # let client = hyper_util::client::legacy::Client::builder(
16050/// #     hyper_util::rt::TokioExecutor::new()
16051/// # )
16052/// # .build(
16053/// #     hyper_rustls::HttpsConnectorBuilder::new()
16054/// #         .with_native_roots()
16055/// #         .unwrap()
16056/// #         .https_or_http()
16057/// #         .enable_http1()
16058/// #         .build()
16059/// # );
16060/// # let mut hub = Dfareporting::new(client, auth);
16061/// // You can configure optional parameters by calling the respective setters at will, and
16062/// // execute the final call using `doit()`.
16063/// // Values shown here are possibly random and not representative !
16064/// let result = hub.account_permission_groups().list(-20)
16065///              .doit().await;
16066/// # }
16067/// ```
16068pub struct AccountPermissionGroupListCall<'a, C>
16069where
16070    C: 'a,
16071{
16072    hub: &'a Dfareporting<C>,
16073    _profile_id: i64,
16074    _delegate: Option<&'a mut dyn common::Delegate>,
16075    _additional_params: HashMap<String, String>,
16076    _scopes: BTreeSet<String>,
16077}
16078
16079impl<'a, C> common::CallBuilder for AccountPermissionGroupListCall<'a, C> {}
16080
16081impl<'a, C> AccountPermissionGroupListCall<'a, C>
16082where
16083    C: common::Connector,
16084{
16085    /// Perform the operation you have build so far.
16086    pub async fn doit(
16087        mut self,
16088    ) -> common::Result<(common::Response, AccountPermissionGroupsListResponse)> {
16089        use std::borrow::Cow;
16090        use std::io::{Read, Seek};
16091
16092        use common::{url::Params, ToParts};
16093        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16094
16095        let mut dd = common::DefaultDelegate;
16096        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16097        dlg.begin(common::MethodInfo {
16098            id: "dfareporting.accountPermissionGroups.list",
16099            http_method: hyper::Method::GET,
16100        });
16101
16102        for &field in ["alt", "profileId"].iter() {
16103            if self._additional_params.contains_key(field) {
16104                dlg.finished(false);
16105                return Err(common::Error::FieldClash(field));
16106            }
16107        }
16108
16109        let mut params = Params::with_capacity(3 + self._additional_params.len());
16110        params.push("profileId", self._profile_id.to_string());
16111
16112        params.extend(self._additional_params.iter());
16113
16114        params.push("alt", "json");
16115        let mut url =
16116            self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissionGroups";
16117        if self._scopes.is_empty() {
16118            self._scopes
16119                .insert(Scope::Dfatrafficking.as_ref().to_string());
16120        }
16121
16122        #[allow(clippy::single_element_loop)]
16123        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
16124            url = params.uri_replacement(url, param_name, find_this, false);
16125        }
16126        {
16127            let to_remove = ["profileId"];
16128            params.remove_params(&to_remove);
16129        }
16130
16131        let url = params.parse_with_url(&url);
16132
16133        loop {
16134            let token = match self
16135                .hub
16136                .auth
16137                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16138                .await
16139            {
16140                Ok(token) => token,
16141                Err(e) => match dlg.token(e) {
16142                    Ok(token) => token,
16143                    Err(e) => {
16144                        dlg.finished(false);
16145                        return Err(common::Error::MissingToken(e));
16146                    }
16147                },
16148            };
16149            let mut req_result = {
16150                let client = &self.hub.client;
16151                dlg.pre_request();
16152                let mut req_builder = hyper::Request::builder()
16153                    .method(hyper::Method::GET)
16154                    .uri(url.as_str())
16155                    .header(USER_AGENT, self.hub._user_agent.clone());
16156
16157                if let Some(token) = token.as_ref() {
16158                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16159                }
16160
16161                let request = req_builder
16162                    .header(CONTENT_LENGTH, 0_u64)
16163                    .body(common::to_body::<String>(None));
16164
16165                client.request(request.unwrap()).await
16166            };
16167
16168            match req_result {
16169                Err(err) => {
16170                    if let common::Retry::After(d) = dlg.http_error(&err) {
16171                        sleep(d).await;
16172                        continue;
16173                    }
16174                    dlg.finished(false);
16175                    return Err(common::Error::HttpError(err));
16176                }
16177                Ok(res) => {
16178                    let (mut parts, body) = res.into_parts();
16179                    let mut body = common::Body::new(body);
16180                    if !parts.status.is_success() {
16181                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16182                        let error = serde_json::from_str(&common::to_string(&bytes));
16183                        let response = common::to_response(parts, bytes.into());
16184
16185                        if let common::Retry::After(d) =
16186                            dlg.http_failure(&response, error.as_ref().ok())
16187                        {
16188                            sleep(d).await;
16189                            continue;
16190                        }
16191
16192                        dlg.finished(false);
16193
16194                        return Err(match error {
16195                            Ok(value) => common::Error::BadRequest(value),
16196                            _ => common::Error::Failure(response),
16197                        });
16198                    }
16199                    let response = {
16200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16201                        let encoded = common::to_string(&bytes);
16202                        match serde_json::from_str(&encoded) {
16203                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16204                            Err(error) => {
16205                                dlg.response_json_decode_error(&encoded, &error);
16206                                return Err(common::Error::JsonDecodeError(
16207                                    encoded.to_string(),
16208                                    error,
16209                                ));
16210                            }
16211                        }
16212                    };
16213
16214                    dlg.finished(true);
16215                    return Ok(response);
16216                }
16217            }
16218        }
16219    }
16220
16221    /// User profile ID associated with this request.
16222    ///
16223    /// Sets the *profile id* path property to the given value.
16224    ///
16225    /// Even though the property as already been set when instantiating this call,
16226    /// we provide this method for API completeness.
16227    pub fn profile_id(mut self, new_value: i64) -> AccountPermissionGroupListCall<'a, C> {
16228        self._profile_id = new_value;
16229        self
16230    }
16231    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16232    /// while executing the actual API request.
16233    ///
16234    /// ````text
16235    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16236    /// ````
16237    ///
16238    /// Sets the *delegate* property to the given value.
16239    pub fn delegate(
16240        mut self,
16241        new_value: &'a mut dyn common::Delegate,
16242    ) -> AccountPermissionGroupListCall<'a, C> {
16243        self._delegate = Some(new_value);
16244        self
16245    }
16246
16247    /// Set any additional parameter of the query string used in the request.
16248    /// It should be used to set parameters which are not yet available through their own
16249    /// setters.
16250    ///
16251    /// Please note that this method must not be used to set any of the known parameters
16252    /// which have their own setter method. If done anyway, the request will fail.
16253    ///
16254    /// # Additional Parameters
16255    ///
16256    /// * *alt* (query-string) - Data format for the response.
16257    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16258    /// * *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.
16259    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16260    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16261    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16262    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16263    pub fn param<T>(mut self, name: T, value: T) -> AccountPermissionGroupListCall<'a, C>
16264    where
16265        T: AsRef<str>,
16266    {
16267        self._additional_params
16268            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16269        self
16270    }
16271
16272    /// Identifies the authorization scope for the method you are building.
16273    ///
16274    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16275    /// [`Scope::Dfatrafficking`].
16276    ///
16277    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16278    /// tokens for more than one scope.
16279    ///
16280    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16281    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16282    /// sufficient, a read-write scope will do as well.
16283    pub fn add_scope<St>(mut self, scope: St) -> AccountPermissionGroupListCall<'a, C>
16284    where
16285        St: AsRef<str>,
16286    {
16287        self._scopes.insert(String::from(scope.as_ref()));
16288        self
16289    }
16290    /// Identifies the authorization scope(s) for the method you are building.
16291    ///
16292    /// See [`Self::add_scope()`] for details.
16293    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPermissionGroupListCall<'a, C>
16294    where
16295        I: IntoIterator<Item = St>,
16296        St: AsRef<str>,
16297    {
16298        self._scopes
16299            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16300        self
16301    }
16302
16303    /// Removes all scopes, and no default scope will be used either.
16304    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16305    /// for details).
16306    pub fn clear_scopes(mut self) -> AccountPermissionGroupListCall<'a, C> {
16307        self._scopes.clear();
16308        self
16309    }
16310}
16311
16312/// Gets one account permission by ID.
16313///
16314/// A builder for the *get* method supported by a *accountPermission* resource.
16315/// It is not used directly, but through a [`AccountPermissionMethods`] instance.
16316///
16317/// # Example
16318///
16319/// Instantiate a resource method builder
16320///
16321/// ```test_harness,no_run
16322/// # extern crate hyper;
16323/// # extern crate hyper_rustls;
16324/// # extern crate google_dfareporting3d2 as dfareporting3d2;
16325/// # async fn dox() {
16326/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16327///
16328/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16330/// #     secret,
16331/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16332/// # ).build().await.unwrap();
16333///
16334/// # let client = hyper_util::client::legacy::Client::builder(
16335/// #     hyper_util::rt::TokioExecutor::new()
16336/// # )
16337/// # .build(
16338/// #     hyper_rustls::HttpsConnectorBuilder::new()
16339/// #         .with_native_roots()
16340/// #         .unwrap()
16341/// #         .https_or_http()
16342/// #         .enable_http1()
16343/// #         .build()
16344/// # );
16345/// # let mut hub = Dfareporting::new(client, auth);
16346/// // You can configure optional parameters by calling the respective setters at will, and
16347/// // execute the final call using `doit()`.
16348/// // Values shown here are possibly random and not representative !
16349/// let result = hub.account_permissions().get(-50, -93)
16350///              .doit().await;
16351/// # }
16352/// ```
16353pub struct AccountPermissionGetCall<'a, C>
16354where
16355    C: 'a,
16356{
16357    hub: &'a Dfareporting<C>,
16358    _profile_id: i64,
16359    _id: i64,
16360    _delegate: Option<&'a mut dyn common::Delegate>,
16361    _additional_params: HashMap<String, String>,
16362    _scopes: BTreeSet<String>,
16363}
16364
16365impl<'a, C> common::CallBuilder for AccountPermissionGetCall<'a, C> {}
16366
16367impl<'a, C> AccountPermissionGetCall<'a, C>
16368where
16369    C: common::Connector,
16370{
16371    /// Perform the operation you have build so far.
16372    pub async fn doit(mut self) -> common::Result<(common::Response, AccountPermission)> {
16373        use std::borrow::Cow;
16374        use std::io::{Read, Seek};
16375
16376        use common::{url::Params, ToParts};
16377        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16378
16379        let mut dd = common::DefaultDelegate;
16380        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16381        dlg.begin(common::MethodInfo {
16382            id: "dfareporting.accountPermissions.get",
16383            http_method: hyper::Method::GET,
16384        });
16385
16386        for &field in ["alt", "profileId", "id"].iter() {
16387            if self._additional_params.contains_key(field) {
16388                dlg.finished(false);
16389                return Err(common::Error::FieldClash(field));
16390            }
16391        }
16392
16393        let mut params = Params::with_capacity(4 + self._additional_params.len());
16394        params.push("profileId", self._profile_id.to_string());
16395        params.push("id", self._id.to_string());
16396
16397        params.extend(self._additional_params.iter());
16398
16399        params.push("alt", "json");
16400        let mut url =
16401            self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissions/{id}";
16402        if self._scopes.is_empty() {
16403            self._scopes
16404                .insert(Scope::Dfatrafficking.as_ref().to_string());
16405        }
16406
16407        #[allow(clippy::single_element_loop)]
16408        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
16409            url = params.uri_replacement(url, param_name, find_this, false);
16410        }
16411        {
16412            let to_remove = ["id", "profileId"];
16413            params.remove_params(&to_remove);
16414        }
16415
16416        let url = params.parse_with_url(&url);
16417
16418        loop {
16419            let token = match self
16420                .hub
16421                .auth
16422                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16423                .await
16424            {
16425                Ok(token) => token,
16426                Err(e) => match dlg.token(e) {
16427                    Ok(token) => token,
16428                    Err(e) => {
16429                        dlg.finished(false);
16430                        return Err(common::Error::MissingToken(e));
16431                    }
16432                },
16433            };
16434            let mut req_result = {
16435                let client = &self.hub.client;
16436                dlg.pre_request();
16437                let mut req_builder = hyper::Request::builder()
16438                    .method(hyper::Method::GET)
16439                    .uri(url.as_str())
16440                    .header(USER_AGENT, self.hub._user_agent.clone());
16441
16442                if let Some(token) = token.as_ref() {
16443                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16444                }
16445
16446                let request = req_builder
16447                    .header(CONTENT_LENGTH, 0_u64)
16448                    .body(common::to_body::<String>(None));
16449
16450                client.request(request.unwrap()).await
16451            };
16452
16453            match req_result {
16454                Err(err) => {
16455                    if let common::Retry::After(d) = dlg.http_error(&err) {
16456                        sleep(d).await;
16457                        continue;
16458                    }
16459                    dlg.finished(false);
16460                    return Err(common::Error::HttpError(err));
16461                }
16462                Ok(res) => {
16463                    let (mut parts, body) = res.into_parts();
16464                    let mut body = common::Body::new(body);
16465                    if !parts.status.is_success() {
16466                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16467                        let error = serde_json::from_str(&common::to_string(&bytes));
16468                        let response = common::to_response(parts, bytes.into());
16469
16470                        if let common::Retry::After(d) =
16471                            dlg.http_failure(&response, error.as_ref().ok())
16472                        {
16473                            sleep(d).await;
16474                            continue;
16475                        }
16476
16477                        dlg.finished(false);
16478
16479                        return Err(match error {
16480                            Ok(value) => common::Error::BadRequest(value),
16481                            _ => common::Error::Failure(response),
16482                        });
16483                    }
16484                    let response = {
16485                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16486                        let encoded = common::to_string(&bytes);
16487                        match serde_json::from_str(&encoded) {
16488                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16489                            Err(error) => {
16490                                dlg.response_json_decode_error(&encoded, &error);
16491                                return Err(common::Error::JsonDecodeError(
16492                                    encoded.to_string(),
16493                                    error,
16494                                ));
16495                            }
16496                        }
16497                    };
16498
16499                    dlg.finished(true);
16500                    return Ok(response);
16501                }
16502            }
16503        }
16504    }
16505
16506    /// User profile ID associated with this request.
16507    ///
16508    /// Sets the *profile id* path property to the given value.
16509    ///
16510    /// Even though the property as already been set when instantiating this call,
16511    /// we provide this method for API completeness.
16512    pub fn profile_id(mut self, new_value: i64) -> AccountPermissionGetCall<'a, C> {
16513        self._profile_id = new_value;
16514        self
16515    }
16516    /// Account permission ID.
16517    ///
16518    /// Sets the *id* path property to the given value.
16519    ///
16520    /// Even though the property as already been set when instantiating this call,
16521    /// we provide this method for API completeness.
16522    pub fn id(mut self, new_value: i64) -> AccountPermissionGetCall<'a, C> {
16523        self._id = new_value;
16524        self
16525    }
16526    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16527    /// while executing the actual API request.
16528    ///
16529    /// ````text
16530    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16531    /// ````
16532    ///
16533    /// Sets the *delegate* property to the given value.
16534    pub fn delegate(
16535        mut self,
16536        new_value: &'a mut dyn common::Delegate,
16537    ) -> AccountPermissionGetCall<'a, C> {
16538        self._delegate = Some(new_value);
16539        self
16540    }
16541
16542    /// Set any additional parameter of the query string used in the request.
16543    /// It should be used to set parameters which are not yet available through their own
16544    /// setters.
16545    ///
16546    /// Please note that this method must not be used to set any of the known parameters
16547    /// which have their own setter method. If done anyway, the request will fail.
16548    ///
16549    /// # Additional Parameters
16550    ///
16551    /// * *alt* (query-string) - Data format for the response.
16552    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16553    /// * *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.
16554    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16555    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16556    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16557    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16558    pub fn param<T>(mut self, name: T, value: T) -> AccountPermissionGetCall<'a, C>
16559    where
16560        T: AsRef<str>,
16561    {
16562        self._additional_params
16563            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16564        self
16565    }
16566
16567    /// Identifies the authorization scope for the method you are building.
16568    ///
16569    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16570    /// [`Scope::Dfatrafficking`].
16571    ///
16572    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16573    /// tokens for more than one scope.
16574    ///
16575    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16576    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16577    /// sufficient, a read-write scope will do as well.
16578    pub fn add_scope<St>(mut self, scope: St) -> AccountPermissionGetCall<'a, C>
16579    where
16580        St: AsRef<str>,
16581    {
16582        self._scopes.insert(String::from(scope.as_ref()));
16583        self
16584    }
16585    /// Identifies the authorization scope(s) for the method you are building.
16586    ///
16587    /// See [`Self::add_scope()`] for details.
16588    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPermissionGetCall<'a, C>
16589    where
16590        I: IntoIterator<Item = St>,
16591        St: AsRef<str>,
16592    {
16593        self._scopes
16594            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16595        self
16596    }
16597
16598    /// Removes all scopes, and no default scope will be used either.
16599    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16600    /// for details).
16601    pub fn clear_scopes(mut self) -> AccountPermissionGetCall<'a, C> {
16602        self._scopes.clear();
16603        self
16604    }
16605}
16606
16607/// Retrieves the list of account permissions.
16608///
16609/// A builder for the *list* method supported by a *accountPermission* resource.
16610/// It is not used directly, but through a [`AccountPermissionMethods`] instance.
16611///
16612/// # Example
16613///
16614/// Instantiate a resource method builder
16615///
16616/// ```test_harness,no_run
16617/// # extern crate hyper;
16618/// # extern crate hyper_rustls;
16619/// # extern crate google_dfareporting3d2 as dfareporting3d2;
16620/// # async fn dox() {
16621/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16622///
16623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16625/// #     secret,
16626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16627/// # ).build().await.unwrap();
16628///
16629/// # let client = hyper_util::client::legacy::Client::builder(
16630/// #     hyper_util::rt::TokioExecutor::new()
16631/// # )
16632/// # .build(
16633/// #     hyper_rustls::HttpsConnectorBuilder::new()
16634/// #         .with_native_roots()
16635/// #         .unwrap()
16636/// #         .https_or_http()
16637/// #         .enable_http1()
16638/// #         .build()
16639/// # );
16640/// # let mut hub = Dfareporting::new(client, auth);
16641/// // You can configure optional parameters by calling the respective setters at will, and
16642/// // execute the final call using `doit()`.
16643/// // Values shown here are possibly random and not representative !
16644/// let result = hub.account_permissions().list(-37)
16645///              .doit().await;
16646/// # }
16647/// ```
16648pub struct AccountPermissionListCall<'a, C>
16649where
16650    C: 'a,
16651{
16652    hub: &'a Dfareporting<C>,
16653    _profile_id: i64,
16654    _delegate: Option<&'a mut dyn common::Delegate>,
16655    _additional_params: HashMap<String, String>,
16656    _scopes: BTreeSet<String>,
16657}
16658
16659impl<'a, C> common::CallBuilder for AccountPermissionListCall<'a, C> {}
16660
16661impl<'a, C> AccountPermissionListCall<'a, C>
16662where
16663    C: common::Connector,
16664{
16665    /// Perform the operation you have build so far.
16666    pub async fn doit(
16667        mut self,
16668    ) -> common::Result<(common::Response, AccountPermissionsListResponse)> {
16669        use std::borrow::Cow;
16670        use std::io::{Read, Seek};
16671
16672        use common::{url::Params, ToParts};
16673        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16674
16675        let mut dd = common::DefaultDelegate;
16676        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16677        dlg.begin(common::MethodInfo {
16678            id: "dfareporting.accountPermissions.list",
16679            http_method: hyper::Method::GET,
16680        });
16681
16682        for &field in ["alt", "profileId"].iter() {
16683            if self._additional_params.contains_key(field) {
16684                dlg.finished(false);
16685                return Err(common::Error::FieldClash(field));
16686            }
16687        }
16688
16689        let mut params = Params::with_capacity(3 + self._additional_params.len());
16690        params.push("profileId", self._profile_id.to_string());
16691
16692        params.extend(self._additional_params.iter());
16693
16694        params.push("alt", "json");
16695        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissions";
16696        if self._scopes.is_empty() {
16697            self._scopes
16698                .insert(Scope::Dfatrafficking.as_ref().to_string());
16699        }
16700
16701        #[allow(clippy::single_element_loop)]
16702        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
16703            url = params.uri_replacement(url, param_name, find_this, false);
16704        }
16705        {
16706            let to_remove = ["profileId"];
16707            params.remove_params(&to_remove);
16708        }
16709
16710        let url = params.parse_with_url(&url);
16711
16712        loop {
16713            let token = match self
16714                .hub
16715                .auth
16716                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16717                .await
16718            {
16719                Ok(token) => token,
16720                Err(e) => match dlg.token(e) {
16721                    Ok(token) => token,
16722                    Err(e) => {
16723                        dlg.finished(false);
16724                        return Err(common::Error::MissingToken(e));
16725                    }
16726                },
16727            };
16728            let mut req_result = {
16729                let client = &self.hub.client;
16730                dlg.pre_request();
16731                let mut req_builder = hyper::Request::builder()
16732                    .method(hyper::Method::GET)
16733                    .uri(url.as_str())
16734                    .header(USER_AGENT, self.hub._user_agent.clone());
16735
16736                if let Some(token) = token.as_ref() {
16737                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16738                }
16739
16740                let request = req_builder
16741                    .header(CONTENT_LENGTH, 0_u64)
16742                    .body(common::to_body::<String>(None));
16743
16744                client.request(request.unwrap()).await
16745            };
16746
16747            match req_result {
16748                Err(err) => {
16749                    if let common::Retry::After(d) = dlg.http_error(&err) {
16750                        sleep(d).await;
16751                        continue;
16752                    }
16753                    dlg.finished(false);
16754                    return Err(common::Error::HttpError(err));
16755                }
16756                Ok(res) => {
16757                    let (mut parts, body) = res.into_parts();
16758                    let mut body = common::Body::new(body);
16759                    if !parts.status.is_success() {
16760                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16761                        let error = serde_json::from_str(&common::to_string(&bytes));
16762                        let response = common::to_response(parts, bytes.into());
16763
16764                        if let common::Retry::After(d) =
16765                            dlg.http_failure(&response, error.as_ref().ok())
16766                        {
16767                            sleep(d).await;
16768                            continue;
16769                        }
16770
16771                        dlg.finished(false);
16772
16773                        return Err(match error {
16774                            Ok(value) => common::Error::BadRequest(value),
16775                            _ => common::Error::Failure(response),
16776                        });
16777                    }
16778                    let response = {
16779                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16780                        let encoded = common::to_string(&bytes);
16781                        match serde_json::from_str(&encoded) {
16782                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16783                            Err(error) => {
16784                                dlg.response_json_decode_error(&encoded, &error);
16785                                return Err(common::Error::JsonDecodeError(
16786                                    encoded.to_string(),
16787                                    error,
16788                                ));
16789                            }
16790                        }
16791                    };
16792
16793                    dlg.finished(true);
16794                    return Ok(response);
16795                }
16796            }
16797        }
16798    }
16799
16800    /// User profile ID associated with this request.
16801    ///
16802    /// Sets the *profile id* path property to the given value.
16803    ///
16804    /// Even though the property as already been set when instantiating this call,
16805    /// we provide this method for API completeness.
16806    pub fn profile_id(mut self, new_value: i64) -> AccountPermissionListCall<'a, C> {
16807        self._profile_id = new_value;
16808        self
16809    }
16810    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16811    /// while executing the actual API request.
16812    ///
16813    /// ````text
16814    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16815    /// ````
16816    ///
16817    /// Sets the *delegate* property to the given value.
16818    pub fn delegate(
16819        mut self,
16820        new_value: &'a mut dyn common::Delegate,
16821    ) -> AccountPermissionListCall<'a, C> {
16822        self._delegate = Some(new_value);
16823        self
16824    }
16825
16826    /// Set any additional parameter of the query string used in the request.
16827    /// It should be used to set parameters which are not yet available through their own
16828    /// setters.
16829    ///
16830    /// Please note that this method must not be used to set any of the known parameters
16831    /// which have their own setter method. If done anyway, the request will fail.
16832    ///
16833    /// # Additional Parameters
16834    ///
16835    /// * *alt* (query-string) - Data format for the response.
16836    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16837    /// * *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.
16838    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16839    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16840    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16841    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16842    pub fn param<T>(mut self, name: T, value: T) -> AccountPermissionListCall<'a, C>
16843    where
16844        T: AsRef<str>,
16845    {
16846        self._additional_params
16847            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16848        self
16849    }
16850
16851    /// Identifies the authorization scope for the method you are building.
16852    ///
16853    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16854    /// [`Scope::Dfatrafficking`].
16855    ///
16856    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16857    /// tokens for more than one scope.
16858    ///
16859    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16860    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16861    /// sufficient, a read-write scope will do as well.
16862    pub fn add_scope<St>(mut self, scope: St) -> AccountPermissionListCall<'a, C>
16863    where
16864        St: AsRef<str>,
16865    {
16866        self._scopes.insert(String::from(scope.as_ref()));
16867        self
16868    }
16869    /// Identifies the authorization scope(s) for the method you are building.
16870    ///
16871    /// See [`Self::add_scope()`] for details.
16872    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPermissionListCall<'a, C>
16873    where
16874        I: IntoIterator<Item = St>,
16875        St: AsRef<str>,
16876    {
16877        self._scopes
16878            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16879        self
16880    }
16881
16882    /// Removes all scopes, and no default scope will be used either.
16883    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16884    /// for details).
16885    pub fn clear_scopes(mut self) -> AccountPermissionListCall<'a, C> {
16886        self._scopes.clear();
16887        self
16888    }
16889}
16890
16891/// Gets one account user profile by ID.
16892///
16893/// A builder for the *get* method supported by a *accountUserProfile* resource.
16894/// It is not used directly, but through a [`AccountUserProfileMethods`] instance.
16895///
16896/// # Example
16897///
16898/// Instantiate a resource method builder
16899///
16900/// ```test_harness,no_run
16901/// # extern crate hyper;
16902/// # extern crate hyper_rustls;
16903/// # extern crate google_dfareporting3d2 as dfareporting3d2;
16904/// # async fn dox() {
16905/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16906///
16907/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16908/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16909/// #     secret,
16910/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16911/// # ).build().await.unwrap();
16912///
16913/// # let client = hyper_util::client::legacy::Client::builder(
16914/// #     hyper_util::rt::TokioExecutor::new()
16915/// # )
16916/// # .build(
16917/// #     hyper_rustls::HttpsConnectorBuilder::new()
16918/// #         .with_native_roots()
16919/// #         .unwrap()
16920/// #         .https_or_http()
16921/// #         .enable_http1()
16922/// #         .build()
16923/// # );
16924/// # let mut hub = Dfareporting::new(client, auth);
16925/// // You can configure optional parameters by calling the respective setters at will, and
16926/// // execute the final call using `doit()`.
16927/// // Values shown here are possibly random and not representative !
16928/// let result = hub.account_user_profiles().get(-12, -16)
16929///              .doit().await;
16930/// # }
16931/// ```
16932pub struct AccountUserProfileGetCall<'a, C>
16933where
16934    C: 'a,
16935{
16936    hub: &'a Dfareporting<C>,
16937    _profile_id: i64,
16938    _id: i64,
16939    _delegate: Option<&'a mut dyn common::Delegate>,
16940    _additional_params: HashMap<String, String>,
16941    _scopes: BTreeSet<String>,
16942}
16943
16944impl<'a, C> common::CallBuilder for AccountUserProfileGetCall<'a, C> {}
16945
16946impl<'a, C> AccountUserProfileGetCall<'a, C>
16947where
16948    C: common::Connector,
16949{
16950    /// Perform the operation you have build so far.
16951    pub async fn doit(mut self) -> common::Result<(common::Response, AccountUserProfile)> {
16952        use std::borrow::Cow;
16953        use std::io::{Read, Seek};
16954
16955        use common::{url::Params, ToParts};
16956        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16957
16958        let mut dd = common::DefaultDelegate;
16959        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16960        dlg.begin(common::MethodInfo {
16961            id: "dfareporting.accountUserProfiles.get",
16962            http_method: hyper::Method::GET,
16963        });
16964
16965        for &field in ["alt", "profileId", "id"].iter() {
16966            if self._additional_params.contains_key(field) {
16967                dlg.finished(false);
16968                return Err(common::Error::FieldClash(field));
16969            }
16970        }
16971
16972        let mut params = Params::with_capacity(4 + self._additional_params.len());
16973        params.push("profileId", self._profile_id.to_string());
16974        params.push("id", self._id.to_string());
16975
16976        params.extend(self._additional_params.iter());
16977
16978        params.push("alt", "json");
16979        let mut url =
16980            self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles/{id}";
16981        if self._scopes.is_empty() {
16982            self._scopes
16983                .insert(Scope::Dfatrafficking.as_ref().to_string());
16984        }
16985
16986        #[allow(clippy::single_element_loop)]
16987        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
16988            url = params.uri_replacement(url, param_name, find_this, false);
16989        }
16990        {
16991            let to_remove = ["id", "profileId"];
16992            params.remove_params(&to_remove);
16993        }
16994
16995        let url = params.parse_with_url(&url);
16996
16997        loop {
16998            let token = match self
16999                .hub
17000                .auth
17001                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17002                .await
17003            {
17004                Ok(token) => token,
17005                Err(e) => match dlg.token(e) {
17006                    Ok(token) => token,
17007                    Err(e) => {
17008                        dlg.finished(false);
17009                        return Err(common::Error::MissingToken(e));
17010                    }
17011                },
17012            };
17013            let mut req_result = {
17014                let client = &self.hub.client;
17015                dlg.pre_request();
17016                let mut req_builder = hyper::Request::builder()
17017                    .method(hyper::Method::GET)
17018                    .uri(url.as_str())
17019                    .header(USER_AGENT, self.hub._user_agent.clone());
17020
17021                if let Some(token) = token.as_ref() {
17022                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17023                }
17024
17025                let request = req_builder
17026                    .header(CONTENT_LENGTH, 0_u64)
17027                    .body(common::to_body::<String>(None));
17028
17029                client.request(request.unwrap()).await
17030            };
17031
17032            match req_result {
17033                Err(err) => {
17034                    if let common::Retry::After(d) = dlg.http_error(&err) {
17035                        sleep(d).await;
17036                        continue;
17037                    }
17038                    dlg.finished(false);
17039                    return Err(common::Error::HttpError(err));
17040                }
17041                Ok(res) => {
17042                    let (mut parts, body) = res.into_parts();
17043                    let mut body = common::Body::new(body);
17044                    if !parts.status.is_success() {
17045                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17046                        let error = serde_json::from_str(&common::to_string(&bytes));
17047                        let response = common::to_response(parts, bytes.into());
17048
17049                        if let common::Retry::After(d) =
17050                            dlg.http_failure(&response, error.as_ref().ok())
17051                        {
17052                            sleep(d).await;
17053                            continue;
17054                        }
17055
17056                        dlg.finished(false);
17057
17058                        return Err(match error {
17059                            Ok(value) => common::Error::BadRequest(value),
17060                            _ => common::Error::Failure(response),
17061                        });
17062                    }
17063                    let response = {
17064                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17065                        let encoded = common::to_string(&bytes);
17066                        match serde_json::from_str(&encoded) {
17067                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17068                            Err(error) => {
17069                                dlg.response_json_decode_error(&encoded, &error);
17070                                return Err(common::Error::JsonDecodeError(
17071                                    encoded.to_string(),
17072                                    error,
17073                                ));
17074                            }
17075                        }
17076                    };
17077
17078                    dlg.finished(true);
17079                    return Ok(response);
17080                }
17081            }
17082        }
17083    }
17084
17085    /// User profile ID associated with this request.
17086    ///
17087    /// Sets the *profile id* path property to the given value.
17088    ///
17089    /// Even though the property as already been set when instantiating this call,
17090    /// we provide this method for API completeness.
17091    pub fn profile_id(mut self, new_value: i64) -> AccountUserProfileGetCall<'a, C> {
17092        self._profile_id = new_value;
17093        self
17094    }
17095    /// User profile ID.
17096    ///
17097    /// Sets the *id* path property to the given value.
17098    ///
17099    /// Even though the property as already been set when instantiating this call,
17100    /// we provide this method for API completeness.
17101    pub fn id(mut self, new_value: i64) -> AccountUserProfileGetCall<'a, C> {
17102        self._id = new_value;
17103        self
17104    }
17105    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17106    /// while executing the actual API request.
17107    ///
17108    /// ````text
17109    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17110    /// ````
17111    ///
17112    /// Sets the *delegate* property to the given value.
17113    pub fn delegate(
17114        mut self,
17115        new_value: &'a mut dyn common::Delegate,
17116    ) -> AccountUserProfileGetCall<'a, C> {
17117        self._delegate = Some(new_value);
17118        self
17119    }
17120
17121    /// Set any additional parameter of the query string used in the request.
17122    /// It should be used to set parameters which are not yet available through their own
17123    /// setters.
17124    ///
17125    /// Please note that this method must not be used to set any of the known parameters
17126    /// which have their own setter method. If done anyway, the request will fail.
17127    ///
17128    /// # Additional Parameters
17129    ///
17130    /// * *alt* (query-string) - Data format for the response.
17131    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17132    /// * *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.
17133    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17134    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17135    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17136    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17137    pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfileGetCall<'a, C>
17138    where
17139        T: AsRef<str>,
17140    {
17141        self._additional_params
17142            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17143        self
17144    }
17145
17146    /// Identifies the authorization scope for the method you are building.
17147    ///
17148    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17149    /// [`Scope::Dfatrafficking`].
17150    ///
17151    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17152    /// tokens for more than one scope.
17153    ///
17154    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17155    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17156    /// sufficient, a read-write scope will do as well.
17157    pub fn add_scope<St>(mut self, scope: St) -> AccountUserProfileGetCall<'a, C>
17158    where
17159        St: AsRef<str>,
17160    {
17161        self._scopes.insert(String::from(scope.as_ref()));
17162        self
17163    }
17164    /// Identifies the authorization scope(s) for the method you are building.
17165    ///
17166    /// See [`Self::add_scope()`] for details.
17167    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUserProfileGetCall<'a, C>
17168    where
17169        I: IntoIterator<Item = St>,
17170        St: AsRef<str>,
17171    {
17172        self._scopes
17173            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17174        self
17175    }
17176
17177    /// Removes all scopes, and no default scope will be used either.
17178    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17179    /// for details).
17180    pub fn clear_scopes(mut self) -> AccountUserProfileGetCall<'a, C> {
17181        self._scopes.clear();
17182        self
17183    }
17184}
17185
17186/// Inserts a new account user profile.
17187///
17188/// A builder for the *insert* method supported by a *accountUserProfile* resource.
17189/// It is not used directly, but through a [`AccountUserProfileMethods`] instance.
17190///
17191/// # Example
17192///
17193/// Instantiate a resource method builder
17194///
17195/// ```test_harness,no_run
17196/// # extern crate hyper;
17197/// # extern crate hyper_rustls;
17198/// # extern crate google_dfareporting3d2 as dfareporting3d2;
17199/// use dfareporting3d2::api::AccountUserProfile;
17200/// # async fn dox() {
17201/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17202///
17203/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17204/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17205/// #     secret,
17206/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17207/// # ).build().await.unwrap();
17208///
17209/// # let client = hyper_util::client::legacy::Client::builder(
17210/// #     hyper_util::rt::TokioExecutor::new()
17211/// # )
17212/// # .build(
17213/// #     hyper_rustls::HttpsConnectorBuilder::new()
17214/// #         .with_native_roots()
17215/// #         .unwrap()
17216/// #         .https_or_http()
17217/// #         .enable_http1()
17218/// #         .build()
17219/// # );
17220/// # let mut hub = Dfareporting::new(client, auth);
17221/// // As the method needs a request, you would usually fill it with the desired information
17222/// // into the respective structure. Some of the parts shown here might not be applicable !
17223/// // Values shown here are possibly random and not representative !
17224/// let mut req = AccountUserProfile::default();
17225///
17226/// // You can configure optional parameters by calling the respective setters at will, and
17227/// // execute the final call using `doit()`.
17228/// // Values shown here are possibly random and not representative !
17229/// let result = hub.account_user_profiles().insert(req, -57)
17230///              .doit().await;
17231/// # }
17232/// ```
17233pub struct AccountUserProfileInsertCall<'a, C>
17234where
17235    C: 'a,
17236{
17237    hub: &'a Dfareporting<C>,
17238    _request: AccountUserProfile,
17239    _profile_id: i64,
17240    _delegate: Option<&'a mut dyn common::Delegate>,
17241    _additional_params: HashMap<String, String>,
17242    _scopes: BTreeSet<String>,
17243}
17244
17245impl<'a, C> common::CallBuilder for AccountUserProfileInsertCall<'a, C> {}
17246
17247impl<'a, C> AccountUserProfileInsertCall<'a, C>
17248where
17249    C: common::Connector,
17250{
17251    /// Perform the operation you have build so far.
17252    pub async fn doit(mut self) -> common::Result<(common::Response, AccountUserProfile)> {
17253        use std::borrow::Cow;
17254        use std::io::{Read, Seek};
17255
17256        use common::{url::Params, ToParts};
17257        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17258
17259        let mut dd = common::DefaultDelegate;
17260        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17261        dlg.begin(common::MethodInfo {
17262            id: "dfareporting.accountUserProfiles.insert",
17263            http_method: hyper::Method::POST,
17264        });
17265
17266        for &field in ["alt", "profileId"].iter() {
17267            if self._additional_params.contains_key(field) {
17268                dlg.finished(false);
17269                return Err(common::Error::FieldClash(field));
17270            }
17271        }
17272
17273        let mut params = Params::with_capacity(4 + self._additional_params.len());
17274        params.push("profileId", self._profile_id.to_string());
17275
17276        params.extend(self._additional_params.iter());
17277
17278        params.push("alt", "json");
17279        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles";
17280        if self._scopes.is_empty() {
17281            self._scopes
17282                .insert(Scope::Dfatrafficking.as_ref().to_string());
17283        }
17284
17285        #[allow(clippy::single_element_loop)]
17286        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
17287            url = params.uri_replacement(url, param_name, find_this, false);
17288        }
17289        {
17290            let to_remove = ["profileId"];
17291            params.remove_params(&to_remove);
17292        }
17293
17294        let url = params.parse_with_url(&url);
17295
17296        let mut json_mime_type = mime::APPLICATION_JSON;
17297        let mut request_value_reader = {
17298            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17299            common::remove_json_null_values(&mut value);
17300            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17301            serde_json::to_writer(&mut dst, &value).unwrap();
17302            dst
17303        };
17304        let request_size = request_value_reader
17305            .seek(std::io::SeekFrom::End(0))
17306            .unwrap();
17307        request_value_reader
17308            .seek(std::io::SeekFrom::Start(0))
17309            .unwrap();
17310
17311        loop {
17312            let token = match self
17313                .hub
17314                .auth
17315                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17316                .await
17317            {
17318                Ok(token) => token,
17319                Err(e) => match dlg.token(e) {
17320                    Ok(token) => token,
17321                    Err(e) => {
17322                        dlg.finished(false);
17323                        return Err(common::Error::MissingToken(e));
17324                    }
17325                },
17326            };
17327            request_value_reader
17328                .seek(std::io::SeekFrom::Start(0))
17329                .unwrap();
17330            let mut req_result = {
17331                let client = &self.hub.client;
17332                dlg.pre_request();
17333                let mut req_builder = hyper::Request::builder()
17334                    .method(hyper::Method::POST)
17335                    .uri(url.as_str())
17336                    .header(USER_AGENT, self.hub._user_agent.clone());
17337
17338                if let Some(token) = token.as_ref() {
17339                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17340                }
17341
17342                let request = req_builder
17343                    .header(CONTENT_TYPE, json_mime_type.to_string())
17344                    .header(CONTENT_LENGTH, request_size as u64)
17345                    .body(common::to_body(
17346                        request_value_reader.get_ref().clone().into(),
17347                    ));
17348
17349                client.request(request.unwrap()).await
17350            };
17351
17352            match req_result {
17353                Err(err) => {
17354                    if let common::Retry::After(d) = dlg.http_error(&err) {
17355                        sleep(d).await;
17356                        continue;
17357                    }
17358                    dlg.finished(false);
17359                    return Err(common::Error::HttpError(err));
17360                }
17361                Ok(res) => {
17362                    let (mut parts, body) = res.into_parts();
17363                    let mut body = common::Body::new(body);
17364                    if !parts.status.is_success() {
17365                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17366                        let error = serde_json::from_str(&common::to_string(&bytes));
17367                        let response = common::to_response(parts, bytes.into());
17368
17369                        if let common::Retry::After(d) =
17370                            dlg.http_failure(&response, error.as_ref().ok())
17371                        {
17372                            sleep(d).await;
17373                            continue;
17374                        }
17375
17376                        dlg.finished(false);
17377
17378                        return Err(match error {
17379                            Ok(value) => common::Error::BadRequest(value),
17380                            _ => common::Error::Failure(response),
17381                        });
17382                    }
17383                    let response = {
17384                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17385                        let encoded = common::to_string(&bytes);
17386                        match serde_json::from_str(&encoded) {
17387                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17388                            Err(error) => {
17389                                dlg.response_json_decode_error(&encoded, &error);
17390                                return Err(common::Error::JsonDecodeError(
17391                                    encoded.to_string(),
17392                                    error,
17393                                ));
17394                            }
17395                        }
17396                    };
17397
17398                    dlg.finished(true);
17399                    return Ok(response);
17400                }
17401            }
17402        }
17403    }
17404
17405    ///
17406    /// Sets the *request* property to the given value.
17407    ///
17408    /// Even though the property as already been set when instantiating this call,
17409    /// we provide this method for API completeness.
17410    pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileInsertCall<'a, C> {
17411        self._request = new_value;
17412        self
17413    }
17414    /// User profile ID associated with this request.
17415    ///
17416    /// Sets the *profile id* path property to the given value.
17417    ///
17418    /// Even though the property as already been set when instantiating this call,
17419    /// we provide this method for API completeness.
17420    pub fn profile_id(mut self, new_value: i64) -> AccountUserProfileInsertCall<'a, C> {
17421        self._profile_id = new_value;
17422        self
17423    }
17424    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17425    /// while executing the actual API request.
17426    ///
17427    /// ````text
17428    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17429    /// ````
17430    ///
17431    /// Sets the *delegate* property to the given value.
17432    pub fn delegate(
17433        mut self,
17434        new_value: &'a mut dyn common::Delegate,
17435    ) -> AccountUserProfileInsertCall<'a, C> {
17436        self._delegate = Some(new_value);
17437        self
17438    }
17439
17440    /// Set any additional parameter of the query string used in the request.
17441    /// It should be used to set parameters which are not yet available through their own
17442    /// setters.
17443    ///
17444    /// Please note that this method must not be used to set any of the known parameters
17445    /// which have their own setter method. If done anyway, the request will fail.
17446    ///
17447    /// # Additional Parameters
17448    ///
17449    /// * *alt* (query-string) - Data format for the response.
17450    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17451    /// * *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.
17452    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17453    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17454    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17455    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17456    pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfileInsertCall<'a, C>
17457    where
17458        T: AsRef<str>,
17459    {
17460        self._additional_params
17461            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17462        self
17463    }
17464
17465    /// Identifies the authorization scope for the method you are building.
17466    ///
17467    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17468    /// [`Scope::Dfatrafficking`].
17469    ///
17470    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17471    /// tokens for more than one scope.
17472    ///
17473    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17474    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17475    /// sufficient, a read-write scope will do as well.
17476    pub fn add_scope<St>(mut self, scope: St) -> AccountUserProfileInsertCall<'a, C>
17477    where
17478        St: AsRef<str>,
17479    {
17480        self._scopes.insert(String::from(scope.as_ref()));
17481        self
17482    }
17483    /// Identifies the authorization scope(s) for the method you are building.
17484    ///
17485    /// See [`Self::add_scope()`] for details.
17486    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUserProfileInsertCall<'a, C>
17487    where
17488        I: IntoIterator<Item = St>,
17489        St: AsRef<str>,
17490    {
17491        self._scopes
17492            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17493        self
17494    }
17495
17496    /// Removes all scopes, and no default scope will be used either.
17497    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17498    /// for details).
17499    pub fn clear_scopes(mut self) -> AccountUserProfileInsertCall<'a, C> {
17500        self._scopes.clear();
17501        self
17502    }
17503}
17504
17505/// Retrieves a list of account user profiles, possibly filtered. This method supports paging.
17506///
17507/// A builder for the *list* method supported by a *accountUserProfile* resource.
17508/// It is not used directly, but through a [`AccountUserProfileMethods`] instance.
17509///
17510/// # Example
17511///
17512/// Instantiate a resource method builder
17513///
17514/// ```test_harness,no_run
17515/// # extern crate hyper;
17516/// # extern crate hyper_rustls;
17517/// # extern crate google_dfareporting3d2 as dfareporting3d2;
17518/// # async fn dox() {
17519/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17520///
17521/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17522/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17523/// #     secret,
17524/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17525/// # ).build().await.unwrap();
17526///
17527/// # let client = hyper_util::client::legacy::Client::builder(
17528/// #     hyper_util::rt::TokioExecutor::new()
17529/// # )
17530/// # .build(
17531/// #     hyper_rustls::HttpsConnectorBuilder::new()
17532/// #         .with_native_roots()
17533/// #         .unwrap()
17534/// #         .https_or_http()
17535/// #         .enable_http1()
17536/// #         .build()
17537/// # );
17538/// # let mut hub = Dfareporting::new(client, auth);
17539/// // You can configure optional parameters by calling the respective setters at will, and
17540/// // execute the final call using `doit()`.
17541/// // Values shown here are possibly random and not representative !
17542/// let result = hub.account_user_profiles().list(-50)
17543///              .user_role_id(-50)
17544///              .subaccount_id(-7)
17545///              .sort_order("gubergren")
17546///              .sort_field("ea")
17547///              .search_string("dolor")
17548///              .page_token("Lorem")
17549///              .max_results(-25)
17550///              .add_ids(-86)
17551///              .active(true)
17552///              .doit().await;
17553/// # }
17554/// ```
17555pub struct AccountUserProfileListCall<'a, C>
17556where
17557    C: 'a,
17558{
17559    hub: &'a Dfareporting<C>,
17560    _profile_id: i64,
17561    _user_role_id: Option<i64>,
17562    _subaccount_id: Option<i64>,
17563    _sort_order: Option<String>,
17564    _sort_field: Option<String>,
17565    _search_string: Option<String>,
17566    _page_token: Option<String>,
17567    _max_results: Option<i32>,
17568    _ids: Vec<i64>,
17569    _active: Option<bool>,
17570    _delegate: Option<&'a mut dyn common::Delegate>,
17571    _additional_params: HashMap<String, String>,
17572    _scopes: BTreeSet<String>,
17573}
17574
17575impl<'a, C> common::CallBuilder for AccountUserProfileListCall<'a, C> {}
17576
17577impl<'a, C> AccountUserProfileListCall<'a, C>
17578where
17579    C: common::Connector,
17580{
17581    /// Perform the operation you have build so far.
17582    pub async fn doit(
17583        mut self,
17584    ) -> common::Result<(common::Response, AccountUserProfilesListResponse)> {
17585        use std::borrow::Cow;
17586        use std::io::{Read, Seek};
17587
17588        use common::{url::Params, ToParts};
17589        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17590
17591        let mut dd = common::DefaultDelegate;
17592        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17593        dlg.begin(common::MethodInfo {
17594            id: "dfareporting.accountUserProfiles.list",
17595            http_method: hyper::Method::GET,
17596        });
17597
17598        for &field in [
17599            "alt",
17600            "profileId",
17601            "userRoleId",
17602            "subaccountId",
17603            "sortOrder",
17604            "sortField",
17605            "searchString",
17606            "pageToken",
17607            "maxResults",
17608            "ids",
17609            "active",
17610        ]
17611        .iter()
17612        {
17613            if self._additional_params.contains_key(field) {
17614                dlg.finished(false);
17615                return Err(common::Error::FieldClash(field));
17616            }
17617        }
17618
17619        let mut params = Params::with_capacity(12 + self._additional_params.len());
17620        params.push("profileId", self._profile_id.to_string());
17621        if let Some(value) = self._user_role_id.as_ref() {
17622            params.push("userRoleId", value.to_string());
17623        }
17624        if let Some(value) = self._subaccount_id.as_ref() {
17625            params.push("subaccountId", value.to_string());
17626        }
17627        if let Some(value) = self._sort_order.as_ref() {
17628            params.push("sortOrder", value);
17629        }
17630        if let Some(value) = self._sort_field.as_ref() {
17631            params.push("sortField", value);
17632        }
17633        if let Some(value) = self._search_string.as_ref() {
17634            params.push("searchString", value);
17635        }
17636        if let Some(value) = self._page_token.as_ref() {
17637            params.push("pageToken", value);
17638        }
17639        if let Some(value) = self._max_results.as_ref() {
17640            params.push("maxResults", value.to_string());
17641        }
17642        if !self._ids.is_empty() {
17643            for f in self._ids.iter() {
17644                params.push("ids", f.to_string());
17645            }
17646        }
17647        if let Some(value) = self._active.as_ref() {
17648            params.push("active", value.to_string());
17649        }
17650
17651        params.extend(self._additional_params.iter());
17652
17653        params.push("alt", "json");
17654        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles";
17655        if self._scopes.is_empty() {
17656            self._scopes
17657                .insert(Scope::Dfatrafficking.as_ref().to_string());
17658        }
17659
17660        #[allow(clippy::single_element_loop)]
17661        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
17662            url = params.uri_replacement(url, param_name, find_this, false);
17663        }
17664        {
17665            let to_remove = ["profileId"];
17666            params.remove_params(&to_remove);
17667        }
17668
17669        let url = params.parse_with_url(&url);
17670
17671        loop {
17672            let token = match self
17673                .hub
17674                .auth
17675                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17676                .await
17677            {
17678                Ok(token) => token,
17679                Err(e) => match dlg.token(e) {
17680                    Ok(token) => token,
17681                    Err(e) => {
17682                        dlg.finished(false);
17683                        return Err(common::Error::MissingToken(e));
17684                    }
17685                },
17686            };
17687            let mut req_result = {
17688                let client = &self.hub.client;
17689                dlg.pre_request();
17690                let mut req_builder = hyper::Request::builder()
17691                    .method(hyper::Method::GET)
17692                    .uri(url.as_str())
17693                    .header(USER_AGENT, self.hub._user_agent.clone());
17694
17695                if let Some(token) = token.as_ref() {
17696                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17697                }
17698
17699                let request = req_builder
17700                    .header(CONTENT_LENGTH, 0_u64)
17701                    .body(common::to_body::<String>(None));
17702
17703                client.request(request.unwrap()).await
17704            };
17705
17706            match req_result {
17707                Err(err) => {
17708                    if let common::Retry::After(d) = dlg.http_error(&err) {
17709                        sleep(d).await;
17710                        continue;
17711                    }
17712                    dlg.finished(false);
17713                    return Err(common::Error::HttpError(err));
17714                }
17715                Ok(res) => {
17716                    let (mut parts, body) = res.into_parts();
17717                    let mut body = common::Body::new(body);
17718                    if !parts.status.is_success() {
17719                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17720                        let error = serde_json::from_str(&common::to_string(&bytes));
17721                        let response = common::to_response(parts, bytes.into());
17722
17723                        if let common::Retry::After(d) =
17724                            dlg.http_failure(&response, error.as_ref().ok())
17725                        {
17726                            sleep(d).await;
17727                            continue;
17728                        }
17729
17730                        dlg.finished(false);
17731
17732                        return Err(match error {
17733                            Ok(value) => common::Error::BadRequest(value),
17734                            _ => common::Error::Failure(response),
17735                        });
17736                    }
17737                    let response = {
17738                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17739                        let encoded = common::to_string(&bytes);
17740                        match serde_json::from_str(&encoded) {
17741                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17742                            Err(error) => {
17743                                dlg.response_json_decode_error(&encoded, &error);
17744                                return Err(common::Error::JsonDecodeError(
17745                                    encoded.to_string(),
17746                                    error,
17747                                ));
17748                            }
17749                        }
17750                    };
17751
17752                    dlg.finished(true);
17753                    return Ok(response);
17754                }
17755            }
17756        }
17757    }
17758
17759    /// User profile ID associated with this request.
17760    ///
17761    /// Sets the *profile id* path property to the given value.
17762    ///
17763    /// Even though the property as already been set when instantiating this call,
17764    /// we provide this method for API completeness.
17765    pub fn profile_id(mut self, new_value: i64) -> AccountUserProfileListCall<'a, C> {
17766        self._profile_id = new_value;
17767        self
17768    }
17769    /// Select only user profiles with the specified user role ID.
17770    ///
17771    /// Sets the *user role id* query property to the given value.
17772    pub fn user_role_id(mut self, new_value: i64) -> AccountUserProfileListCall<'a, C> {
17773        self._user_role_id = Some(new_value);
17774        self
17775    }
17776    /// Select only user profiles with the specified subaccount ID.
17777    ///
17778    /// Sets the *subaccount id* query property to the given value.
17779    pub fn subaccount_id(mut self, new_value: i64) -> AccountUserProfileListCall<'a, C> {
17780        self._subaccount_id = Some(new_value);
17781        self
17782    }
17783    /// Order of sorted results.
17784    ///
17785    /// Sets the *sort order* query property to the given value.
17786    pub fn sort_order(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C> {
17787        self._sort_order = Some(new_value.to_string());
17788        self
17789    }
17790    /// Field by which to sort the list.
17791    ///
17792    /// Sets the *sort field* query property to the given value.
17793    pub fn sort_field(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C> {
17794        self._sort_field = Some(new_value.to_string());
17795        self
17796    }
17797    /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "user profile*2015" will return objects with names like "user profile June 2015", "user profile April 2015", or simply "user profile 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "user profile" will match objects with name "my user profile", "user profile 2015", or simply "user profile".
17798    ///
17799    /// Sets the *search string* query property to the given value.
17800    pub fn search_string(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C> {
17801        self._search_string = Some(new_value.to_string());
17802        self
17803    }
17804    /// Value of the nextPageToken from the previous result page.
17805    ///
17806    /// Sets the *page token* query property to the given value.
17807    pub fn page_token(mut self, new_value: &str) -> AccountUserProfileListCall<'a, C> {
17808        self._page_token = Some(new_value.to_string());
17809        self
17810    }
17811    /// Maximum number of results to return.
17812    ///
17813    /// Sets the *max results* query property to the given value.
17814    pub fn max_results(mut self, new_value: i32) -> AccountUserProfileListCall<'a, C> {
17815        self._max_results = Some(new_value);
17816        self
17817    }
17818    /// Select only user profiles with these IDs.
17819    ///
17820    /// Append the given value to the *ids* query property.
17821    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
17822    pub fn add_ids(mut self, new_value: i64) -> AccountUserProfileListCall<'a, C> {
17823        self._ids.push(new_value);
17824        self
17825    }
17826    /// Select only active user profiles.
17827    ///
17828    /// Sets the *active* query property to the given value.
17829    pub fn active(mut self, new_value: bool) -> AccountUserProfileListCall<'a, C> {
17830        self._active = Some(new_value);
17831        self
17832    }
17833    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17834    /// while executing the actual API request.
17835    ///
17836    /// ````text
17837    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17838    /// ````
17839    ///
17840    /// Sets the *delegate* property to the given value.
17841    pub fn delegate(
17842        mut self,
17843        new_value: &'a mut dyn common::Delegate,
17844    ) -> AccountUserProfileListCall<'a, C> {
17845        self._delegate = Some(new_value);
17846        self
17847    }
17848
17849    /// Set any additional parameter of the query string used in the request.
17850    /// It should be used to set parameters which are not yet available through their own
17851    /// setters.
17852    ///
17853    /// Please note that this method must not be used to set any of the known parameters
17854    /// which have their own setter method. If done anyway, the request will fail.
17855    ///
17856    /// # Additional Parameters
17857    ///
17858    /// * *alt* (query-string) - Data format for the response.
17859    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17860    /// * *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.
17861    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17862    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17863    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17864    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17865    pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfileListCall<'a, C>
17866    where
17867        T: AsRef<str>,
17868    {
17869        self._additional_params
17870            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17871        self
17872    }
17873
17874    /// Identifies the authorization scope for the method you are building.
17875    ///
17876    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17877    /// [`Scope::Dfatrafficking`].
17878    ///
17879    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17880    /// tokens for more than one scope.
17881    ///
17882    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17883    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17884    /// sufficient, a read-write scope will do as well.
17885    pub fn add_scope<St>(mut self, scope: St) -> AccountUserProfileListCall<'a, C>
17886    where
17887        St: AsRef<str>,
17888    {
17889        self._scopes.insert(String::from(scope.as_ref()));
17890        self
17891    }
17892    /// Identifies the authorization scope(s) for the method you are building.
17893    ///
17894    /// See [`Self::add_scope()`] for details.
17895    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUserProfileListCall<'a, C>
17896    where
17897        I: IntoIterator<Item = St>,
17898        St: AsRef<str>,
17899    {
17900        self._scopes
17901            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17902        self
17903    }
17904
17905    /// Removes all scopes, and no default scope will be used either.
17906    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17907    /// for details).
17908    pub fn clear_scopes(mut self) -> AccountUserProfileListCall<'a, C> {
17909        self._scopes.clear();
17910        self
17911    }
17912}
17913
17914/// Updates an existing account user profile. This method supports patch semantics.
17915///
17916/// A builder for the *patch* method supported by a *accountUserProfile* resource.
17917/// It is not used directly, but through a [`AccountUserProfileMethods`] instance.
17918///
17919/// # Example
17920///
17921/// Instantiate a resource method builder
17922///
17923/// ```test_harness,no_run
17924/// # extern crate hyper;
17925/// # extern crate hyper_rustls;
17926/// # extern crate google_dfareporting3d2 as dfareporting3d2;
17927/// use dfareporting3d2::api::AccountUserProfile;
17928/// # async fn dox() {
17929/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17930///
17931/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17933/// #     secret,
17934/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17935/// # ).build().await.unwrap();
17936///
17937/// # let client = hyper_util::client::legacy::Client::builder(
17938/// #     hyper_util::rt::TokioExecutor::new()
17939/// # )
17940/// # .build(
17941/// #     hyper_rustls::HttpsConnectorBuilder::new()
17942/// #         .with_native_roots()
17943/// #         .unwrap()
17944/// #         .https_or_http()
17945/// #         .enable_http1()
17946/// #         .build()
17947/// # );
17948/// # let mut hub = Dfareporting::new(client, auth);
17949/// // As the method needs a request, you would usually fill it with the desired information
17950/// // into the respective structure. Some of the parts shown here might not be applicable !
17951/// // Values shown here are possibly random and not representative !
17952/// let mut req = AccountUserProfile::default();
17953///
17954/// // You can configure optional parameters by calling the respective setters at will, and
17955/// // execute the final call using `doit()`.
17956/// // Values shown here are possibly random and not representative !
17957/// let result = hub.account_user_profiles().patch(req, -70, -80)
17958///              .doit().await;
17959/// # }
17960/// ```
17961pub struct AccountUserProfilePatchCall<'a, C>
17962where
17963    C: 'a,
17964{
17965    hub: &'a Dfareporting<C>,
17966    _request: AccountUserProfile,
17967    _profile_id: i64,
17968    _id: i64,
17969    _delegate: Option<&'a mut dyn common::Delegate>,
17970    _additional_params: HashMap<String, String>,
17971    _scopes: BTreeSet<String>,
17972}
17973
17974impl<'a, C> common::CallBuilder for AccountUserProfilePatchCall<'a, C> {}
17975
17976impl<'a, C> AccountUserProfilePatchCall<'a, C>
17977where
17978    C: common::Connector,
17979{
17980    /// Perform the operation you have build so far.
17981    pub async fn doit(mut self) -> common::Result<(common::Response, AccountUserProfile)> {
17982        use std::borrow::Cow;
17983        use std::io::{Read, Seek};
17984
17985        use common::{url::Params, ToParts};
17986        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17987
17988        let mut dd = common::DefaultDelegate;
17989        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17990        dlg.begin(common::MethodInfo {
17991            id: "dfareporting.accountUserProfiles.patch",
17992            http_method: hyper::Method::PATCH,
17993        });
17994
17995        for &field in ["alt", "profileId", "id"].iter() {
17996            if self._additional_params.contains_key(field) {
17997                dlg.finished(false);
17998                return Err(common::Error::FieldClash(field));
17999            }
18000        }
18001
18002        let mut params = Params::with_capacity(5 + self._additional_params.len());
18003        params.push("profileId", self._profile_id.to_string());
18004        params.push("id", self._id.to_string());
18005
18006        params.extend(self._additional_params.iter());
18007
18008        params.push("alt", "json");
18009        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles";
18010        if self._scopes.is_empty() {
18011            self._scopes
18012                .insert(Scope::Dfatrafficking.as_ref().to_string());
18013        }
18014
18015        #[allow(clippy::single_element_loop)]
18016        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
18017            url = params.uri_replacement(url, param_name, find_this, false);
18018        }
18019        {
18020            let to_remove = ["profileId"];
18021            params.remove_params(&to_remove);
18022        }
18023
18024        let url = params.parse_with_url(&url);
18025
18026        let mut json_mime_type = mime::APPLICATION_JSON;
18027        let mut request_value_reader = {
18028            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18029            common::remove_json_null_values(&mut value);
18030            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18031            serde_json::to_writer(&mut dst, &value).unwrap();
18032            dst
18033        };
18034        let request_size = request_value_reader
18035            .seek(std::io::SeekFrom::End(0))
18036            .unwrap();
18037        request_value_reader
18038            .seek(std::io::SeekFrom::Start(0))
18039            .unwrap();
18040
18041        loop {
18042            let token = match self
18043                .hub
18044                .auth
18045                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18046                .await
18047            {
18048                Ok(token) => token,
18049                Err(e) => match dlg.token(e) {
18050                    Ok(token) => token,
18051                    Err(e) => {
18052                        dlg.finished(false);
18053                        return Err(common::Error::MissingToken(e));
18054                    }
18055                },
18056            };
18057            request_value_reader
18058                .seek(std::io::SeekFrom::Start(0))
18059                .unwrap();
18060            let mut req_result = {
18061                let client = &self.hub.client;
18062                dlg.pre_request();
18063                let mut req_builder = hyper::Request::builder()
18064                    .method(hyper::Method::PATCH)
18065                    .uri(url.as_str())
18066                    .header(USER_AGENT, self.hub._user_agent.clone());
18067
18068                if let Some(token) = token.as_ref() {
18069                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18070                }
18071
18072                let request = req_builder
18073                    .header(CONTENT_TYPE, json_mime_type.to_string())
18074                    .header(CONTENT_LENGTH, request_size as u64)
18075                    .body(common::to_body(
18076                        request_value_reader.get_ref().clone().into(),
18077                    ));
18078
18079                client.request(request.unwrap()).await
18080            };
18081
18082            match req_result {
18083                Err(err) => {
18084                    if let common::Retry::After(d) = dlg.http_error(&err) {
18085                        sleep(d).await;
18086                        continue;
18087                    }
18088                    dlg.finished(false);
18089                    return Err(common::Error::HttpError(err));
18090                }
18091                Ok(res) => {
18092                    let (mut parts, body) = res.into_parts();
18093                    let mut body = common::Body::new(body);
18094                    if !parts.status.is_success() {
18095                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18096                        let error = serde_json::from_str(&common::to_string(&bytes));
18097                        let response = common::to_response(parts, bytes.into());
18098
18099                        if let common::Retry::After(d) =
18100                            dlg.http_failure(&response, error.as_ref().ok())
18101                        {
18102                            sleep(d).await;
18103                            continue;
18104                        }
18105
18106                        dlg.finished(false);
18107
18108                        return Err(match error {
18109                            Ok(value) => common::Error::BadRequest(value),
18110                            _ => common::Error::Failure(response),
18111                        });
18112                    }
18113                    let response = {
18114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18115                        let encoded = common::to_string(&bytes);
18116                        match serde_json::from_str(&encoded) {
18117                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18118                            Err(error) => {
18119                                dlg.response_json_decode_error(&encoded, &error);
18120                                return Err(common::Error::JsonDecodeError(
18121                                    encoded.to_string(),
18122                                    error,
18123                                ));
18124                            }
18125                        }
18126                    };
18127
18128                    dlg.finished(true);
18129                    return Ok(response);
18130                }
18131            }
18132        }
18133    }
18134
18135    ///
18136    /// Sets the *request* property to the given value.
18137    ///
18138    /// Even though the property as already been set when instantiating this call,
18139    /// we provide this method for API completeness.
18140    pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfilePatchCall<'a, C> {
18141        self._request = new_value;
18142        self
18143    }
18144    /// User profile ID associated with this request.
18145    ///
18146    /// Sets the *profile id* path property to the given value.
18147    ///
18148    /// Even though the property as already been set when instantiating this call,
18149    /// we provide this method for API completeness.
18150    pub fn profile_id(mut self, new_value: i64) -> AccountUserProfilePatchCall<'a, C> {
18151        self._profile_id = new_value;
18152        self
18153    }
18154    /// User profile ID.
18155    ///
18156    /// Sets the *id* query property to the given value.
18157    ///
18158    /// Even though the property as already been set when instantiating this call,
18159    /// we provide this method for API completeness.
18160    pub fn id(mut self, new_value: i64) -> AccountUserProfilePatchCall<'a, C> {
18161        self._id = new_value;
18162        self
18163    }
18164    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18165    /// while executing the actual API request.
18166    ///
18167    /// ````text
18168    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18169    /// ````
18170    ///
18171    /// Sets the *delegate* property to the given value.
18172    pub fn delegate(
18173        mut self,
18174        new_value: &'a mut dyn common::Delegate,
18175    ) -> AccountUserProfilePatchCall<'a, C> {
18176        self._delegate = Some(new_value);
18177        self
18178    }
18179
18180    /// Set any additional parameter of the query string used in the request.
18181    /// It should be used to set parameters which are not yet available through their own
18182    /// setters.
18183    ///
18184    /// Please note that this method must not be used to set any of the known parameters
18185    /// which have their own setter method. If done anyway, the request will fail.
18186    ///
18187    /// # Additional Parameters
18188    ///
18189    /// * *alt* (query-string) - Data format for the response.
18190    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18191    /// * *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.
18192    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18193    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18194    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18195    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18196    pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfilePatchCall<'a, C>
18197    where
18198        T: AsRef<str>,
18199    {
18200        self._additional_params
18201            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18202        self
18203    }
18204
18205    /// Identifies the authorization scope for the method you are building.
18206    ///
18207    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18208    /// [`Scope::Dfatrafficking`].
18209    ///
18210    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18211    /// tokens for more than one scope.
18212    ///
18213    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18214    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18215    /// sufficient, a read-write scope will do as well.
18216    pub fn add_scope<St>(mut self, scope: St) -> AccountUserProfilePatchCall<'a, C>
18217    where
18218        St: AsRef<str>,
18219    {
18220        self._scopes.insert(String::from(scope.as_ref()));
18221        self
18222    }
18223    /// Identifies the authorization scope(s) for the method you are building.
18224    ///
18225    /// See [`Self::add_scope()`] for details.
18226    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUserProfilePatchCall<'a, C>
18227    where
18228        I: IntoIterator<Item = St>,
18229        St: AsRef<str>,
18230    {
18231        self._scopes
18232            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18233        self
18234    }
18235
18236    /// Removes all scopes, and no default scope will be used either.
18237    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18238    /// for details).
18239    pub fn clear_scopes(mut self) -> AccountUserProfilePatchCall<'a, C> {
18240        self._scopes.clear();
18241        self
18242    }
18243}
18244
18245/// Updates an existing account user profile.
18246///
18247/// A builder for the *update* method supported by a *accountUserProfile* resource.
18248/// It is not used directly, but through a [`AccountUserProfileMethods`] instance.
18249///
18250/// # Example
18251///
18252/// Instantiate a resource method builder
18253///
18254/// ```test_harness,no_run
18255/// # extern crate hyper;
18256/// # extern crate hyper_rustls;
18257/// # extern crate google_dfareporting3d2 as dfareporting3d2;
18258/// use dfareporting3d2::api::AccountUserProfile;
18259/// # async fn dox() {
18260/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18261///
18262/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18264/// #     secret,
18265/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18266/// # ).build().await.unwrap();
18267///
18268/// # let client = hyper_util::client::legacy::Client::builder(
18269/// #     hyper_util::rt::TokioExecutor::new()
18270/// # )
18271/// # .build(
18272/// #     hyper_rustls::HttpsConnectorBuilder::new()
18273/// #         .with_native_roots()
18274/// #         .unwrap()
18275/// #         .https_or_http()
18276/// #         .enable_http1()
18277/// #         .build()
18278/// # );
18279/// # let mut hub = Dfareporting::new(client, auth);
18280/// // As the method needs a request, you would usually fill it with the desired information
18281/// // into the respective structure. Some of the parts shown here might not be applicable !
18282/// // Values shown here are possibly random and not representative !
18283/// let mut req = AccountUserProfile::default();
18284///
18285/// // You can configure optional parameters by calling the respective setters at will, and
18286/// // execute the final call using `doit()`.
18287/// // Values shown here are possibly random and not representative !
18288/// let result = hub.account_user_profiles().update(req, -61)
18289///              .doit().await;
18290/// # }
18291/// ```
18292pub struct AccountUserProfileUpdateCall<'a, C>
18293where
18294    C: 'a,
18295{
18296    hub: &'a Dfareporting<C>,
18297    _request: AccountUserProfile,
18298    _profile_id: i64,
18299    _delegate: Option<&'a mut dyn common::Delegate>,
18300    _additional_params: HashMap<String, String>,
18301    _scopes: BTreeSet<String>,
18302}
18303
18304impl<'a, C> common::CallBuilder for AccountUserProfileUpdateCall<'a, C> {}
18305
18306impl<'a, C> AccountUserProfileUpdateCall<'a, C>
18307where
18308    C: common::Connector,
18309{
18310    /// Perform the operation you have build so far.
18311    pub async fn doit(mut self) -> common::Result<(common::Response, AccountUserProfile)> {
18312        use std::borrow::Cow;
18313        use std::io::{Read, Seek};
18314
18315        use common::{url::Params, ToParts};
18316        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18317
18318        let mut dd = common::DefaultDelegate;
18319        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18320        dlg.begin(common::MethodInfo {
18321            id: "dfareporting.accountUserProfiles.update",
18322            http_method: hyper::Method::PUT,
18323        });
18324
18325        for &field in ["alt", "profileId"].iter() {
18326            if self._additional_params.contains_key(field) {
18327                dlg.finished(false);
18328                return Err(common::Error::FieldClash(field));
18329            }
18330        }
18331
18332        let mut params = Params::with_capacity(4 + self._additional_params.len());
18333        params.push("profileId", self._profile_id.to_string());
18334
18335        params.extend(self._additional_params.iter());
18336
18337        params.push("alt", "json");
18338        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles";
18339        if self._scopes.is_empty() {
18340            self._scopes
18341                .insert(Scope::Dfatrafficking.as_ref().to_string());
18342        }
18343
18344        #[allow(clippy::single_element_loop)]
18345        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
18346            url = params.uri_replacement(url, param_name, find_this, false);
18347        }
18348        {
18349            let to_remove = ["profileId"];
18350            params.remove_params(&to_remove);
18351        }
18352
18353        let url = params.parse_with_url(&url);
18354
18355        let mut json_mime_type = mime::APPLICATION_JSON;
18356        let mut request_value_reader = {
18357            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18358            common::remove_json_null_values(&mut value);
18359            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18360            serde_json::to_writer(&mut dst, &value).unwrap();
18361            dst
18362        };
18363        let request_size = request_value_reader
18364            .seek(std::io::SeekFrom::End(0))
18365            .unwrap();
18366        request_value_reader
18367            .seek(std::io::SeekFrom::Start(0))
18368            .unwrap();
18369
18370        loop {
18371            let token = match self
18372                .hub
18373                .auth
18374                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18375                .await
18376            {
18377                Ok(token) => token,
18378                Err(e) => match dlg.token(e) {
18379                    Ok(token) => token,
18380                    Err(e) => {
18381                        dlg.finished(false);
18382                        return Err(common::Error::MissingToken(e));
18383                    }
18384                },
18385            };
18386            request_value_reader
18387                .seek(std::io::SeekFrom::Start(0))
18388                .unwrap();
18389            let mut req_result = {
18390                let client = &self.hub.client;
18391                dlg.pre_request();
18392                let mut req_builder = hyper::Request::builder()
18393                    .method(hyper::Method::PUT)
18394                    .uri(url.as_str())
18395                    .header(USER_AGENT, self.hub._user_agent.clone());
18396
18397                if let Some(token) = token.as_ref() {
18398                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18399                }
18400
18401                let request = req_builder
18402                    .header(CONTENT_TYPE, json_mime_type.to_string())
18403                    .header(CONTENT_LENGTH, request_size as u64)
18404                    .body(common::to_body(
18405                        request_value_reader.get_ref().clone().into(),
18406                    ));
18407
18408                client.request(request.unwrap()).await
18409            };
18410
18411            match req_result {
18412                Err(err) => {
18413                    if let common::Retry::After(d) = dlg.http_error(&err) {
18414                        sleep(d).await;
18415                        continue;
18416                    }
18417                    dlg.finished(false);
18418                    return Err(common::Error::HttpError(err));
18419                }
18420                Ok(res) => {
18421                    let (mut parts, body) = res.into_parts();
18422                    let mut body = common::Body::new(body);
18423                    if !parts.status.is_success() {
18424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18425                        let error = serde_json::from_str(&common::to_string(&bytes));
18426                        let response = common::to_response(parts, bytes.into());
18427
18428                        if let common::Retry::After(d) =
18429                            dlg.http_failure(&response, error.as_ref().ok())
18430                        {
18431                            sleep(d).await;
18432                            continue;
18433                        }
18434
18435                        dlg.finished(false);
18436
18437                        return Err(match error {
18438                            Ok(value) => common::Error::BadRequest(value),
18439                            _ => common::Error::Failure(response),
18440                        });
18441                    }
18442                    let response = {
18443                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18444                        let encoded = common::to_string(&bytes);
18445                        match serde_json::from_str(&encoded) {
18446                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18447                            Err(error) => {
18448                                dlg.response_json_decode_error(&encoded, &error);
18449                                return Err(common::Error::JsonDecodeError(
18450                                    encoded.to_string(),
18451                                    error,
18452                                ));
18453                            }
18454                        }
18455                    };
18456
18457                    dlg.finished(true);
18458                    return Ok(response);
18459                }
18460            }
18461        }
18462    }
18463
18464    ///
18465    /// Sets the *request* property to the given value.
18466    ///
18467    /// Even though the property as already been set when instantiating this call,
18468    /// we provide this method for API completeness.
18469    pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileUpdateCall<'a, C> {
18470        self._request = new_value;
18471        self
18472    }
18473    /// User profile ID associated with this request.
18474    ///
18475    /// Sets the *profile id* path property to the given value.
18476    ///
18477    /// Even though the property as already been set when instantiating this call,
18478    /// we provide this method for API completeness.
18479    pub fn profile_id(mut self, new_value: i64) -> AccountUserProfileUpdateCall<'a, C> {
18480        self._profile_id = new_value;
18481        self
18482    }
18483    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18484    /// while executing the actual API request.
18485    ///
18486    /// ````text
18487    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18488    /// ````
18489    ///
18490    /// Sets the *delegate* property to the given value.
18491    pub fn delegate(
18492        mut self,
18493        new_value: &'a mut dyn common::Delegate,
18494    ) -> AccountUserProfileUpdateCall<'a, C> {
18495        self._delegate = Some(new_value);
18496        self
18497    }
18498
18499    /// Set any additional parameter of the query string used in the request.
18500    /// It should be used to set parameters which are not yet available through their own
18501    /// setters.
18502    ///
18503    /// Please note that this method must not be used to set any of the known parameters
18504    /// which have their own setter method. If done anyway, the request will fail.
18505    ///
18506    /// # Additional Parameters
18507    ///
18508    /// * *alt* (query-string) - Data format for the response.
18509    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18510    /// * *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.
18511    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18512    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18513    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18514    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18515    pub fn param<T>(mut self, name: T, value: T) -> AccountUserProfileUpdateCall<'a, C>
18516    where
18517        T: AsRef<str>,
18518    {
18519        self._additional_params
18520            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18521        self
18522    }
18523
18524    /// Identifies the authorization scope for the method you are building.
18525    ///
18526    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18527    /// [`Scope::Dfatrafficking`].
18528    ///
18529    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18530    /// tokens for more than one scope.
18531    ///
18532    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18533    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18534    /// sufficient, a read-write scope will do as well.
18535    pub fn add_scope<St>(mut self, scope: St) -> AccountUserProfileUpdateCall<'a, C>
18536    where
18537        St: AsRef<str>,
18538    {
18539        self._scopes.insert(String::from(scope.as_ref()));
18540        self
18541    }
18542    /// Identifies the authorization scope(s) for the method you are building.
18543    ///
18544    /// See [`Self::add_scope()`] for details.
18545    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUserProfileUpdateCall<'a, C>
18546    where
18547        I: IntoIterator<Item = St>,
18548        St: AsRef<str>,
18549    {
18550        self._scopes
18551            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18552        self
18553    }
18554
18555    /// Removes all scopes, and no default scope will be used either.
18556    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18557    /// for details).
18558    pub fn clear_scopes(mut self) -> AccountUserProfileUpdateCall<'a, C> {
18559        self._scopes.clear();
18560        self
18561    }
18562}
18563
18564/// Gets one account by ID.
18565///
18566/// A builder for the *get* method supported by a *account* resource.
18567/// It is not used directly, but through a [`AccountMethods`] instance.
18568///
18569/// # Example
18570///
18571/// Instantiate a resource method builder
18572///
18573/// ```test_harness,no_run
18574/// # extern crate hyper;
18575/// # extern crate hyper_rustls;
18576/// # extern crate google_dfareporting3d2 as dfareporting3d2;
18577/// # async fn dox() {
18578/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18579///
18580/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18582/// #     secret,
18583/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18584/// # ).build().await.unwrap();
18585///
18586/// # let client = hyper_util::client::legacy::Client::builder(
18587/// #     hyper_util::rt::TokioExecutor::new()
18588/// # )
18589/// # .build(
18590/// #     hyper_rustls::HttpsConnectorBuilder::new()
18591/// #         .with_native_roots()
18592/// #         .unwrap()
18593/// #         .https_or_http()
18594/// #         .enable_http1()
18595/// #         .build()
18596/// # );
18597/// # let mut hub = Dfareporting::new(client, auth);
18598/// // You can configure optional parameters by calling the respective setters at will, and
18599/// // execute the final call using `doit()`.
18600/// // Values shown here are possibly random and not representative !
18601/// let result = hub.accounts().get(-15, -13)
18602///              .doit().await;
18603/// # }
18604/// ```
18605pub struct AccountGetCall<'a, C>
18606where
18607    C: 'a,
18608{
18609    hub: &'a Dfareporting<C>,
18610    _profile_id: i64,
18611    _id: i64,
18612    _delegate: Option<&'a mut dyn common::Delegate>,
18613    _additional_params: HashMap<String, String>,
18614    _scopes: BTreeSet<String>,
18615}
18616
18617impl<'a, C> common::CallBuilder for AccountGetCall<'a, C> {}
18618
18619impl<'a, C> AccountGetCall<'a, C>
18620where
18621    C: common::Connector,
18622{
18623    /// Perform the operation you have build so far.
18624    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
18625        use std::borrow::Cow;
18626        use std::io::{Read, Seek};
18627
18628        use common::{url::Params, ToParts};
18629        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18630
18631        let mut dd = common::DefaultDelegate;
18632        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18633        dlg.begin(common::MethodInfo {
18634            id: "dfareporting.accounts.get",
18635            http_method: hyper::Method::GET,
18636        });
18637
18638        for &field in ["alt", "profileId", "id"].iter() {
18639            if self._additional_params.contains_key(field) {
18640                dlg.finished(false);
18641                return Err(common::Error::FieldClash(field));
18642            }
18643        }
18644
18645        let mut params = Params::with_capacity(4 + self._additional_params.len());
18646        params.push("profileId", self._profile_id.to_string());
18647        params.push("id", self._id.to_string());
18648
18649        params.extend(self._additional_params.iter());
18650
18651        params.push("alt", "json");
18652        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts/{id}";
18653        if self._scopes.is_empty() {
18654            self._scopes
18655                .insert(Scope::Dfatrafficking.as_ref().to_string());
18656        }
18657
18658        #[allow(clippy::single_element_loop)]
18659        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
18660            url = params.uri_replacement(url, param_name, find_this, false);
18661        }
18662        {
18663            let to_remove = ["id", "profileId"];
18664            params.remove_params(&to_remove);
18665        }
18666
18667        let url = params.parse_with_url(&url);
18668
18669        loop {
18670            let token = match self
18671                .hub
18672                .auth
18673                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18674                .await
18675            {
18676                Ok(token) => token,
18677                Err(e) => match dlg.token(e) {
18678                    Ok(token) => token,
18679                    Err(e) => {
18680                        dlg.finished(false);
18681                        return Err(common::Error::MissingToken(e));
18682                    }
18683                },
18684            };
18685            let mut req_result = {
18686                let client = &self.hub.client;
18687                dlg.pre_request();
18688                let mut req_builder = hyper::Request::builder()
18689                    .method(hyper::Method::GET)
18690                    .uri(url.as_str())
18691                    .header(USER_AGENT, self.hub._user_agent.clone());
18692
18693                if let Some(token) = token.as_ref() {
18694                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18695                }
18696
18697                let request = req_builder
18698                    .header(CONTENT_LENGTH, 0_u64)
18699                    .body(common::to_body::<String>(None));
18700
18701                client.request(request.unwrap()).await
18702            };
18703
18704            match req_result {
18705                Err(err) => {
18706                    if let common::Retry::After(d) = dlg.http_error(&err) {
18707                        sleep(d).await;
18708                        continue;
18709                    }
18710                    dlg.finished(false);
18711                    return Err(common::Error::HttpError(err));
18712                }
18713                Ok(res) => {
18714                    let (mut parts, body) = res.into_parts();
18715                    let mut body = common::Body::new(body);
18716                    if !parts.status.is_success() {
18717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18718                        let error = serde_json::from_str(&common::to_string(&bytes));
18719                        let response = common::to_response(parts, bytes.into());
18720
18721                        if let common::Retry::After(d) =
18722                            dlg.http_failure(&response, error.as_ref().ok())
18723                        {
18724                            sleep(d).await;
18725                            continue;
18726                        }
18727
18728                        dlg.finished(false);
18729
18730                        return Err(match error {
18731                            Ok(value) => common::Error::BadRequest(value),
18732                            _ => common::Error::Failure(response),
18733                        });
18734                    }
18735                    let response = {
18736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18737                        let encoded = common::to_string(&bytes);
18738                        match serde_json::from_str(&encoded) {
18739                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18740                            Err(error) => {
18741                                dlg.response_json_decode_error(&encoded, &error);
18742                                return Err(common::Error::JsonDecodeError(
18743                                    encoded.to_string(),
18744                                    error,
18745                                ));
18746                            }
18747                        }
18748                    };
18749
18750                    dlg.finished(true);
18751                    return Ok(response);
18752                }
18753            }
18754        }
18755    }
18756
18757    /// User profile ID associated with this request.
18758    ///
18759    /// Sets the *profile id* path property to the given value.
18760    ///
18761    /// Even though the property as already been set when instantiating this call,
18762    /// we provide this method for API completeness.
18763    pub fn profile_id(mut self, new_value: i64) -> AccountGetCall<'a, C> {
18764        self._profile_id = new_value;
18765        self
18766    }
18767    /// Account ID.
18768    ///
18769    /// Sets the *id* path property to the given value.
18770    ///
18771    /// Even though the property as already been set when instantiating this call,
18772    /// we provide this method for API completeness.
18773    pub fn id(mut self, new_value: i64) -> AccountGetCall<'a, C> {
18774        self._id = new_value;
18775        self
18776    }
18777    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18778    /// while executing the actual API request.
18779    ///
18780    /// ````text
18781    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18782    /// ````
18783    ///
18784    /// Sets the *delegate* property to the given value.
18785    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountGetCall<'a, C> {
18786        self._delegate = Some(new_value);
18787        self
18788    }
18789
18790    /// Set any additional parameter of the query string used in the request.
18791    /// It should be used to set parameters which are not yet available through their own
18792    /// setters.
18793    ///
18794    /// Please note that this method must not be used to set any of the known parameters
18795    /// which have their own setter method. If done anyway, the request will fail.
18796    ///
18797    /// # Additional Parameters
18798    ///
18799    /// * *alt* (query-string) - Data format for the response.
18800    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18801    /// * *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.
18802    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18803    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18804    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18805    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18806    pub fn param<T>(mut self, name: T, value: T) -> AccountGetCall<'a, C>
18807    where
18808        T: AsRef<str>,
18809    {
18810        self._additional_params
18811            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18812        self
18813    }
18814
18815    /// Identifies the authorization scope for the method you are building.
18816    ///
18817    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18818    /// [`Scope::Dfatrafficking`].
18819    ///
18820    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18821    /// tokens for more than one scope.
18822    ///
18823    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18824    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18825    /// sufficient, a read-write scope will do as well.
18826    pub fn add_scope<St>(mut self, scope: St) -> AccountGetCall<'a, C>
18827    where
18828        St: AsRef<str>,
18829    {
18830        self._scopes.insert(String::from(scope.as_ref()));
18831        self
18832    }
18833    /// Identifies the authorization scope(s) for the method you are building.
18834    ///
18835    /// See [`Self::add_scope()`] for details.
18836    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, C>
18837    where
18838        I: IntoIterator<Item = St>,
18839        St: AsRef<str>,
18840    {
18841        self._scopes
18842            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18843        self
18844    }
18845
18846    /// Removes all scopes, and no default scope will be used either.
18847    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18848    /// for details).
18849    pub fn clear_scopes(mut self) -> AccountGetCall<'a, C> {
18850        self._scopes.clear();
18851        self
18852    }
18853}
18854
18855/// Retrieves the list of accounts, possibly filtered. This method supports paging.
18856///
18857/// A builder for the *list* method supported by a *account* resource.
18858/// It is not used directly, but through a [`AccountMethods`] instance.
18859///
18860/// # Example
18861///
18862/// Instantiate a resource method builder
18863///
18864/// ```test_harness,no_run
18865/// # extern crate hyper;
18866/// # extern crate hyper_rustls;
18867/// # extern crate google_dfareporting3d2 as dfareporting3d2;
18868/// # async fn dox() {
18869/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18870///
18871/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18873/// #     secret,
18874/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18875/// # ).build().await.unwrap();
18876///
18877/// # let client = hyper_util::client::legacy::Client::builder(
18878/// #     hyper_util::rt::TokioExecutor::new()
18879/// # )
18880/// # .build(
18881/// #     hyper_rustls::HttpsConnectorBuilder::new()
18882/// #         .with_native_roots()
18883/// #         .unwrap()
18884/// #         .https_or_http()
18885/// #         .enable_http1()
18886/// #         .build()
18887/// # );
18888/// # let mut hub = Dfareporting::new(client, auth);
18889/// // You can configure optional parameters by calling the respective setters at will, and
18890/// // execute the final call using `doit()`.
18891/// // Values shown here are possibly random and not representative !
18892/// let result = hub.accounts().list(-24)
18893///              .sort_order("sed")
18894///              .sort_field("et")
18895///              .search_string("et")
18896///              .page_token("vero")
18897///              .max_results(-31)
18898///              .add_ids(-93)
18899///              .active(false)
18900///              .doit().await;
18901/// # }
18902/// ```
18903pub struct AccountListCall<'a, C>
18904where
18905    C: 'a,
18906{
18907    hub: &'a Dfareporting<C>,
18908    _profile_id: i64,
18909    _sort_order: Option<String>,
18910    _sort_field: Option<String>,
18911    _search_string: Option<String>,
18912    _page_token: Option<String>,
18913    _max_results: Option<i32>,
18914    _ids: Vec<i64>,
18915    _active: Option<bool>,
18916    _delegate: Option<&'a mut dyn common::Delegate>,
18917    _additional_params: HashMap<String, String>,
18918    _scopes: BTreeSet<String>,
18919}
18920
18921impl<'a, C> common::CallBuilder for AccountListCall<'a, C> {}
18922
18923impl<'a, C> AccountListCall<'a, C>
18924where
18925    C: common::Connector,
18926{
18927    /// Perform the operation you have build so far.
18928    pub async fn doit(mut self) -> common::Result<(common::Response, AccountsListResponse)> {
18929        use std::borrow::Cow;
18930        use std::io::{Read, Seek};
18931
18932        use common::{url::Params, ToParts};
18933        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18934
18935        let mut dd = common::DefaultDelegate;
18936        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18937        dlg.begin(common::MethodInfo {
18938            id: "dfareporting.accounts.list",
18939            http_method: hyper::Method::GET,
18940        });
18941
18942        for &field in [
18943            "alt",
18944            "profileId",
18945            "sortOrder",
18946            "sortField",
18947            "searchString",
18948            "pageToken",
18949            "maxResults",
18950            "ids",
18951            "active",
18952        ]
18953        .iter()
18954        {
18955            if self._additional_params.contains_key(field) {
18956                dlg.finished(false);
18957                return Err(common::Error::FieldClash(field));
18958            }
18959        }
18960
18961        let mut params = Params::with_capacity(10 + self._additional_params.len());
18962        params.push("profileId", self._profile_id.to_string());
18963        if let Some(value) = self._sort_order.as_ref() {
18964            params.push("sortOrder", value);
18965        }
18966        if let Some(value) = self._sort_field.as_ref() {
18967            params.push("sortField", value);
18968        }
18969        if let Some(value) = self._search_string.as_ref() {
18970            params.push("searchString", value);
18971        }
18972        if let Some(value) = self._page_token.as_ref() {
18973            params.push("pageToken", value);
18974        }
18975        if let Some(value) = self._max_results.as_ref() {
18976            params.push("maxResults", value.to_string());
18977        }
18978        if !self._ids.is_empty() {
18979            for f in self._ids.iter() {
18980                params.push("ids", f.to_string());
18981            }
18982        }
18983        if let Some(value) = self._active.as_ref() {
18984            params.push("active", value.to_string());
18985        }
18986
18987        params.extend(self._additional_params.iter());
18988
18989        params.push("alt", "json");
18990        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts";
18991        if self._scopes.is_empty() {
18992            self._scopes
18993                .insert(Scope::Dfatrafficking.as_ref().to_string());
18994        }
18995
18996        #[allow(clippy::single_element_loop)]
18997        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
18998            url = params.uri_replacement(url, param_name, find_this, false);
18999        }
19000        {
19001            let to_remove = ["profileId"];
19002            params.remove_params(&to_remove);
19003        }
19004
19005        let url = params.parse_with_url(&url);
19006
19007        loop {
19008            let token = match self
19009                .hub
19010                .auth
19011                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19012                .await
19013            {
19014                Ok(token) => token,
19015                Err(e) => match dlg.token(e) {
19016                    Ok(token) => token,
19017                    Err(e) => {
19018                        dlg.finished(false);
19019                        return Err(common::Error::MissingToken(e));
19020                    }
19021                },
19022            };
19023            let mut req_result = {
19024                let client = &self.hub.client;
19025                dlg.pre_request();
19026                let mut req_builder = hyper::Request::builder()
19027                    .method(hyper::Method::GET)
19028                    .uri(url.as_str())
19029                    .header(USER_AGENT, self.hub._user_agent.clone());
19030
19031                if let Some(token) = token.as_ref() {
19032                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19033                }
19034
19035                let request = req_builder
19036                    .header(CONTENT_LENGTH, 0_u64)
19037                    .body(common::to_body::<String>(None));
19038
19039                client.request(request.unwrap()).await
19040            };
19041
19042            match req_result {
19043                Err(err) => {
19044                    if let common::Retry::After(d) = dlg.http_error(&err) {
19045                        sleep(d).await;
19046                        continue;
19047                    }
19048                    dlg.finished(false);
19049                    return Err(common::Error::HttpError(err));
19050                }
19051                Ok(res) => {
19052                    let (mut parts, body) = res.into_parts();
19053                    let mut body = common::Body::new(body);
19054                    if !parts.status.is_success() {
19055                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19056                        let error = serde_json::from_str(&common::to_string(&bytes));
19057                        let response = common::to_response(parts, bytes.into());
19058
19059                        if let common::Retry::After(d) =
19060                            dlg.http_failure(&response, error.as_ref().ok())
19061                        {
19062                            sleep(d).await;
19063                            continue;
19064                        }
19065
19066                        dlg.finished(false);
19067
19068                        return Err(match error {
19069                            Ok(value) => common::Error::BadRequest(value),
19070                            _ => common::Error::Failure(response),
19071                        });
19072                    }
19073                    let response = {
19074                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19075                        let encoded = common::to_string(&bytes);
19076                        match serde_json::from_str(&encoded) {
19077                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19078                            Err(error) => {
19079                                dlg.response_json_decode_error(&encoded, &error);
19080                                return Err(common::Error::JsonDecodeError(
19081                                    encoded.to_string(),
19082                                    error,
19083                                ));
19084                            }
19085                        }
19086                    };
19087
19088                    dlg.finished(true);
19089                    return Ok(response);
19090                }
19091            }
19092        }
19093    }
19094
19095    /// User profile ID associated with this request.
19096    ///
19097    /// Sets the *profile id* path property to the given value.
19098    ///
19099    /// Even though the property as already been set when instantiating this call,
19100    /// we provide this method for API completeness.
19101    pub fn profile_id(mut self, new_value: i64) -> AccountListCall<'a, C> {
19102        self._profile_id = new_value;
19103        self
19104    }
19105    /// Order of sorted results.
19106    ///
19107    /// Sets the *sort order* query property to the given value.
19108    pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, C> {
19109        self._sort_order = Some(new_value.to_string());
19110        self
19111    }
19112    /// Field by which to sort the list.
19113    ///
19114    /// Sets the *sort field* query property to the given value.
19115    pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, C> {
19116        self._sort_field = Some(new_value.to_string());
19117        self
19118    }
19119    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "account*2015" will return objects with names like "account June 2015", "account April 2015", or simply "account 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "account" will match objects with name "my account", "account 2015", or simply "account".
19120    ///
19121    /// Sets the *search string* query property to the given value.
19122    pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, C> {
19123        self._search_string = Some(new_value.to_string());
19124        self
19125    }
19126    /// Value of the nextPageToken from the previous result page.
19127    ///
19128    /// Sets the *page token* query property to the given value.
19129    pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C> {
19130        self._page_token = Some(new_value.to_string());
19131        self
19132    }
19133    /// Maximum number of results to return.
19134    ///
19135    /// Sets the *max results* query property to the given value.
19136    pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, C> {
19137        self._max_results = Some(new_value);
19138        self
19139    }
19140    /// Select only accounts with these IDs.
19141    ///
19142    /// Append the given value to the *ids* query property.
19143    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
19144    pub fn add_ids(mut self, new_value: i64) -> AccountListCall<'a, C> {
19145        self._ids.push(new_value);
19146        self
19147    }
19148    /// Select only active accounts. Don't set this field to select both active and non-active accounts.
19149    ///
19150    /// Sets the *active* query property to the given value.
19151    pub fn active(mut self, new_value: bool) -> AccountListCall<'a, C> {
19152        self._active = Some(new_value);
19153        self
19154    }
19155    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19156    /// while executing the actual API request.
19157    ///
19158    /// ````text
19159    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19160    /// ````
19161    ///
19162    /// Sets the *delegate* property to the given value.
19163    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountListCall<'a, C> {
19164        self._delegate = Some(new_value);
19165        self
19166    }
19167
19168    /// Set any additional parameter of the query string used in the request.
19169    /// It should be used to set parameters which are not yet available through their own
19170    /// setters.
19171    ///
19172    /// Please note that this method must not be used to set any of the known parameters
19173    /// which have their own setter method. If done anyway, the request will fail.
19174    ///
19175    /// # Additional Parameters
19176    ///
19177    /// * *alt* (query-string) - Data format for the response.
19178    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19179    /// * *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.
19180    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19181    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19182    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19183    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19184    pub fn param<T>(mut self, name: T, value: T) -> AccountListCall<'a, C>
19185    where
19186        T: AsRef<str>,
19187    {
19188        self._additional_params
19189            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19190        self
19191    }
19192
19193    /// Identifies the authorization scope for the method you are building.
19194    ///
19195    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19196    /// [`Scope::Dfatrafficking`].
19197    ///
19198    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19199    /// tokens for more than one scope.
19200    ///
19201    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19202    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19203    /// sufficient, a read-write scope will do as well.
19204    pub fn add_scope<St>(mut self, scope: St) -> AccountListCall<'a, C>
19205    where
19206        St: AsRef<str>,
19207    {
19208        self._scopes.insert(String::from(scope.as_ref()));
19209        self
19210    }
19211    /// Identifies the authorization scope(s) for the method you are building.
19212    ///
19213    /// See [`Self::add_scope()`] for details.
19214    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, C>
19215    where
19216        I: IntoIterator<Item = St>,
19217        St: AsRef<str>,
19218    {
19219        self._scopes
19220            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19221        self
19222    }
19223
19224    /// Removes all scopes, and no default scope will be used either.
19225    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19226    /// for details).
19227    pub fn clear_scopes(mut self) -> AccountListCall<'a, C> {
19228        self._scopes.clear();
19229        self
19230    }
19231}
19232
19233/// Updates an existing account. This method supports patch semantics.
19234///
19235/// A builder for the *patch* method supported by a *account* resource.
19236/// It is not used directly, but through a [`AccountMethods`] instance.
19237///
19238/// # Example
19239///
19240/// Instantiate a resource method builder
19241///
19242/// ```test_harness,no_run
19243/// # extern crate hyper;
19244/// # extern crate hyper_rustls;
19245/// # extern crate google_dfareporting3d2 as dfareporting3d2;
19246/// use dfareporting3d2::api::Account;
19247/// # async fn dox() {
19248/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19249///
19250/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19252/// #     secret,
19253/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19254/// # ).build().await.unwrap();
19255///
19256/// # let client = hyper_util::client::legacy::Client::builder(
19257/// #     hyper_util::rt::TokioExecutor::new()
19258/// # )
19259/// # .build(
19260/// #     hyper_rustls::HttpsConnectorBuilder::new()
19261/// #         .with_native_roots()
19262/// #         .unwrap()
19263/// #         .https_or_http()
19264/// #         .enable_http1()
19265/// #         .build()
19266/// # );
19267/// # let mut hub = Dfareporting::new(client, auth);
19268/// // As the method needs a request, you would usually fill it with the desired information
19269/// // into the respective structure. Some of the parts shown here might not be applicable !
19270/// // Values shown here are possibly random and not representative !
19271/// let mut req = Account::default();
19272///
19273/// // You can configure optional parameters by calling the respective setters at will, and
19274/// // execute the final call using `doit()`.
19275/// // Values shown here are possibly random and not representative !
19276/// let result = hub.accounts().patch(req, -92, -49)
19277///              .doit().await;
19278/// # }
19279/// ```
19280pub struct AccountPatchCall<'a, C>
19281where
19282    C: 'a,
19283{
19284    hub: &'a Dfareporting<C>,
19285    _request: Account,
19286    _profile_id: i64,
19287    _id: i64,
19288    _delegate: Option<&'a mut dyn common::Delegate>,
19289    _additional_params: HashMap<String, String>,
19290    _scopes: BTreeSet<String>,
19291}
19292
19293impl<'a, C> common::CallBuilder for AccountPatchCall<'a, C> {}
19294
19295impl<'a, C> AccountPatchCall<'a, C>
19296where
19297    C: common::Connector,
19298{
19299    /// Perform the operation you have build so far.
19300    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
19301        use std::borrow::Cow;
19302        use std::io::{Read, Seek};
19303
19304        use common::{url::Params, ToParts};
19305        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19306
19307        let mut dd = common::DefaultDelegate;
19308        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19309        dlg.begin(common::MethodInfo {
19310            id: "dfareporting.accounts.patch",
19311            http_method: hyper::Method::PATCH,
19312        });
19313
19314        for &field in ["alt", "profileId", "id"].iter() {
19315            if self._additional_params.contains_key(field) {
19316                dlg.finished(false);
19317                return Err(common::Error::FieldClash(field));
19318            }
19319        }
19320
19321        let mut params = Params::with_capacity(5 + self._additional_params.len());
19322        params.push("profileId", self._profile_id.to_string());
19323        params.push("id", self._id.to_string());
19324
19325        params.extend(self._additional_params.iter());
19326
19327        params.push("alt", "json");
19328        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts";
19329        if self._scopes.is_empty() {
19330            self._scopes
19331                .insert(Scope::Dfatrafficking.as_ref().to_string());
19332        }
19333
19334        #[allow(clippy::single_element_loop)]
19335        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
19336            url = params.uri_replacement(url, param_name, find_this, false);
19337        }
19338        {
19339            let to_remove = ["profileId"];
19340            params.remove_params(&to_remove);
19341        }
19342
19343        let url = params.parse_with_url(&url);
19344
19345        let mut json_mime_type = mime::APPLICATION_JSON;
19346        let mut request_value_reader = {
19347            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19348            common::remove_json_null_values(&mut value);
19349            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19350            serde_json::to_writer(&mut dst, &value).unwrap();
19351            dst
19352        };
19353        let request_size = request_value_reader
19354            .seek(std::io::SeekFrom::End(0))
19355            .unwrap();
19356        request_value_reader
19357            .seek(std::io::SeekFrom::Start(0))
19358            .unwrap();
19359
19360        loop {
19361            let token = match self
19362                .hub
19363                .auth
19364                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19365                .await
19366            {
19367                Ok(token) => token,
19368                Err(e) => match dlg.token(e) {
19369                    Ok(token) => token,
19370                    Err(e) => {
19371                        dlg.finished(false);
19372                        return Err(common::Error::MissingToken(e));
19373                    }
19374                },
19375            };
19376            request_value_reader
19377                .seek(std::io::SeekFrom::Start(0))
19378                .unwrap();
19379            let mut req_result = {
19380                let client = &self.hub.client;
19381                dlg.pre_request();
19382                let mut req_builder = hyper::Request::builder()
19383                    .method(hyper::Method::PATCH)
19384                    .uri(url.as_str())
19385                    .header(USER_AGENT, self.hub._user_agent.clone());
19386
19387                if let Some(token) = token.as_ref() {
19388                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19389                }
19390
19391                let request = req_builder
19392                    .header(CONTENT_TYPE, json_mime_type.to_string())
19393                    .header(CONTENT_LENGTH, request_size as u64)
19394                    .body(common::to_body(
19395                        request_value_reader.get_ref().clone().into(),
19396                    ));
19397
19398                client.request(request.unwrap()).await
19399            };
19400
19401            match req_result {
19402                Err(err) => {
19403                    if let common::Retry::After(d) = dlg.http_error(&err) {
19404                        sleep(d).await;
19405                        continue;
19406                    }
19407                    dlg.finished(false);
19408                    return Err(common::Error::HttpError(err));
19409                }
19410                Ok(res) => {
19411                    let (mut parts, body) = res.into_parts();
19412                    let mut body = common::Body::new(body);
19413                    if !parts.status.is_success() {
19414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19415                        let error = serde_json::from_str(&common::to_string(&bytes));
19416                        let response = common::to_response(parts, bytes.into());
19417
19418                        if let common::Retry::After(d) =
19419                            dlg.http_failure(&response, error.as_ref().ok())
19420                        {
19421                            sleep(d).await;
19422                            continue;
19423                        }
19424
19425                        dlg.finished(false);
19426
19427                        return Err(match error {
19428                            Ok(value) => common::Error::BadRequest(value),
19429                            _ => common::Error::Failure(response),
19430                        });
19431                    }
19432                    let response = {
19433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19434                        let encoded = common::to_string(&bytes);
19435                        match serde_json::from_str(&encoded) {
19436                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19437                            Err(error) => {
19438                                dlg.response_json_decode_error(&encoded, &error);
19439                                return Err(common::Error::JsonDecodeError(
19440                                    encoded.to_string(),
19441                                    error,
19442                                ));
19443                            }
19444                        }
19445                    };
19446
19447                    dlg.finished(true);
19448                    return Ok(response);
19449                }
19450            }
19451        }
19452    }
19453
19454    ///
19455    /// Sets the *request* property to the given value.
19456    ///
19457    /// Even though the property as already been set when instantiating this call,
19458    /// we provide this method for API completeness.
19459    pub fn request(mut self, new_value: Account) -> AccountPatchCall<'a, C> {
19460        self._request = new_value;
19461        self
19462    }
19463    /// User profile ID associated with this request.
19464    ///
19465    /// Sets the *profile id* path property to the given value.
19466    ///
19467    /// Even though the property as already been set when instantiating this call,
19468    /// we provide this method for API completeness.
19469    pub fn profile_id(mut self, new_value: i64) -> AccountPatchCall<'a, C> {
19470        self._profile_id = new_value;
19471        self
19472    }
19473    /// Account ID.
19474    ///
19475    /// Sets the *id* query property to the given value.
19476    ///
19477    /// Even though the property as already been set when instantiating this call,
19478    /// we provide this method for API completeness.
19479    pub fn id(mut self, new_value: i64) -> AccountPatchCall<'a, C> {
19480        self._id = new_value;
19481        self
19482    }
19483    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19484    /// while executing the actual API request.
19485    ///
19486    /// ````text
19487    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19488    /// ````
19489    ///
19490    /// Sets the *delegate* property to the given value.
19491    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountPatchCall<'a, C> {
19492        self._delegate = Some(new_value);
19493        self
19494    }
19495
19496    /// Set any additional parameter of the query string used in the request.
19497    /// It should be used to set parameters which are not yet available through their own
19498    /// setters.
19499    ///
19500    /// Please note that this method must not be used to set any of the known parameters
19501    /// which have their own setter method. If done anyway, the request will fail.
19502    ///
19503    /// # Additional Parameters
19504    ///
19505    /// * *alt* (query-string) - Data format for the response.
19506    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19507    /// * *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.
19508    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19509    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19510    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19511    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19512    pub fn param<T>(mut self, name: T, value: T) -> AccountPatchCall<'a, C>
19513    where
19514        T: AsRef<str>,
19515    {
19516        self._additional_params
19517            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19518        self
19519    }
19520
19521    /// Identifies the authorization scope for the method you are building.
19522    ///
19523    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19524    /// [`Scope::Dfatrafficking`].
19525    ///
19526    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19527    /// tokens for more than one scope.
19528    ///
19529    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19530    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19531    /// sufficient, a read-write scope will do as well.
19532    pub fn add_scope<St>(mut self, scope: St) -> AccountPatchCall<'a, C>
19533    where
19534        St: AsRef<str>,
19535    {
19536        self._scopes.insert(String::from(scope.as_ref()));
19537        self
19538    }
19539    /// Identifies the authorization scope(s) for the method you are building.
19540    ///
19541    /// See [`Self::add_scope()`] for details.
19542    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPatchCall<'a, C>
19543    where
19544        I: IntoIterator<Item = St>,
19545        St: AsRef<str>,
19546    {
19547        self._scopes
19548            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19549        self
19550    }
19551
19552    /// Removes all scopes, and no default scope will be used either.
19553    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19554    /// for details).
19555    pub fn clear_scopes(mut self) -> AccountPatchCall<'a, C> {
19556        self._scopes.clear();
19557        self
19558    }
19559}
19560
19561/// Updates an existing account.
19562///
19563/// A builder for the *update* method supported by a *account* resource.
19564/// It is not used directly, but through a [`AccountMethods`] instance.
19565///
19566/// # Example
19567///
19568/// Instantiate a resource method builder
19569///
19570/// ```test_harness,no_run
19571/// # extern crate hyper;
19572/// # extern crate hyper_rustls;
19573/// # extern crate google_dfareporting3d2 as dfareporting3d2;
19574/// use dfareporting3d2::api::Account;
19575/// # async fn dox() {
19576/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19577///
19578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19579/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19580/// #     secret,
19581/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19582/// # ).build().await.unwrap();
19583///
19584/// # let client = hyper_util::client::legacy::Client::builder(
19585/// #     hyper_util::rt::TokioExecutor::new()
19586/// # )
19587/// # .build(
19588/// #     hyper_rustls::HttpsConnectorBuilder::new()
19589/// #         .with_native_roots()
19590/// #         .unwrap()
19591/// #         .https_or_http()
19592/// #         .enable_http1()
19593/// #         .build()
19594/// # );
19595/// # let mut hub = Dfareporting::new(client, auth);
19596/// // As the method needs a request, you would usually fill it with the desired information
19597/// // into the respective structure. Some of the parts shown here might not be applicable !
19598/// // Values shown here are possibly random and not representative !
19599/// let mut req = Account::default();
19600///
19601/// // You can configure optional parameters by calling the respective setters at will, and
19602/// // execute the final call using `doit()`.
19603/// // Values shown here are possibly random and not representative !
19604/// let result = hub.accounts().update(req, -18)
19605///              .doit().await;
19606/// # }
19607/// ```
19608pub struct AccountUpdateCall<'a, C>
19609where
19610    C: 'a,
19611{
19612    hub: &'a Dfareporting<C>,
19613    _request: Account,
19614    _profile_id: i64,
19615    _delegate: Option<&'a mut dyn common::Delegate>,
19616    _additional_params: HashMap<String, String>,
19617    _scopes: BTreeSet<String>,
19618}
19619
19620impl<'a, C> common::CallBuilder for AccountUpdateCall<'a, C> {}
19621
19622impl<'a, C> AccountUpdateCall<'a, C>
19623where
19624    C: common::Connector,
19625{
19626    /// Perform the operation you have build so far.
19627    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
19628        use std::borrow::Cow;
19629        use std::io::{Read, Seek};
19630
19631        use common::{url::Params, ToParts};
19632        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19633
19634        let mut dd = common::DefaultDelegate;
19635        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19636        dlg.begin(common::MethodInfo {
19637            id: "dfareporting.accounts.update",
19638            http_method: hyper::Method::PUT,
19639        });
19640
19641        for &field in ["alt", "profileId"].iter() {
19642            if self._additional_params.contains_key(field) {
19643                dlg.finished(false);
19644                return Err(common::Error::FieldClash(field));
19645            }
19646        }
19647
19648        let mut params = Params::with_capacity(4 + self._additional_params.len());
19649        params.push("profileId", self._profile_id.to_string());
19650
19651        params.extend(self._additional_params.iter());
19652
19653        params.push("alt", "json");
19654        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts";
19655        if self._scopes.is_empty() {
19656            self._scopes
19657                .insert(Scope::Dfatrafficking.as_ref().to_string());
19658        }
19659
19660        #[allow(clippy::single_element_loop)]
19661        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
19662            url = params.uri_replacement(url, param_name, find_this, false);
19663        }
19664        {
19665            let to_remove = ["profileId"];
19666            params.remove_params(&to_remove);
19667        }
19668
19669        let url = params.parse_with_url(&url);
19670
19671        let mut json_mime_type = mime::APPLICATION_JSON;
19672        let mut request_value_reader = {
19673            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19674            common::remove_json_null_values(&mut value);
19675            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19676            serde_json::to_writer(&mut dst, &value).unwrap();
19677            dst
19678        };
19679        let request_size = request_value_reader
19680            .seek(std::io::SeekFrom::End(0))
19681            .unwrap();
19682        request_value_reader
19683            .seek(std::io::SeekFrom::Start(0))
19684            .unwrap();
19685
19686        loop {
19687            let token = match self
19688                .hub
19689                .auth
19690                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19691                .await
19692            {
19693                Ok(token) => token,
19694                Err(e) => match dlg.token(e) {
19695                    Ok(token) => token,
19696                    Err(e) => {
19697                        dlg.finished(false);
19698                        return Err(common::Error::MissingToken(e));
19699                    }
19700                },
19701            };
19702            request_value_reader
19703                .seek(std::io::SeekFrom::Start(0))
19704                .unwrap();
19705            let mut req_result = {
19706                let client = &self.hub.client;
19707                dlg.pre_request();
19708                let mut req_builder = hyper::Request::builder()
19709                    .method(hyper::Method::PUT)
19710                    .uri(url.as_str())
19711                    .header(USER_AGENT, self.hub._user_agent.clone());
19712
19713                if let Some(token) = token.as_ref() {
19714                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19715                }
19716
19717                let request = req_builder
19718                    .header(CONTENT_TYPE, json_mime_type.to_string())
19719                    .header(CONTENT_LENGTH, request_size as u64)
19720                    .body(common::to_body(
19721                        request_value_reader.get_ref().clone().into(),
19722                    ));
19723
19724                client.request(request.unwrap()).await
19725            };
19726
19727            match req_result {
19728                Err(err) => {
19729                    if let common::Retry::After(d) = dlg.http_error(&err) {
19730                        sleep(d).await;
19731                        continue;
19732                    }
19733                    dlg.finished(false);
19734                    return Err(common::Error::HttpError(err));
19735                }
19736                Ok(res) => {
19737                    let (mut parts, body) = res.into_parts();
19738                    let mut body = common::Body::new(body);
19739                    if !parts.status.is_success() {
19740                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19741                        let error = serde_json::from_str(&common::to_string(&bytes));
19742                        let response = common::to_response(parts, bytes.into());
19743
19744                        if let common::Retry::After(d) =
19745                            dlg.http_failure(&response, error.as_ref().ok())
19746                        {
19747                            sleep(d).await;
19748                            continue;
19749                        }
19750
19751                        dlg.finished(false);
19752
19753                        return Err(match error {
19754                            Ok(value) => common::Error::BadRequest(value),
19755                            _ => common::Error::Failure(response),
19756                        });
19757                    }
19758                    let response = {
19759                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19760                        let encoded = common::to_string(&bytes);
19761                        match serde_json::from_str(&encoded) {
19762                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19763                            Err(error) => {
19764                                dlg.response_json_decode_error(&encoded, &error);
19765                                return Err(common::Error::JsonDecodeError(
19766                                    encoded.to_string(),
19767                                    error,
19768                                ));
19769                            }
19770                        }
19771                    };
19772
19773                    dlg.finished(true);
19774                    return Ok(response);
19775                }
19776            }
19777        }
19778    }
19779
19780    ///
19781    /// Sets the *request* property to the given value.
19782    ///
19783    /// Even though the property as already been set when instantiating this call,
19784    /// we provide this method for API completeness.
19785    pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, C> {
19786        self._request = new_value;
19787        self
19788    }
19789    /// User profile ID associated with this request.
19790    ///
19791    /// Sets the *profile id* path property to the given value.
19792    ///
19793    /// Even though the property as already been set when instantiating this call,
19794    /// we provide this method for API completeness.
19795    pub fn profile_id(mut self, new_value: i64) -> AccountUpdateCall<'a, C> {
19796        self._profile_id = new_value;
19797        self
19798    }
19799    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19800    /// while executing the actual API request.
19801    ///
19802    /// ````text
19803    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19804    /// ````
19805    ///
19806    /// Sets the *delegate* property to the given value.
19807    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountUpdateCall<'a, C> {
19808        self._delegate = Some(new_value);
19809        self
19810    }
19811
19812    /// Set any additional parameter of the query string used in the request.
19813    /// It should be used to set parameters which are not yet available through their own
19814    /// setters.
19815    ///
19816    /// Please note that this method must not be used to set any of the known parameters
19817    /// which have their own setter method. If done anyway, the request will fail.
19818    ///
19819    /// # Additional Parameters
19820    ///
19821    /// * *alt* (query-string) - Data format for the response.
19822    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19823    /// * *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.
19824    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19825    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19826    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
19827    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
19828    pub fn param<T>(mut self, name: T, value: T) -> AccountUpdateCall<'a, C>
19829    where
19830        T: AsRef<str>,
19831    {
19832        self._additional_params
19833            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19834        self
19835    }
19836
19837    /// Identifies the authorization scope for the method you are building.
19838    ///
19839    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19840    /// [`Scope::Dfatrafficking`].
19841    ///
19842    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19843    /// tokens for more than one scope.
19844    ///
19845    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19846    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19847    /// sufficient, a read-write scope will do as well.
19848    pub fn add_scope<St>(mut self, scope: St) -> AccountUpdateCall<'a, C>
19849    where
19850        St: AsRef<str>,
19851    {
19852        self._scopes.insert(String::from(scope.as_ref()));
19853        self
19854    }
19855    /// Identifies the authorization scope(s) for the method you are building.
19856    ///
19857    /// See [`Self::add_scope()`] for details.
19858    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUpdateCall<'a, C>
19859    where
19860        I: IntoIterator<Item = St>,
19861        St: AsRef<str>,
19862    {
19863        self._scopes
19864            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19865        self
19866    }
19867
19868    /// Removes all scopes, and no default scope will be used either.
19869    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19870    /// for details).
19871    pub fn clear_scopes(mut self) -> AccountUpdateCall<'a, C> {
19872        self._scopes.clear();
19873        self
19874    }
19875}
19876
19877/// Gets one ad by ID.
19878///
19879/// A builder for the *get* method supported by a *ad* resource.
19880/// It is not used directly, but through a [`AdMethods`] instance.
19881///
19882/// # Example
19883///
19884/// Instantiate a resource method builder
19885///
19886/// ```test_harness,no_run
19887/// # extern crate hyper;
19888/// # extern crate hyper_rustls;
19889/// # extern crate google_dfareporting3d2 as dfareporting3d2;
19890/// # async fn dox() {
19891/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19892///
19893/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19894/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19895/// #     secret,
19896/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19897/// # ).build().await.unwrap();
19898///
19899/// # let client = hyper_util::client::legacy::Client::builder(
19900/// #     hyper_util::rt::TokioExecutor::new()
19901/// # )
19902/// # .build(
19903/// #     hyper_rustls::HttpsConnectorBuilder::new()
19904/// #         .with_native_roots()
19905/// #         .unwrap()
19906/// #         .https_or_http()
19907/// #         .enable_http1()
19908/// #         .build()
19909/// # );
19910/// # let mut hub = Dfareporting::new(client, auth);
19911/// // You can configure optional parameters by calling the respective setters at will, and
19912/// // execute the final call using `doit()`.
19913/// // Values shown here are possibly random and not representative !
19914/// let result = hub.ads().get(-22, -95)
19915///              .doit().await;
19916/// # }
19917/// ```
19918pub struct AdGetCall<'a, C>
19919where
19920    C: 'a,
19921{
19922    hub: &'a Dfareporting<C>,
19923    _profile_id: i64,
19924    _id: i64,
19925    _delegate: Option<&'a mut dyn common::Delegate>,
19926    _additional_params: HashMap<String, String>,
19927    _scopes: BTreeSet<String>,
19928}
19929
19930impl<'a, C> common::CallBuilder for AdGetCall<'a, C> {}
19931
19932impl<'a, C> AdGetCall<'a, C>
19933where
19934    C: common::Connector,
19935{
19936    /// Perform the operation you have build so far.
19937    pub async fn doit(mut self) -> common::Result<(common::Response, Ad)> {
19938        use std::borrow::Cow;
19939        use std::io::{Read, Seek};
19940
19941        use common::{url::Params, ToParts};
19942        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19943
19944        let mut dd = common::DefaultDelegate;
19945        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19946        dlg.begin(common::MethodInfo {
19947            id: "dfareporting.ads.get",
19948            http_method: hyper::Method::GET,
19949        });
19950
19951        for &field in ["alt", "profileId", "id"].iter() {
19952            if self._additional_params.contains_key(field) {
19953                dlg.finished(false);
19954                return Err(common::Error::FieldClash(field));
19955            }
19956        }
19957
19958        let mut params = Params::with_capacity(4 + self._additional_params.len());
19959        params.push("profileId", self._profile_id.to_string());
19960        params.push("id", self._id.to_string());
19961
19962        params.extend(self._additional_params.iter());
19963
19964        params.push("alt", "json");
19965        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads/{id}";
19966        if self._scopes.is_empty() {
19967            self._scopes
19968                .insert(Scope::Dfatrafficking.as_ref().to_string());
19969        }
19970
19971        #[allow(clippy::single_element_loop)]
19972        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
19973            url = params.uri_replacement(url, param_name, find_this, false);
19974        }
19975        {
19976            let to_remove = ["id", "profileId"];
19977            params.remove_params(&to_remove);
19978        }
19979
19980        let url = params.parse_with_url(&url);
19981
19982        loop {
19983            let token = match self
19984                .hub
19985                .auth
19986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19987                .await
19988            {
19989                Ok(token) => token,
19990                Err(e) => match dlg.token(e) {
19991                    Ok(token) => token,
19992                    Err(e) => {
19993                        dlg.finished(false);
19994                        return Err(common::Error::MissingToken(e));
19995                    }
19996                },
19997            };
19998            let mut req_result = {
19999                let client = &self.hub.client;
20000                dlg.pre_request();
20001                let mut req_builder = hyper::Request::builder()
20002                    .method(hyper::Method::GET)
20003                    .uri(url.as_str())
20004                    .header(USER_AGENT, self.hub._user_agent.clone());
20005
20006                if let Some(token) = token.as_ref() {
20007                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20008                }
20009
20010                let request = req_builder
20011                    .header(CONTENT_LENGTH, 0_u64)
20012                    .body(common::to_body::<String>(None));
20013
20014                client.request(request.unwrap()).await
20015            };
20016
20017            match req_result {
20018                Err(err) => {
20019                    if let common::Retry::After(d) = dlg.http_error(&err) {
20020                        sleep(d).await;
20021                        continue;
20022                    }
20023                    dlg.finished(false);
20024                    return Err(common::Error::HttpError(err));
20025                }
20026                Ok(res) => {
20027                    let (mut parts, body) = res.into_parts();
20028                    let mut body = common::Body::new(body);
20029                    if !parts.status.is_success() {
20030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20031                        let error = serde_json::from_str(&common::to_string(&bytes));
20032                        let response = common::to_response(parts, bytes.into());
20033
20034                        if let common::Retry::After(d) =
20035                            dlg.http_failure(&response, error.as_ref().ok())
20036                        {
20037                            sleep(d).await;
20038                            continue;
20039                        }
20040
20041                        dlg.finished(false);
20042
20043                        return Err(match error {
20044                            Ok(value) => common::Error::BadRequest(value),
20045                            _ => common::Error::Failure(response),
20046                        });
20047                    }
20048                    let response = {
20049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20050                        let encoded = common::to_string(&bytes);
20051                        match serde_json::from_str(&encoded) {
20052                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20053                            Err(error) => {
20054                                dlg.response_json_decode_error(&encoded, &error);
20055                                return Err(common::Error::JsonDecodeError(
20056                                    encoded.to_string(),
20057                                    error,
20058                                ));
20059                            }
20060                        }
20061                    };
20062
20063                    dlg.finished(true);
20064                    return Ok(response);
20065                }
20066            }
20067        }
20068    }
20069
20070    /// User profile ID associated with this request.
20071    ///
20072    /// Sets the *profile id* path property to the given value.
20073    ///
20074    /// Even though the property as already been set when instantiating this call,
20075    /// we provide this method for API completeness.
20076    pub fn profile_id(mut self, new_value: i64) -> AdGetCall<'a, C> {
20077        self._profile_id = new_value;
20078        self
20079    }
20080    /// Ad ID.
20081    ///
20082    /// Sets the *id* path property to the given value.
20083    ///
20084    /// Even though the property as already been set when instantiating this call,
20085    /// we provide this method for API completeness.
20086    pub fn id(mut self, new_value: i64) -> AdGetCall<'a, C> {
20087        self._id = new_value;
20088        self
20089    }
20090    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20091    /// while executing the actual API request.
20092    ///
20093    /// ````text
20094    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20095    /// ````
20096    ///
20097    /// Sets the *delegate* property to the given value.
20098    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdGetCall<'a, C> {
20099        self._delegate = Some(new_value);
20100        self
20101    }
20102
20103    /// Set any additional parameter of the query string used in the request.
20104    /// It should be used to set parameters which are not yet available through their own
20105    /// setters.
20106    ///
20107    /// Please note that this method must not be used to set any of the known parameters
20108    /// which have their own setter method. If done anyway, the request will fail.
20109    ///
20110    /// # Additional Parameters
20111    ///
20112    /// * *alt* (query-string) - Data format for the response.
20113    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20114    /// * *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.
20115    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20116    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20117    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20118    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20119    pub fn param<T>(mut self, name: T, value: T) -> AdGetCall<'a, C>
20120    where
20121        T: AsRef<str>,
20122    {
20123        self._additional_params
20124            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20125        self
20126    }
20127
20128    /// Identifies the authorization scope for the method you are building.
20129    ///
20130    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20131    /// [`Scope::Dfatrafficking`].
20132    ///
20133    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20134    /// tokens for more than one scope.
20135    ///
20136    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20137    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20138    /// sufficient, a read-write scope will do as well.
20139    pub fn add_scope<St>(mut self, scope: St) -> AdGetCall<'a, C>
20140    where
20141        St: AsRef<str>,
20142    {
20143        self._scopes.insert(String::from(scope.as_ref()));
20144        self
20145    }
20146    /// Identifies the authorization scope(s) for the method you are building.
20147    ///
20148    /// See [`Self::add_scope()`] for details.
20149    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdGetCall<'a, C>
20150    where
20151        I: IntoIterator<Item = St>,
20152        St: AsRef<str>,
20153    {
20154        self._scopes
20155            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20156        self
20157    }
20158
20159    /// Removes all scopes, and no default scope will be used either.
20160    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20161    /// for details).
20162    pub fn clear_scopes(mut self) -> AdGetCall<'a, C> {
20163        self._scopes.clear();
20164        self
20165    }
20166}
20167
20168/// Inserts a new ad.
20169///
20170/// A builder for the *insert* method supported by a *ad* resource.
20171/// It is not used directly, but through a [`AdMethods`] instance.
20172///
20173/// # Example
20174///
20175/// Instantiate a resource method builder
20176///
20177/// ```test_harness,no_run
20178/// # extern crate hyper;
20179/// # extern crate hyper_rustls;
20180/// # extern crate google_dfareporting3d2 as dfareporting3d2;
20181/// use dfareporting3d2::api::Ad;
20182/// # async fn dox() {
20183/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20184///
20185/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20186/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20187/// #     secret,
20188/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20189/// # ).build().await.unwrap();
20190///
20191/// # let client = hyper_util::client::legacy::Client::builder(
20192/// #     hyper_util::rt::TokioExecutor::new()
20193/// # )
20194/// # .build(
20195/// #     hyper_rustls::HttpsConnectorBuilder::new()
20196/// #         .with_native_roots()
20197/// #         .unwrap()
20198/// #         .https_or_http()
20199/// #         .enable_http1()
20200/// #         .build()
20201/// # );
20202/// # let mut hub = Dfareporting::new(client, auth);
20203/// // As the method needs a request, you would usually fill it with the desired information
20204/// // into the respective structure. Some of the parts shown here might not be applicable !
20205/// // Values shown here are possibly random and not representative !
20206/// let mut req = Ad::default();
20207///
20208/// // You can configure optional parameters by calling the respective setters at will, and
20209/// // execute the final call using `doit()`.
20210/// // Values shown here are possibly random and not representative !
20211/// let result = hub.ads().insert(req, -15)
20212///              .doit().await;
20213/// # }
20214/// ```
20215pub struct AdInsertCall<'a, C>
20216where
20217    C: 'a,
20218{
20219    hub: &'a Dfareporting<C>,
20220    _request: Ad,
20221    _profile_id: i64,
20222    _delegate: Option<&'a mut dyn common::Delegate>,
20223    _additional_params: HashMap<String, String>,
20224    _scopes: BTreeSet<String>,
20225}
20226
20227impl<'a, C> common::CallBuilder for AdInsertCall<'a, C> {}
20228
20229impl<'a, C> AdInsertCall<'a, C>
20230where
20231    C: common::Connector,
20232{
20233    /// Perform the operation you have build so far.
20234    pub async fn doit(mut self) -> common::Result<(common::Response, Ad)> {
20235        use std::borrow::Cow;
20236        use std::io::{Read, Seek};
20237
20238        use common::{url::Params, ToParts};
20239        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20240
20241        let mut dd = common::DefaultDelegate;
20242        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20243        dlg.begin(common::MethodInfo {
20244            id: "dfareporting.ads.insert",
20245            http_method: hyper::Method::POST,
20246        });
20247
20248        for &field in ["alt", "profileId"].iter() {
20249            if self._additional_params.contains_key(field) {
20250                dlg.finished(false);
20251                return Err(common::Error::FieldClash(field));
20252            }
20253        }
20254
20255        let mut params = Params::with_capacity(4 + self._additional_params.len());
20256        params.push("profileId", self._profile_id.to_string());
20257
20258        params.extend(self._additional_params.iter());
20259
20260        params.push("alt", "json");
20261        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads";
20262        if self._scopes.is_empty() {
20263            self._scopes
20264                .insert(Scope::Dfatrafficking.as_ref().to_string());
20265        }
20266
20267        #[allow(clippy::single_element_loop)]
20268        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
20269            url = params.uri_replacement(url, param_name, find_this, false);
20270        }
20271        {
20272            let to_remove = ["profileId"];
20273            params.remove_params(&to_remove);
20274        }
20275
20276        let url = params.parse_with_url(&url);
20277
20278        let mut json_mime_type = mime::APPLICATION_JSON;
20279        let mut request_value_reader = {
20280            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20281            common::remove_json_null_values(&mut value);
20282            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20283            serde_json::to_writer(&mut dst, &value).unwrap();
20284            dst
20285        };
20286        let request_size = request_value_reader
20287            .seek(std::io::SeekFrom::End(0))
20288            .unwrap();
20289        request_value_reader
20290            .seek(std::io::SeekFrom::Start(0))
20291            .unwrap();
20292
20293        loop {
20294            let token = match self
20295                .hub
20296                .auth
20297                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20298                .await
20299            {
20300                Ok(token) => token,
20301                Err(e) => match dlg.token(e) {
20302                    Ok(token) => token,
20303                    Err(e) => {
20304                        dlg.finished(false);
20305                        return Err(common::Error::MissingToken(e));
20306                    }
20307                },
20308            };
20309            request_value_reader
20310                .seek(std::io::SeekFrom::Start(0))
20311                .unwrap();
20312            let mut req_result = {
20313                let client = &self.hub.client;
20314                dlg.pre_request();
20315                let mut req_builder = hyper::Request::builder()
20316                    .method(hyper::Method::POST)
20317                    .uri(url.as_str())
20318                    .header(USER_AGENT, self.hub._user_agent.clone());
20319
20320                if let Some(token) = token.as_ref() {
20321                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20322                }
20323
20324                let request = req_builder
20325                    .header(CONTENT_TYPE, json_mime_type.to_string())
20326                    .header(CONTENT_LENGTH, request_size as u64)
20327                    .body(common::to_body(
20328                        request_value_reader.get_ref().clone().into(),
20329                    ));
20330
20331                client.request(request.unwrap()).await
20332            };
20333
20334            match req_result {
20335                Err(err) => {
20336                    if let common::Retry::After(d) = dlg.http_error(&err) {
20337                        sleep(d).await;
20338                        continue;
20339                    }
20340                    dlg.finished(false);
20341                    return Err(common::Error::HttpError(err));
20342                }
20343                Ok(res) => {
20344                    let (mut parts, body) = res.into_parts();
20345                    let mut body = common::Body::new(body);
20346                    if !parts.status.is_success() {
20347                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20348                        let error = serde_json::from_str(&common::to_string(&bytes));
20349                        let response = common::to_response(parts, bytes.into());
20350
20351                        if let common::Retry::After(d) =
20352                            dlg.http_failure(&response, error.as_ref().ok())
20353                        {
20354                            sleep(d).await;
20355                            continue;
20356                        }
20357
20358                        dlg.finished(false);
20359
20360                        return Err(match error {
20361                            Ok(value) => common::Error::BadRequest(value),
20362                            _ => common::Error::Failure(response),
20363                        });
20364                    }
20365                    let response = {
20366                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20367                        let encoded = common::to_string(&bytes);
20368                        match serde_json::from_str(&encoded) {
20369                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20370                            Err(error) => {
20371                                dlg.response_json_decode_error(&encoded, &error);
20372                                return Err(common::Error::JsonDecodeError(
20373                                    encoded.to_string(),
20374                                    error,
20375                                ));
20376                            }
20377                        }
20378                    };
20379
20380                    dlg.finished(true);
20381                    return Ok(response);
20382                }
20383            }
20384        }
20385    }
20386
20387    ///
20388    /// Sets the *request* property to the given value.
20389    ///
20390    /// Even though the property as already been set when instantiating this call,
20391    /// we provide this method for API completeness.
20392    pub fn request(mut self, new_value: Ad) -> AdInsertCall<'a, C> {
20393        self._request = new_value;
20394        self
20395    }
20396    /// User profile ID associated with this request.
20397    ///
20398    /// Sets the *profile id* path property to the given value.
20399    ///
20400    /// Even though the property as already been set when instantiating this call,
20401    /// we provide this method for API completeness.
20402    pub fn profile_id(mut self, new_value: i64) -> AdInsertCall<'a, C> {
20403        self._profile_id = new_value;
20404        self
20405    }
20406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20407    /// while executing the actual API request.
20408    ///
20409    /// ````text
20410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20411    /// ````
20412    ///
20413    /// Sets the *delegate* property to the given value.
20414    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdInsertCall<'a, C> {
20415        self._delegate = Some(new_value);
20416        self
20417    }
20418
20419    /// Set any additional parameter of the query string used in the request.
20420    /// It should be used to set parameters which are not yet available through their own
20421    /// setters.
20422    ///
20423    /// Please note that this method must not be used to set any of the known parameters
20424    /// which have their own setter method. If done anyway, the request will fail.
20425    ///
20426    /// # Additional Parameters
20427    ///
20428    /// * *alt* (query-string) - Data format for the response.
20429    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20430    /// * *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.
20431    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20432    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20433    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
20434    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
20435    pub fn param<T>(mut self, name: T, value: T) -> AdInsertCall<'a, C>
20436    where
20437        T: AsRef<str>,
20438    {
20439        self._additional_params
20440            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20441        self
20442    }
20443
20444    /// Identifies the authorization scope for the method you are building.
20445    ///
20446    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20447    /// [`Scope::Dfatrafficking`].
20448    ///
20449    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20450    /// tokens for more than one scope.
20451    ///
20452    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20453    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20454    /// sufficient, a read-write scope will do as well.
20455    pub fn add_scope<St>(mut self, scope: St) -> AdInsertCall<'a, C>
20456    where
20457        St: AsRef<str>,
20458    {
20459        self._scopes.insert(String::from(scope.as_ref()));
20460        self
20461    }
20462    /// Identifies the authorization scope(s) for the method you are building.
20463    ///
20464    /// See [`Self::add_scope()`] for details.
20465    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdInsertCall<'a, C>
20466    where
20467        I: IntoIterator<Item = St>,
20468        St: AsRef<str>,
20469    {
20470        self._scopes
20471            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20472        self
20473    }
20474
20475    /// Removes all scopes, and no default scope will be used either.
20476    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20477    /// for details).
20478    pub fn clear_scopes(mut self) -> AdInsertCall<'a, C> {
20479        self._scopes.clear();
20480        self
20481    }
20482}
20483
20484/// Retrieves a list of ads, possibly filtered. This method supports paging.
20485///
20486/// A builder for the *list* method supported by a *ad* resource.
20487/// It is not used directly, but through a [`AdMethods`] instance.
20488///
20489/// # Example
20490///
20491/// Instantiate a resource method builder
20492///
20493/// ```test_harness,no_run
20494/// # extern crate hyper;
20495/// # extern crate hyper_rustls;
20496/// # extern crate google_dfareporting3d2 as dfareporting3d2;
20497/// # async fn dox() {
20498/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20499///
20500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20501/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20502/// #     secret,
20503/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20504/// # ).build().await.unwrap();
20505///
20506/// # let client = hyper_util::client::legacy::Client::builder(
20507/// #     hyper_util::rt::TokioExecutor::new()
20508/// # )
20509/// # .build(
20510/// #     hyper_rustls::HttpsConnectorBuilder::new()
20511/// #         .with_native_roots()
20512/// #         .unwrap()
20513/// #         .https_or_http()
20514/// #         .enable_http1()
20515/// #         .build()
20516/// # );
20517/// # let mut hub = Dfareporting::new(client, auth);
20518/// // You can configure optional parameters by calling the respective setters at will, and
20519/// // execute the final call using `doit()`.
20520/// // Values shown here are possibly random and not representative !
20521/// let result = hub.ads().list(-99)
20522///              .add_type("duo")
20523///              .ssl_required(false)
20524///              .ssl_compliant(false)
20525///              .sort_order("invidunt")
20526///              .sort_field("Stet")
20527///              .add_size_ids(-76)
20528///              .search_string("elitr")
20529///              .add_remarketing_list_ids(-6)
20530///              .add_placement_ids(-29)
20531///              .page_token("no")
20532///              .overridden_event_tag_id(-100)
20533///              .max_results(-23)
20534///              .add_landing_page_ids(-59)
20535///              .add_ids(-46)
20536///              .dynamic_click_tracker(false)
20537///              .add_creative_optimization_configuration_ids(-31)
20538///              .add_creative_ids(-96)
20539///              .compatibility("amet.")
20540///              .add_campaign_ids(-30)
20541///              .add_audience_segment_ids(-9)
20542///              .archived(true)
20543///              .advertiser_id(-74)
20544///              .active(false)
20545///              .doit().await;
20546/// # }
20547/// ```
20548pub struct AdListCall<'a, C>
20549where
20550    C: 'a,
20551{
20552    hub: &'a Dfareporting<C>,
20553    _profile_id: i64,
20554    _type_: Vec<String>,
20555    _ssl_required: Option<bool>,
20556    _ssl_compliant: Option<bool>,
20557    _sort_order: Option<String>,
20558    _sort_field: Option<String>,
20559    _size_ids: Vec<i64>,
20560    _search_string: Option<String>,
20561    _remarketing_list_ids: Vec<i64>,
20562    _placement_ids: Vec<i64>,
20563    _page_token: Option<String>,
20564    _overridden_event_tag_id: Option<i64>,
20565    _max_results: Option<i32>,
20566    _landing_page_ids: Vec<i64>,
20567    _ids: Vec<i64>,
20568    _dynamic_click_tracker: Option<bool>,
20569    _creative_optimization_configuration_ids: Vec<i64>,
20570    _creative_ids: Vec<i64>,
20571    _compatibility: Option<String>,
20572    _campaign_ids: Vec<i64>,
20573    _audience_segment_ids: Vec<i64>,
20574    _archived: Option<bool>,
20575    _advertiser_id: Option<i64>,
20576    _active: Option<bool>,
20577    _delegate: Option<&'a mut dyn common::Delegate>,
20578    _additional_params: HashMap<String, String>,
20579    _scopes: BTreeSet<String>,
20580}
20581
20582impl<'a, C> common::CallBuilder for AdListCall<'a, C> {}
20583
20584impl<'a, C> AdListCall<'a, C>
20585where
20586    C: common::Connector,
20587{
20588    /// Perform the operation you have build so far.
20589    pub async fn doit(mut self) -> common::Result<(common::Response, AdsListResponse)> {
20590        use std::borrow::Cow;
20591        use std::io::{Read, Seek};
20592
20593        use common::{url::Params, ToParts};
20594        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20595
20596        let mut dd = common::DefaultDelegate;
20597        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20598        dlg.begin(common::MethodInfo {
20599            id: "dfareporting.ads.list",
20600            http_method: hyper::Method::GET,
20601        });
20602
20603        for &field in [
20604            "alt",
20605            "profileId",
20606            "type",
20607            "sslRequired",
20608            "sslCompliant",
20609            "sortOrder",
20610            "sortField",
20611            "sizeIds",
20612            "searchString",
20613            "remarketingListIds",
20614            "placementIds",
20615            "pageToken",
20616            "overriddenEventTagId",
20617            "maxResults",
20618            "landingPageIds",
20619            "ids",
20620            "dynamicClickTracker",
20621            "creativeOptimizationConfigurationIds",
20622            "creativeIds",
20623            "compatibility",
20624            "campaignIds",
20625            "audienceSegmentIds",
20626            "archived",
20627            "advertiserId",
20628            "active",
20629        ]
20630        .iter()
20631        {
20632            if self._additional_params.contains_key(field) {
20633                dlg.finished(false);
20634                return Err(common::Error::FieldClash(field));
20635            }
20636        }
20637
20638        let mut params = Params::with_capacity(26 + self._additional_params.len());
20639        params.push("profileId", self._profile_id.to_string());
20640        if !self._type_.is_empty() {
20641            for f in self._type_.iter() {
20642                params.push("type", f);
20643            }
20644        }
20645        if let Some(value) = self._ssl_required.as_ref() {
20646            params.push("sslRequired", value.to_string());
20647        }
20648        if let Some(value) = self._ssl_compliant.as_ref() {
20649            params.push("sslCompliant", value.to_string());
20650        }
20651        if let Some(value) = self._sort_order.as_ref() {
20652            params.push("sortOrder", value);
20653        }
20654        if let Some(value) = self._sort_field.as_ref() {
20655            params.push("sortField", value);
20656        }
20657        if !self._size_ids.is_empty() {
20658            for f in self._size_ids.iter() {
20659                params.push("sizeIds", f.to_string());
20660            }
20661        }
20662        if let Some(value) = self._search_string.as_ref() {
20663            params.push("searchString", value);
20664        }
20665        if !self._remarketing_list_ids.is_empty() {
20666            for f in self._remarketing_list_ids.iter() {
20667                params.push("remarketingListIds", f.to_string());
20668            }
20669        }
20670        if !self._placement_ids.is_empty() {
20671            for f in self._placement_ids.iter() {
20672                params.push("placementIds", f.to_string());
20673            }
20674        }
20675        if let Some(value) = self._page_token.as_ref() {
20676            params.push("pageToken", value);
20677        }
20678        if let Some(value) = self._overridden_event_tag_id.as_ref() {
20679            params.push("overriddenEventTagId", value.to_string());
20680        }
20681        if let Some(value) = self._max_results.as_ref() {
20682            params.push("maxResults", value.to_string());
20683        }
20684        if !self._landing_page_ids.is_empty() {
20685            for f in self._landing_page_ids.iter() {
20686                params.push("landingPageIds", f.to_string());
20687            }
20688        }
20689        if !self._ids.is_empty() {
20690            for f in self._ids.iter() {
20691                params.push("ids", f.to_string());
20692            }
20693        }
20694        if let Some(value) = self._dynamic_click_tracker.as_ref() {
20695            params.push("dynamicClickTracker", value.to_string());
20696        }
20697        if !self._creative_optimization_configuration_ids.is_empty() {
20698            for f in self._creative_optimization_configuration_ids.iter() {
20699                params.push("creativeOptimizationConfigurationIds", f.to_string());
20700            }
20701        }
20702        if !self._creative_ids.is_empty() {
20703            for f in self._creative_ids.iter() {
20704                params.push("creativeIds", f.to_string());
20705            }
20706        }
20707        if let Some(value) = self._compatibility.as_ref() {
20708            params.push("compatibility", value);
20709        }
20710        if !self._campaign_ids.is_empty() {
20711            for f in self._campaign_ids.iter() {
20712                params.push("campaignIds", f.to_string());
20713            }
20714        }
20715        if !self._audience_segment_ids.is_empty() {
20716            for f in self._audience_segment_ids.iter() {
20717                params.push("audienceSegmentIds", f.to_string());
20718            }
20719        }
20720        if let Some(value) = self._archived.as_ref() {
20721            params.push("archived", value.to_string());
20722        }
20723        if let Some(value) = self._advertiser_id.as_ref() {
20724            params.push("advertiserId", value.to_string());
20725        }
20726        if let Some(value) = self._active.as_ref() {
20727            params.push("active", value.to_string());
20728        }
20729
20730        params.extend(self._additional_params.iter());
20731
20732        params.push("alt", "json");
20733        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads";
20734        if self._scopes.is_empty() {
20735            self._scopes
20736                .insert(Scope::Dfatrafficking.as_ref().to_string());
20737        }
20738
20739        #[allow(clippy::single_element_loop)]
20740        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
20741            url = params.uri_replacement(url, param_name, find_this, false);
20742        }
20743        {
20744            let to_remove = ["profileId"];
20745            params.remove_params(&to_remove);
20746        }
20747
20748        let url = params.parse_with_url(&url);
20749
20750        loop {
20751            let token = match self
20752                .hub
20753                .auth
20754                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20755                .await
20756            {
20757                Ok(token) => token,
20758                Err(e) => match dlg.token(e) {
20759                    Ok(token) => token,
20760                    Err(e) => {
20761                        dlg.finished(false);
20762                        return Err(common::Error::MissingToken(e));
20763                    }
20764                },
20765            };
20766            let mut req_result = {
20767                let client = &self.hub.client;
20768                dlg.pre_request();
20769                let mut req_builder = hyper::Request::builder()
20770                    .method(hyper::Method::GET)
20771                    .uri(url.as_str())
20772                    .header(USER_AGENT, self.hub._user_agent.clone());
20773
20774                if let Some(token) = token.as_ref() {
20775                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20776                }
20777
20778                let request = req_builder
20779                    .header(CONTENT_LENGTH, 0_u64)
20780                    .body(common::to_body::<String>(None));
20781
20782                client.request(request.unwrap()).await
20783            };
20784
20785            match req_result {
20786                Err(err) => {
20787                    if let common::Retry::After(d) = dlg.http_error(&err) {
20788                        sleep(d).await;
20789                        continue;
20790                    }
20791                    dlg.finished(false);
20792                    return Err(common::Error::HttpError(err));
20793                }
20794                Ok(res) => {
20795                    let (mut parts, body) = res.into_parts();
20796                    let mut body = common::Body::new(body);
20797                    if !parts.status.is_success() {
20798                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20799                        let error = serde_json::from_str(&common::to_string(&bytes));
20800                        let response = common::to_response(parts, bytes.into());
20801
20802                        if let common::Retry::After(d) =
20803                            dlg.http_failure(&response, error.as_ref().ok())
20804                        {
20805                            sleep(d).await;
20806                            continue;
20807                        }
20808
20809                        dlg.finished(false);
20810
20811                        return Err(match error {
20812                            Ok(value) => common::Error::BadRequest(value),
20813                            _ => common::Error::Failure(response),
20814                        });
20815                    }
20816                    let response = {
20817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20818                        let encoded = common::to_string(&bytes);
20819                        match serde_json::from_str(&encoded) {
20820                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20821                            Err(error) => {
20822                                dlg.response_json_decode_error(&encoded, &error);
20823                                return Err(common::Error::JsonDecodeError(
20824                                    encoded.to_string(),
20825                                    error,
20826                                ));
20827                            }
20828                        }
20829                    };
20830
20831                    dlg.finished(true);
20832                    return Ok(response);
20833                }
20834            }
20835        }
20836    }
20837
20838    /// User profile ID associated with this request.
20839    ///
20840    /// Sets the *profile id* path property to the given value.
20841    ///
20842    /// Even though the property as already been set when instantiating this call,
20843    /// we provide this method for API completeness.
20844    pub fn profile_id(mut self, new_value: i64) -> AdListCall<'a, C> {
20845        self._profile_id = new_value;
20846        self
20847    }
20848    /// Select only ads with these types.
20849    ///
20850    /// Append the given value to the *type* query property.
20851    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20852    pub fn add_type(mut self, new_value: &str) -> AdListCall<'a, C> {
20853        self._type_.push(new_value.to_string());
20854        self
20855    }
20856    /// Select only ads that require SSL.
20857    ///
20858    /// Sets the *ssl required* query property to the given value.
20859    pub fn ssl_required(mut self, new_value: bool) -> AdListCall<'a, C> {
20860        self._ssl_required = Some(new_value);
20861        self
20862    }
20863    /// Select only ads that are SSL-compliant.
20864    ///
20865    /// Sets the *ssl compliant* query property to the given value.
20866    pub fn ssl_compliant(mut self, new_value: bool) -> AdListCall<'a, C> {
20867        self._ssl_compliant = Some(new_value);
20868        self
20869    }
20870    /// Order of sorted results.
20871    ///
20872    /// Sets the *sort order* query property to the given value.
20873    pub fn sort_order(mut self, new_value: &str) -> AdListCall<'a, C> {
20874        self._sort_order = Some(new_value.to_string());
20875        self
20876    }
20877    /// Field by which to sort the list.
20878    ///
20879    /// Sets the *sort field* query property to the given value.
20880    pub fn sort_field(mut self, new_value: &str) -> AdListCall<'a, C> {
20881        self._sort_field = Some(new_value.to_string());
20882        self
20883    }
20884    /// Select only ads with these size IDs.
20885    ///
20886    /// Append the given value to the *size ids* query property.
20887    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20888    pub fn add_size_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20889        self._size_ids.push(new_value);
20890        self
20891    }
20892    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "ad*2015" will return objects with names like "ad June 2015", "ad April 2015", or simply "ad 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "ad" will match objects with name "my ad", "ad 2015", or simply "ad".
20893    ///
20894    /// Sets the *search string* query property to the given value.
20895    pub fn search_string(mut self, new_value: &str) -> AdListCall<'a, C> {
20896        self._search_string = Some(new_value.to_string());
20897        self
20898    }
20899    /// Select only ads whose list targeting expression use these remarketing list IDs.
20900    ///
20901    /// Append the given value to the *remarketing list ids* query property.
20902    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20903    pub fn add_remarketing_list_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20904        self._remarketing_list_ids.push(new_value);
20905        self
20906    }
20907    /// Select only ads with these placement IDs assigned.
20908    ///
20909    /// Append the given value to the *placement ids* query property.
20910    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20911    pub fn add_placement_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20912        self._placement_ids.push(new_value);
20913        self
20914    }
20915    /// Value of the nextPageToken from the previous result page.
20916    ///
20917    /// Sets the *page token* query property to the given value.
20918    pub fn page_token(mut self, new_value: &str) -> AdListCall<'a, C> {
20919        self._page_token = Some(new_value.to_string());
20920        self
20921    }
20922    /// Select only ads with this event tag override ID.
20923    ///
20924    /// Sets the *overridden event tag id* query property to the given value.
20925    pub fn overridden_event_tag_id(mut self, new_value: i64) -> AdListCall<'a, C> {
20926        self._overridden_event_tag_id = Some(new_value);
20927        self
20928    }
20929    /// Maximum number of results to return.
20930    ///
20931    /// Sets the *max results* query property to the given value.
20932    pub fn max_results(mut self, new_value: i32) -> AdListCall<'a, C> {
20933        self._max_results = Some(new_value);
20934        self
20935    }
20936    /// Select only ads with these landing page IDs.
20937    ///
20938    /// Append the given value to the *landing page ids* query property.
20939    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20940    pub fn add_landing_page_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20941        self._landing_page_ids.push(new_value);
20942        self
20943    }
20944    /// Select only ads with these IDs.
20945    ///
20946    /// Append the given value to the *ids* query property.
20947    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20948    pub fn add_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20949        self._ids.push(new_value);
20950        self
20951    }
20952    /// Select only dynamic click trackers. Applicable when type is AD_SERVING_CLICK_TRACKER. If true, select dynamic click trackers. If false, select static click trackers. Leave unset to select both.
20953    ///
20954    /// Sets the *dynamic click tracker* query property to the given value.
20955    pub fn dynamic_click_tracker(mut self, new_value: bool) -> AdListCall<'a, C> {
20956        self._dynamic_click_tracker = Some(new_value);
20957        self
20958    }
20959    /// Select only ads with these creative optimization configuration IDs.
20960    ///
20961    /// Append the given value to the *creative optimization configuration ids* query property.
20962    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20963    pub fn add_creative_optimization_configuration_ids(
20964        mut self,
20965        new_value: i64,
20966    ) -> AdListCall<'a, C> {
20967        self._creative_optimization_configuration_ids
20968            .push(new_value);
20969        self
20970    }
20971    /// Select only ads with these creative IDs assigned.
20972    ///
20973    /// Append the given value to the *creative ids* query property.
20974    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20975    pub fn add_creative_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20976        self._creative_ids.push(new_value);
20977        self
20978    }
20979    /// Select default ads with the specified compatibility. Applicable when type is AD_SERVING_DEFAULT_AD. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads, respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering an in-stream video ads developed with the VAST standard.
20980    ///
20981    /// Sets the *compatibility* query property to the given value.
20982    pub fn compatibility(mut self, new_value: &str) -> AdListCall<'a, C> {
20983        self._compatibility = Some(new_value.to_string());
20984        self
20985    }
20986    /// Select only ads with these campaign IDs.
20987    ///
20988    /// Append the given value to the *campaign ids* query property.
20989    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20990    pub fn add_campaign_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20991        self._campaign_ids.push(new_value);
20992        self
20993    }
20994    /// Select only ads with these audience segment IDs.
20995    ///
20996    /// Append the given value to the *audience segment ids* query property.
20997    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
20998    pub fn add_audience_segment_ids(mut self, new_value: i64) -> AdListCall<'a, C> {
20999        self._audience_segment_ids.push(new_value);
21000        self
21001    }
21002    /// Select only archived ads.
21003    ///
21004    /// Sets the *archived* query property to the given value.
21005    pub fn archived(mut self, new_value: bool) -> AdListCall<'a, C> {
21006        self._archived = Some(new_value);
21007        self
21008    }
21009    /// Select only ads with this advertiser ID.
21010    ///
21011    /// Sets the *advertiser id* query property to the given value.
21012    pub fn advertiser_id(mut self, new_value: i64) -> AdListCall<'a, C> {
21013        self._advertiser_id = Some(new_value);
21014        self
21015    }
21016    /// Select only active ads.
21017    ///
21018    /// Sets the *active* query property to the given value.
21019    pub fn active(mut self, new_value: bool) -> AdListCall<'a, C> {
21020        self._active = Some(new_value);
21021        self
21022    }
21023    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21024    /// while executing the actual API request.
21025    ///
21026    /// ````text
21027    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21028    /// ````
21029    ///
21030    /// Sets the *delegate* property to the given value.
21031    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdListCall<'a, C> {
21032        self._delegate = Some(new_value);
21033        self
21034    }
21035
21036    /// Set any additional parameter of the query string used in the request.
21037    /// It should be used to set parameters which are not yet available through their own
21038    /// setters.
21039    ///
21040    /// Please note that this method must not be used to set any of the known parameters
21041    /// which have their own setter method. If done anyway, the request will fail.
21042    ///
21043    /// # Additional Parameters
21044    ///
21045    /// * *alt* (query-string) - Data format for the response.
21046    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21047    /// * *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.
21048    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21049    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21050    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21051    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21052    pub fn param<T>(mut self, name: T, value: T) -> AdListCall<'a, C>
21053    where
21054        T: AsRef<str>,
21055    {
21056        self._additional_params
21057            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21058        self
21059    }
21060
21061    /// Identifies the authorization scope for the method you are building.
21062    ///
21063    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21064    /// [`Scope::Dfatrafficking`].
21065    ///
21066    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21067    /// tokens for more than one scope.
21068    ///
21069    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21070    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21071    /// sufficient, a read-write scope will do as well.
21072    pub fn add_scope<St>(mut self, scope: St) -> AdListCall<'a, C>
21073    where
21074        St: AsRef<str>,
21075    {
21076        self._scopes.insert(String::from(scope.as_ref()));
21077        self
21078    }
21079    /// Identifies the authorization scope(s) for the method you are building.
21080    ///
21081    /// See [`Self::add_scope()`] for details.
21082    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdListCall<'a, C>
21083    where
21084        I: IntoIterator<Item = St>,
21085        St: AsRef<str>,
21086    {
21087        self._scopes
21088            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21089        self
21090    }
21091
21092    /// Removes all scopes, and no default scope will be used either.
21093    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21094    /// for details).
21095    pub fn clear_scopes(mut self) -> AdListCall<'a, C> {
21096        self._scopes.clear();
21097        self
21098    }
21099}
21100
21101/// Updates an existing ad. This method supports patch semantics.
21102///
21103/// A builder for the *patch* method supported by a *ad* resource.
21104/// It is not used directly, but through a [`AdMethods`] instance.
21105///
21106/// # Example
21107///
21108/// Instantiate a resource method builder
21109///
21110/// ```test_harness,no_run
21111/// # extern crate hyper;
21112/// # extern crate hyper_rustls;
21113/// # extern crate google_dfareporting3d2 as dfareporting3d2;
21114/// use dfareporting3d2::api::Ad;
21115/// # async fn dox() {
21116/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21117///
21118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21120/// #     secret,
21121/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21122/// # ).build().await.unwrap();
21123///
21124/// # let client = hyper_util::client::legacy::Client::builder(
21125/// #     hyper_util::rt::TokioExecutor::new()
21126/// # )
21127/// # .build(
21128/// #     hyper_rustls::HttpsConnectorBuilder::new()
21129/// #         .with_native_roots()
21130/// #         .unwrap()
21131/// #         .https_or_http()
21132/// #         .enable_http1()
21133/// #         .build()
21134/// # );
21135/// # let mut hub = Dfareporting::new(client, auth);
21136/// // As the method needs a request, you would usually fill it with the desired information
21137/// // into the respective structure. Some of the parts shown here might not be applicable !
21138/// // Values shown here are possibly random and not representative !
21139/// let mut req = Ad::default();
21140///
21141/// // You can configure optional parameters by calling the respective setters at will, and
21142/// // execute the final call using `doit()`.
21143/// // Values shown here are possibly random and not representative !
21144/// let result = hub.ads().patch(req, -34, -34)
21145///              .doit().await;
21146/// # }
21147/// ```
21148pub struct AdPatchCall<'a, C>
21149where
21150    C: 'a,
21151{
21152    hub: &'a Dfareporting<C>,
21153    _request: Ad,
21154    _profile_id: i64,
21155    _id: i64,
21156    _delegate: Option<&'a mut dyn common::Delegate>,
21157    _additional_params: HashMap<String, String>,
21158    _scopes: BTreeSet<String>,
21159}
21160
21161impl<'a, C> common::CallBuilder for AdPatchCall<'a, C> {}
21162
21163impl<'a, C> AdPatchCall<'a, C>
21164where
21165    C: common::Connector,
21166{
21167    /// Perform the operation you have build so far.
21168    pub async fn doit(mut self) -> common::Result<(common::Response, Ad)> {
21169        use std::borrow::Cow;
21170        use std::io::{Read, Seek};
21171
21172        use common::{url::Params, ToParts};
21173        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21174
21175        let mut dd = common::DefaultDelegate;
21176        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21177        dlg.begin(common::MethodInfo {
21178            id: "dfareporting.ads.patch",
21179            http_method: hyper::Method::PATCH,
21180        });
21181
21182        for &field in ["alt", "profileId", "id"].iter() {
21183            if self._additional_params.contains_key(field) {
21184                dlg.finished(false);
21185                return Err(common::Error::FieldClash(field));
21186            }
21187        }
21188
21189        let mut params = Params::with_capacity(5 + self._additional_params.len());
21190        params.push("profileId", self._profile_id.to_string());
21191        params.push("id", self._id.to_string());
21192
21193        params.extend(self._additional_params.iter());
21194
21195        params.push("alt", "json");
21196        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads";
21197        if self._scopes.is_empty() {
21198            self._scopes
21199                .insert(Scope::Dfatrafficking.as_ref().to_string());
21200        }
21201
21202        #[allow(clippy::single_element_loop)]
21203        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
21204            url = params.uri_replacement(url, param_name, find_this, false);
21205        }
21206        {
21207            let to_remove = ["profileId"];
21208            params.remove_params(&to_remove);
21209        }
21210
21211        let url = params.parse_with_url(&url);
21212
21213        let mut json_mime_type = mime::APPLICATION_JSON;
21214        let mut request_value_reader = {
21215            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21216            common::remove_json_null_values(&mut value);
21217            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21218            serde_json::to_writer(&mut dst, &value).unwrap();
21219            dst
21220        };
21221        let request_size = request_value_reader
21222            .seek(std::io::SeekFrom::End(0))
21223            .unwrap();
21224        request_value_reader
21225            .seek(std::io::SeekFrom::Start(0))
21226            .unwrap();
21227
21228        loop {
21229            let token = match self
21230                .hub
21231                .auth
21232                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21233                .await
21234            {
21235                Ok(token) => token,
21236                Err(e) => match dlg.token(e) {
21237                    Ok(token) => token,
21238                    Err(e) => {
21239                        dlg.finished(false);
21240                        return Err(common::Error::MissingToken(e));
21241                    }
21242                },
21243            };
21244            request_value_reader
21245                .seek(std::io::SeekFrom::Start(0))
21246                .unwrap();
21247            let mut req_result = {
21248                let client = &self.hub.client;
21249                dlg.pre_request();
21250                let mut req_builder = hyper::Request::builder()
21251                    .method(hyper::Method::PATCH)
21252                    .uri(url.as_str())
21253                    .header(USER_AGENT, self.hub._user_agent.clone());
21254
21255                if let Some(token) = token.as_ref() {
21256                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21257                }
21258
21259                let request = req_builder
21260                    .header(CONTENT_TYPE, json_mime_type.to_string())
21261                    .header(CONTENT_LENGTH, request_size as u64)
21262                    .body(common::to_body(
21263                        request_value_reader.get_ref().clone().into(),
21264                    ));
21265
21266                client.request(request.unwrap()).await
21267            };
21268
21269            match req_result {
21270                Err(err) => {
21271                    if let common::Retry::After(d) = dlg.http_error(&err) {
21272                        sleep(d).await;
21273                        continue;
21274                    }
21275                    dlg.finished(false);
21276                    return Err(common::Error::HttpError(err));
21277                }
21278                Ok(res) => {
21279                    let (mut parts, body) = res.into_parts();
21280                    let mut body = common::Body::new(body);
21281                    if !parts.status.is_success() {
21282                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21283                        let error = serde_json::from_str(&common::to_string(&bytes));
21284                        let response = common::to_response(parts, bytes.into());
21285
21286                        if let common::Retry::After(d) =
21287                            dlg.http_failure(&response, error.as_ref().ok())
21288                        {
21289                            sleep(d).await;
21290                            continue;
21291                        }
21292
21293                        dlg.finished(false);
21294
21295                        return Err(match error {
21296                            Ok(value) => common::Error::BadRequest(value),
21297                            _ => common::Error::Failure(response),
21298                        });
21299                    }
21300                    let response = {
21301                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21302                        let encoded = common::to_string(&bytes);
21303                        match serde_json::from_str(&encoded) {
21304                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21305                            Err(error) => {
21306                                dlg.response_json_decode_error(&encoded, &error);
21307                                return Err(common::Error::JsonDecodeError(
21308                                    encoded.to_string(),
21309                                    error,
21310                                ));
21311                            }
21312                        }
21313                    };
21314
21315                    dlg.finished(true);
21316                    return Ok(response);
21317                }
21318            }
21319        }
21320    }
21321
21322    ///
21323    /// Sets the *request* property to the given value.
21324    ///
21325    /// Even though the property as already been set when instantiating this call,
21326    /// we provide this method for API completeness.
21327    pub fn request(mut self, new_value: Ad) -> AdPatchCall<'a, C> {
21328        self._request = new_value;
21329        self
21330    }
21331    /// User profile ID associated with this request.
21332    ///
21333    /// Sets the *profile id* path property to the given value.
21334    ///
21335    /// Even though the property as already been set when instantiating this call,
21336    /// we provide this method for API completeness.
21337    pub fn profile_id(mut self, new_value: i64) -> AdPatchCall<'a, C> {
21338        self._profile_id = new_value;
21339        self
21340    }
21341    /// Ad ID.
21342    ///
21343    /// Sets the *id* query property to the given value.
21344    ///
21345    /// Even though the property as already been set when instantiating this call,
21346    /// we provide this method for API completeness.
21347    pub fn id(mut self, new_value: i64) -> AdPatchCall<'a, C> {
21348        self._id = new_value;
21349        self
21350    }
21351    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21352    /// while executing the actual API request.
21353    ///
21354    /// ````text
21355    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21356    /// ````
21357    ///
21358    /// Sets the *delegate* property to the given value.
21359    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdPatchCall<'a, C> {
21360        self._delegate = Some(new_value);
21361        self
21362    }
21363
21364    /// Set any additional parameter of the query string used in the request.
21365    /// It should be used to set parameters which are not yet available through their own
21366    /// setters.
21367    ///
21368    /// Please note that this method must not be used to set any of the known parameters
21369    /// which have their own setter method. If done anyway, the request will fail.
21370    ///
21371    /// # Additional Parameters
21372    ///
21373    /// * *alt* (query-string) - Data format for the response.
21374    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21375    /// * *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.
21376    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21377    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21378    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21379    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21380    pub fn param<T>(mut self, name: T, value: T) -> AdPatchCall<'a, C>
21381    where
21382        T: AsRef<str>,
21383    {
21384        self._additional_params
21385            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21386        self
21387    }
21388
21389    /// Identifies the authorization scope for the method you are building.
21390    ///
21391    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21392    /// [`Scope::Dfatrafficking`].
21393    ///
21394    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21395    /// tokens for more than one scope.
21396    ///
21397    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21398    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21399    /// sufficient, a read-write scope will do as well.
21400    pub fn add_scope<St>(mut self, scope: St) -> AdPatchCall<'a, C>
21401    where
21402        St: AsRef<str>,
21403    {
21404        self._scopes.insert(String::from(scope.as_ref()));
21405        self
21406    }
21407    /// Identifies the authorization scope(s) for the method you are building.
21408    ///
21409    /// See [`Self::add_scope()`] for details.
21410    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdPatchCall<'a, C>
21411    where
21412        I: IntoIterator<Item = St>,
21413        St: AsRef<str>,
21414    {
21415        self._scopes
21416            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21417        self
21418    }
21419
21420    /// Removes all scopes, and no default scope will be used either.
21421    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21422    /// for details).
21423    pub fn clear_scopes(mut self) -> AdPatchCall<'a, C> {
21424        self._scopes.clear();
21425        self
21426    }
21427}
21428
21429/// Updates an existing ad.
21430///
21431/// A builder for the *update* method supported by a *ad* resource.
21432/// It is not used directly, but through a [`AdMethods`] instance.
21433///
21434/// # Example
21435///
21436/// Instantiate a resource method builder
21437///
21438/// ```test_harness,no_run
21439/// # extern crate hyper;
21440/// # extern crate hyper_rustls;
21441/// # extern crate google_dfareporting3d2 as dfareporting3d2;
21442/// use dfareporting3d2::api::Ad;
21443/// # async fn dox() {
21444/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21445///
21446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21448/// #     secret,
21449/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21450/// # ).build().await.unwrap();
21451///
21452/// # let client = hyper_util::client::legacy::Client::builder(
21453/// #     hyper_util::rt::TokioExecutor::new()
21454/// # )
21455/// # .build(
21456/// #     hyper_rustls::HttpsConnectorBuilder::new()
21457/// #         .with_native_roots()
21458/// #         .unwrap()
21459/// #         .https_or_http()
21460/// #         .enable_http1()
21461/// #         .build()
21462/// # );
21463/// # let mut hub = Dfareporting::new(client, auth);
21464/// // As the method needs a request, you would usually fill it with the desired information
21465/// // into the respective structure. Some of the parts shown here might not be applicable !
21466/// // Values shown here are possibly random and not representative !
21467/// let mut req = Ad::default();
21468///
21469/// // You can configure optional parameters by calling the respective setters at will, and
21470/// // execute the final call using `doit()`.
21471/// // Values shown here are possibly random and not representative !
21472/// let result = hub.ads().update(req, -34)
21473///              .doit().await;
21474/// # }
21475/// ```
21476pub struct AdUpdateCall<'a, C>
21477where
21478    C: 'a,
21479{
21480    hub: &'a Dfareporting<C>,
21481    _request: Ad,
21482    _profile_id: i64,
21483    _delegate: Option<&'a mut dyn common::Delegate>,
21484    _additional_params: HashMap<String, String>,
21485    _scopes: BTreeSet<String>,
21486}
21487
21488impl<'a, C> common::CallBuilder for AdUpdateCall<'a, C> {}
21489
21490impl<'a, C> AdUpdateCall<'a, C>
21491where
21492    C: common::Connector,
21493{
21494    /// Perform the operation you have build so far.
21495    pub async fn doit(mut self) -> common::Result<(common::Response, Ad)> {
21496        use std::borrow::Cow;
21497        use std::io::{Read, Seek};
21498
21499        use common::{url::Params, ToParts};
21500        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21501
21502        let mut dd = common::DefaultDelegate;
21503        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21504        dlg.begin(common::MethodInfo {
21505            id: "dfareporting.ads.update",
21506            http_method: hyper::Method::PUT,
21507        });
21508
21509        for &field in ["alt", "profileId"].iter() {
21510            if self._additional_params.contains_key(field) {
21511                dlg.finished(false);
21512                return Err(common::Error::FieldClash(field));
21513            }
21514        }
21515
21516        let mut params = Params::with_capacity(4 + self._additional_params.len());
21517        params.push("profileId", self._profile_id.to_string());
21518
21519        params.extend(self._additional_params.iter());
21520
21521        params.push("alt", "json");
21522        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads";
21523        if self._scopes.is_empty() {
21524            self._scopes
21525                .insert(Scope::Dfatrafficking.as_ref().to_string());
21526        }
21527
21528        #[allow(clippy::single_element_loop)]
21529        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
21530            url = params.uri_replacement(url, param_name, find_this, false);
21531        }
21532        {
21533            let to_remove = ["profileId"];
21534            params.remove_params(&to_remove);
21535        }
21536
21537        let url = params.parse_with_url(&url);
21538
21539        let mut json_mime_type = mime::APPLICATION_JSON;
21540        let mut request_value_reader = {
21541            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21542            common::remove_json_null_values(&mut value);
21543            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21544            serde_json::to_writer(&mut dst, &value).unwrap();
21545            dst
21546        };
21547        let request_size = request_value_reader
21548            .seek(std::io::SeekFrom::End(0))
21549            .unwrap();
21550        request_value_reader
21551            .seek(std::io::SeekFrom::Start(0))
21552            .unwrap();
21553
21554        loop {
21555            let token = match self
21556                .hub
21557                .auth
21558                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21559                .await
21560            {
21561                Ok(token) => token,
21562                Err(e) => match dlg.token(e) {
21563                    Ok(token) => token,
21564                    Err(e) => {
21565                        dlg.finished(false);
21566                        return Err(common::Error::MissingToken(e));
21567                    }
21568                },
21569            };
21570            request_value_reader
21571                .seek(std::io::SeekFrom::Start(0))
21572                .unwrap();
21573            let mut req_result = {
21574                let client = &self.hub.client;
21575                dlg.pre_request();
21576                let mut req_builder = hyper::Request::builder()
21577                    .method(hyper::Method::PUT)
21578                    .uri(url.as_str())
21579                    .header(USER_AGENT, self.hub._user_agent.clone());
21580
21581                if let Some(token) = token.as_ref() {
21582                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21583                }
21584
21585                let request = req_builder
21586                    .header(CONTENT_TYPE, json_mime_type.to_string())
21587                    .header(CONTENT_LENGTH, request_size as u64)
21588                    .body(common::to_body(
21589                        request_value_reader.get_ref().clone().into(),
21590                    ));
21591
21592                client.request(request.unwrap()).await
21593            };
21594
21595            match req_result {
21596                Err(err) => {
21597                    if let common::Retry::After(d) = dlg.http_error(&err) {
21598                        sleep(d).await;
21599                        continue;
21600                    }
21601                    dlg.finished(false);
21602                    return Err(common::Error::HttpError(err));
21603                }
21604                Ok(res) => {
21605                    let (mut parts, body) = res.into_parts();
21606                    let mut body = common::Body::new(body);
21607                    if !parts.status.is_success() {
21608                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21609                        let error = serde_json::from_str(&common::to_string(&bytes));
21610                        let response = common::to_response(parts, bytes.into());
21611
21612                        if let common::Retry::After(d) =
21613                            dlg.http_failure(&response, error.as_ref().ok())
21614                        {
21615                            sleep(d).await;
21616                            continue;
21617                        }
21618
21619                        dlg.finished(false);
21620
21621                        return Err(match error {
21622                            Ok(value) => common::Error::BadRequest(value),
21623                            _ => common::Error::Failure(response),
21624                        });
21625                    }
21626                    let response = {
21627                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21628                        let encoded = common::to_string(&bytes);
21629                        match serde_json::from_str(&encoded) {
21630                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21631                            Err(error) => {
21632                                dlg.response_json_decode_error(&encoded, &error);
21633                                return Err(common::Error::JsonDecodeError(
21634                                    encoded.to_string(),
21635                                    error,
21636                                ));
21637                            }
21638                        }
21639                    };
21640
21641                    dlg.finished(true);
21642                    return Ok(response);
21643                }
21644            }
21645        }
21646    }
21647
21648    ///
21649    /// Sets the *request* property to the given value.
21650    ///
21651    /// Even though the property as already been set when instantiating this call,
21652    /// we provide this method for API completeness.
21653    pub fn request(mut self, new_value: Ad) -> AdUpdateCall<'a, C> {
21654        self._request = new_value;
21655        self
21656    }
21657    /// User profile ID associated with this request.
21658    ///
21659    /// Sets the *profile id* path property to the given value.
21660    ///
21661    /// Even though the property as already been set when instantiating this call,
21662    /// we provide this method for API completeness.
21663    pub fn profile_id(mut self, new_value: i64) -> AdUpdateCall<'a, C> {
21664        self._profile_id = new_value;
21665        self
21666    }
21667    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21668    /// while executing the actual API request.
21669    ///
21670    /// ````text
21671    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21672    /// ````
21673    ///
21674    /// Sets the *delegate* property to the given value.
21675    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdUpdateCall<'a, C> {
21676        self._delegate = Some(new_value);
21677        self
21678    }
21679
21680    /// Set any additional parameter of the query string used in the request.
21681    /// It should be used to set parameters which are not yet available through their own
21682    /// setters.
21683    ///
21684    /// Please note that this method must not be used to set any of the known parameters
21685    /// which have their own setter method. If done anyway, the request will fail.
21686    ///
21687    /// # Additional Parameters
21688    ///
21689    /// * *alt* (query-string) - Data format for the response.
21690    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21691    /// * *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.
21692    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21693    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21694    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21695    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21696    pub fn param<T>(mut self, name: T, value: T) -> AdUpdateCall<'a, C>
21697    where
21698        T: AsRef<str>,
21699    {
21700        self._additional_params
21701            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21702        self
21703    }
21704
21705    /// Identifies the authorization scope for the method you are building.
21706    ///
21707    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21708    /// [`Scope::Dfatrafficking`].
21709    ///
21710    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21711    /// tokens for more than one scope.
21712    ///
21713    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21714    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21715    /// sufficient, a read-write scope will do as well.
21716    pub fn add_scope<St>(mut self, scope: St) -> AdUpdateCall<'a, C>
21717    where
21718        St: AsRef<str>,
21719    {
21720        self._scopes.insert(String::from(scope.as_ref()));
21721        self
21722    }
21723    /// Identifies the authorization scope(s) for the method you are building.
21724    ///
21725    /// See [`Self::add_scope()`] for details.
21726    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdUpdateCall<'a, C>
21727    where
21728        I: IntoIterator<Item = St>,
21729        St: AsRef<str>,
21730    {
21731        self._scopes
21732            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21733        self
21734    }
21735
21736    /// Removes all scopes, and no default scope will be used either.
21737    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21738    /// for details).
21739    pub fn clear_scopes(mut self) -> AdUpdateCall<'a, C> {
21740        self._scopes.clear();
21741        self
21742    }
21743}
21744
21745/// Deletes an existing advertiser group.
21746///
21747/// A builder for the *delete* method supported by a *advertiserGroup* resource.
21748/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
21749///
21750/// # Example
21751///
21752/// Instantiate a resource method builder
21753///
21754/// ```test_harness,no_run
21755/// # extern crate hyper;
21756/// # extern crate hyper_rustls;
21757/// # extern crate google_dfareporting3d2 as dfareporting3d2;
21758/// # async fn dox() {
21759/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21760///
21761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21762/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21763/// #     secret,
21764/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21765/// # ).build().await.unwrap();
21766///
21767/// # let client = hyper_util::client::legacy::Client::builder(
21768/// #     hyper_util::rt::TokioExecutor::new()
21769/// # )
21770/// # .build(
21771/// #     hyper_rustls::HttpsConnectorBuilder::new()
21772/// #         .with_native_roots()
21773/// #         .unwrap()
21774/// #         .https_or_http()
21775/// #         .enable_http1()
21776/// #         .build()
21777/// # );
21778/// # let mut hub = Dfareporting::new(client, auth);
21779/// // You can configure optional parameters by calling the respective setters at will, and
21780/// // execute the final call using `doit()`.
21781/// // Values shown here are possibly random and not representative !
21782/// let result = hub.advertiser_groups().delete(-78, -2)
21783///              .doit().await;
21784/// # }
21785/// ```
21786pub struct AdvertiserGroupDeleteCall<'a, C>
21787where
21788    C: 'a,
21789{
21790    hub: &'a Dfareporting<C>,
21791    _profile_id: i64,
21792    _id: i64,
21793    _delegate: Option<&'a mut dyn common::Delegate>,
21794    _additional_params: HashMap<String, String>,
21795    _scopes: BTreeSet<String>,
21796}
21797
21798impl<'a, C> common::CallBuilder for AdvertiserGroupDeleteCall<'a, C> {}
21799
21800impl<'a, C> AdvertiserGroupDeleteCall<'a, C>
21801where
21802    C: common::Connector,
21803{
21804    /// Perform the operation you have build so far.
21805    pub async fn doit(mut self) -> common::Result<common::Response> {
21806        use std::borrow::Cow;
21807        use std::io::{Read, Seek};
21808
21809        use common::{url::Params, ToParts};
21810        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21811
21812        let mut dd = common::DefaultDelegate;
21813        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21814        dlg.begin(common::MethodInfo {
21815            id: "dfareporting.advertiserGroups.delete",
21816            http_method: hyper::Method::DELETE,
21817        });
21818
21819        for &field in ["profileId", "id"].iter() {
21820            if self._additional_params.contains_key(field) {
21821                dlg.finished(false);
21822                return Err(common::Error::FieldClash(field));
21823            }
21824        }
21825
21826        let mut params = Params::with_capacity(3 + self._additional_params.len());
21827        params.push("profileId", self._profile_id.to_string());
21828        params.push("id", self._id.to_string());
21829
21830        params.extend(self._additional_params.iter());
21831
21832        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups/{id}";
21833        if self._scopes.is_empty() {
21834            self._scopes
21835                .insert(Scope::Dfatrafficking.as_ref().to_string());
21836        }
21837
21838        #[allow(clippy::single_element_loop)]
21839        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
21840            url = params.uri_replacement(url, param_name, find_this, false);
21841        }
21842        {
21843            let to_remove = ["id", "profileId"];
21844            params.remove_params(&to_remove);
21845        }
21846
21847        let url = params.parse_with_url(&url);
21848
21849        loop {
21850            let token = match self
21851                .hub
21852                .auth
21853                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21854                .await
21855            {
21856                Ok(token) => token,
21857                Err(e) => match dlg.token(e) {
21858                    Ok(token) => token,
21859                    Err(e) => {
21860                        dlg.finished(false);
21861                        return Err(common::Error::MissingToken(e));
21862                    }
21863                },
21864            };
21865            let mut req_result = {
21866                let client = &self.hub.client;
21867                dlg.pre_request();
21868                let mut req_builder = hyper::Request::builder()
21869                    .method(hyper::Method::DELETE)
21870                    .uri(url.as_str())
21871                    .header(USER_AGENT, self.hub._user_agent.clone());
21872
21873                if let Some(token) = token.as_ref() {
21874                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21875                }
21876
21877                let request = req_builder
21878                    .header(CONTENT_LENGTH, 0_u64)
21879                    .body(common::to_body::<String>(None));
21880
21881                client.request(request.unwrap()).await
21882            };
21883
21884            match req_result {
21885                Err(err) => {
21886                    if let common::Retry::After(d) = dlg.http_error(&err) {
21887                        sleep(d).await;
21888                        continue;
21889                    }
21890                    dlg.finished(false);
21891                    return Err(common::Error::HttpError(err));
21892                }
21893                Ok(res) => {
21894                    let (mut parts, body) = res.into_parts();
21895                    let mut body = common::Body::new(body);
21896                    if !parts.status.is_success() {
21897                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21898                        let error = serde_json::from_str(&common::to_string(&bytes));
21899                        let response = common::to_response(parts, bytes.into());
21900
21901                        if let common::Retry::After(d) =
21902                            dlg.http_failure(&response, error.as_ref().ok())
21903                        {
21904                            sleep(d).await;
21905                            continue;
21906                        }
21907
21908                        dlg.finished(false);
21909
21910                        return Err(match error {
21911                            Ok(value) => common::Error::BadRequest(value),
21912                            _ => common::Error::Failure(response),
21913                        });
21914                    }
21915                    let response = common::Response::from_parts(parts, body);
21916
21917                    dlg.finished(true);
21918                    return Ok(response);
21919                }
21920            }
21921        }
21922    }
21923
21924    /// User profile ID associated with this request.
21925    ///
21926    /// Sets the *profile id* path property to the given value.
21927    ///
21928    /// Even though the property as already been set when instantiating this call,
21929    /// we provide this method for API completeness.
21930    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupDeleteCall<'a, C> {
21931        self._profile_id = new_value;
21932        self
21933    }
21934    /// Advertiser group ID.
21935    ///
21936    /// Sets the *id* path property to the given value.
21937    ///
21938    /// Even though the property as already been set when instantiating this call,
21939    /// we provide this method for API completeness.
21940    pub fn id(mut self, new_value: i64) -> AdvertiserGroupDeleteCall<'a, C> {
21941        self._id = new_value;
21942        self
21943    }
21944    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21945    /// while executing the actual API request.
21946    ///
21947    /// ````text
21948    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21949    /// ````
21950    ///
21951    /// Sets the *delegate* property to the given value.
21952    pub fn delegate(
21953        mut self,
21954        new_value: &'a mut dyn common::Delegate,
21955    ) -> AdvertiserGroupDeleteCall<'a, C> {
21956        self._delegate = Some(new_value);
21957        self
21958    }
21959
21960    /// Set any additional parameter of the query string used in the request.
21961    /// It should be used to set parameters which are not yet available through their own
21962    /// setters.
21963    ///
21964    /// Please note that this method must not be used to set any of the known parameters
21965    /// which have their own setter method. If done anyway, the request will fail.
21966    ///
21967    /// # Additional Parameters
21968    ///
21969    /// * *alt* (query-string) - Data format for the response.
21970    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21971    /// * *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.
21972    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21973    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21974    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
21975    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
21976    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupDeleteCall<'a, C>
21977    where
21978        T: AsRef<str>,
21979    {
21980        self._additional_params
21981            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21982        self
21983    }
21984
21985    /// Identifies the authorization scope for the method you are building.
21986    ///
21987    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21988    /// [`Scope::Dfatrafficking`].
21989    ///
21990    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21991    /// tokens for more than one scope.
21992    ///
21993    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21994    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21995    /// sufficient, a read-write scope will do as well.
21996    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupDeleteCall<'a, C>
21997    where
21998        St: AsRef<str>,
21999    {
22000        self._scopes.insert(String::from(scope.as_ref()));
22001        self
22002    }
22003    /// Identifies the authorization scope(s) for the method you are building.
22004    ///
22005    /// See [`Self::add_scope()`] for details.
22006    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupDeleteCall<'a, C>
22007    where
22008        I: IntoIterator<Item = St>,
22009        St: AsRef<str>,
22010    {
22011        self._scopes
22012            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22013        self
22014    }
22015
22016    /// Removes all scopes, and no default scope will be used either.
22017    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22018    /// for details).
22019    pub fn clear_scopes(mut self) -> AdvertiserGroupDeleteCall<'a, C> {
22020        self._scopes.clear();
22021        self
22022    }
22023}
22024
22025/// Gets one advertiser group by ID.
22026///
22027/// A builder for the *get* method supported by a *advertiserGroup* resource.
22028/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
22029///
22030/// # Example
22031///
22032/// Instantiate a resource method builder
22033///
22034/// ```test_harness,no_run
22035/// # extern crate hyper;
22036/// # extern crate hyper_rustls;
22037/// # extern crate google_dfareporting3d2 as dfareporting3d2;
22038/// # async fn dox() {
22039/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22040///
22041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22042/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22043/// #     secret,
22044/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22045/// # ).build().await.unwrap();
22046///
22047/// # let client = hyper_util::client::legacy::Client::builder(
22048/// #     hyper_util::rt::TokioExecutor::new()
22049/// # )
22050/// # .build(
22051/// #     hyper_rustls::HttpsConnectorBuilder::new()
22052/// #         .with_native_roots()
22053/// #         .unwrap()
22054/// #         .https_or_http()
22055/// #         .enable_http1()
22056/// #         .build()
22057/// # );
22058/// # let mut hub = Dfareporting::new(client, auth);
22059/// // You can configure optional parameters by calling the respective setters at will, and
22060/// // execute the final call using `doit()`.
22061/// // Values shown here are possibly random and not representative !
22062/// let result = hub.advertiser_groups().get(-17, -95)
22063///              .doit().await;
22064/// # }
22065/// ```
22066pub struct AdvertiserGroupGetCall<'a, C>
22067where
22068    C: 'a,
22069{
22070    hub: &'a Dfareporting<C>,
22071    _profile_id: i64,
22072    _id: i64,
22073    _delegate: Option<&'a mut dyn common::Delegate>,
22074    _additional_params: HashMap<String, String>,
22075    _scopes: BTreeSet<String>,
22076}
22077
22078impl<'a, C> common::CallBuilder for AdvertiserGroupGetCall<'a, C> {}
22079
22080impl<'a, C> AdvertiserGroupGetCall<'a, C>
22081where
22082    C: common::Connector,
22083{
22084    /// Perform the operation you have build so far.
22085    pub async fn doit(mut self) -> common::Result<(common::Response, AdvertiserGroup)> {
22086        use std::borrow::Cow;
22087        use std::io::{Read, Seek};
22088
22089        use common::{url::Params, ToParts};
22090        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22091
22092        let mut dd = common::DefaultDelegate;
22093        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22094        dlg.begin(common::MethodInfo {
22095            id: "dfareporting.advertiserGroups.get",
22096            http_method: hyper::Method::GET,
22097        });
22098
22099        for &field in ["alt", "profileId", "id"].iter() {
22100            if self._additional_params.contains_key(field) {
22101                dlg.finished(false);
22102                return Err(common::Error::FieldClash(field));
22103            }
22104        }
22105
22106        let mut params = Params::with_capacity(4 + self._additional_params.len());
22107        params.push("profileId", self._profile_id.to_string());
22108        params.push("id", self._id.to_string());
22109
22110        params.extend(self._additional_params.iter());
22111
22112        params.push("alt", "json");
22113        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups/{id}";
22114        if self._scopes.is_empty() {
22115            self._scopes
22116                .insert(Scope::Dfatrafficking.as_ref().to_string());
22117        }
22118
22119        #[allow(clippy::single_element_loop)]
22120        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
22121            url = params.uri_replacement(url, param_name, find_this, false);
22122        }
22123        {
22124            let to_remove = ["id", "profileId"];
22125            params.remove_params(&to_remove);
22126        }
22127
22128        let url = params.parse_with_url(&url);
22129
22130        loop {
22131            let token = match self
22132                .hub
22133                .auth
22134                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22135                .await
22136            {
22137                Ok(token) => token,
22138                Err(e) => match dlg.token(e) {
22139                    Ok(token) => token,
22140                    Err(e) => {
22141                        dlg.finished(false);
22142                        return Err(common::Error::MissingToken(e));
22143                    }
22144                },
22145            };
22146            let mut req_result = {
22147                let client = &self.hub.client;
22148                dlg.pre_request();
22149                let mut req_builder = hyper::Request::builder()
22150                    .method(hyper::Method::GET)
22151                    .uri(url.as_str())
22152                    .header(USER_AGENT, self.hub._user_agent.clone());
22153
22154                if let Some(token) = token.as_ref() {
22155                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22156                }
22157
22158                let request = req_builder
22159                    .header(CONTENT_LENGTH, 0_u64)
22160                    .body(common::to_body::<String>(None));
22161
22162                client.request(request.unwrap()).await
22163            };
22164
22165            match req_result {
22166                Err(err) => {
22167                    if let common::Retry::After(d) = dlg.http_error(&err) {
22168                        sleep(d).await;
22169                        continue;
22170                    }
22171                    dlg.finished(false);
22172                    return Err(common::Error::HttpError(err));
22173                }
22174                Ok(res) => {
22175                    let (mut parts, body) = res.into_parts();
22176                    let mut body = common::Body::new(body);
22177                    if !parts.status.is_success() {
22178                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22179                        let error = serde_json::from_str(&common::to_string(&bytes));
22180                        let response = common::to_response(parts, bytes.into());
22181
22182                        if let common::Retry::After(d) =
22183                            dlg.http_failure(&response, error.as_ref().ok())
22184                        {
22185                            sleep(d).await;
22186                            continue;
22187                        }
22188
22189                        dlg.finished(false);
22190
22191                        return Err(match error {
22192                            Ok(value) => common::Error::BadRequest(value),
22193                            _ => common::Error::Failure(response),
22194                        });
22195                    }
22196                    let response = {
22197                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22198                        let encoded = common::to_string(&bytes);
22199                        match serde_json::from_str(&encoded) {
22200                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22201                            Err(error) => {
22202                                dlg.response_json_decode_error(&encoded, &error);
22203                                return Err(common::Error::JsonDecodeError(
22204                                    encoded.to_string(),
22205                                    error,
22206                                ));
22207                            }
22208                        }
22209                    };
22210
22211                    dlg.finished(true);
22212                    return Ok(response);
22213                }
22214            }
22215        }
22216    }
22217
22218    /// User profile ID associated with this request.
22219    ///
22220    /// Sets the *profile id* path property to the given value.
22221    ///
22222    /// Even though the property as already been set when instantiating this call,
22223    /// we provide this method for API completeness.
22224    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupGetCall<'a, C> {
22225        self._profile_id = new_value;
22226        self
22227    }
22228    /// Advertiser group ID.
22229    ///
22230    /// Sets the *id* path property to the given value.
22231    ///
22232    /// Even though the property as already been set when instantiating this call,
22233    /// we provide this method for API completeness.
22234    pub fn id(mut self, new_value: i64) -> AdvertiserGroupGetCall<'a, C> {
22235        self._id = new_value;
22236        self
22237    }
22238    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22239    /// while executing the actual API request.
22240    ///
22241    /// ````text
22242    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22243    /// ````
22244    ///
22245    /// Sets the *delegate* property to the given value.
22246    pub fn delegate(
22247        mut self,
22248        new_value: &'a mut dyn common::Delegate,
22249    ) -> AdvertiserGroupGetCall<'a, C> {
22250        self._delegate = Some(new_value);
22251        self
22252    }
22253
22254    /// Set any additional parameter of the query string used in the request.
22255    /// It should be used to set parameters which are not yet available through their own
22256    /// setters.
22257    ///
22258    /// Please note that this method must not be used to set any of the known parameters
22259    /// which have their own setter method. If done anyway, the request will fail.
22260    ///
22261    /// # Additional Parameters
22262    ///
22263    /// * *alt* (query-string) - Data format for the response.
22264    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22265    /// * *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.
22266    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22267    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22268    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22269    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22270    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupGetCall<'a, C>
22271    where
22272        T: AsRef<str>,
22273    {
22274        self._additional_params
22275            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22276        self
22277    }
22278
22279    /// Identifies the authorization scope for the method you are building.
22280    ///
22281    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22282    /// [`Scope::Dfatrafficking`].
22283    ///
22284    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22285    /// tokens for more than one scope.
22286    ///
22287    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22288    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22289    /// sufficient, a read-write scope will do as well.
22290    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupGetCall<'a, C>
22291    where
22292        St: AsRef<str>,
22293    {
22294        self._scopes.insert(String::from(scope.as_ref()));
22295        self
22296    }
22297    /// Identifies the authorization scope(s) for the method you are building.
22298    ///
22299    /// See [`Self::add_scope()`] for details.
22300    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupGetCall<'a, C>
22301    where
22302        I: IntoIterator<Item = St>,
22303        St: AsRef<str>,
22304    {
22305        self._scopes
22306            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22307        self
22308    }
22309
22310    /// Removes all scopes, and no default scope will be used either.
22311    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22312    /// for details).
22313    pub fn clear_scopes(mut self) -> AdvertiserGroupGetCall<'a, C> {
22314        self._scopes.clear();
22315        self
22316    }
22317}
22318
22319/// Inserts a new advertiser group.
22320///
22321/// A builder for the *insert* method supported by a *advertiserGroup* resource.
22322/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
22323///
22324/// # Example
22325///
22326/// Instantiate a resource method builder
22327///
22328/// ```test_harness,no_run
22329/// # extern crate hyper;
22330/// # extern crate hyper_rustls;
22331/// # extern crate google_dfareporting3d2 as dfareporting3d2;
22332/// use dfareporting3d2::api::AdvertiserGroup;
22333/// # async fn dox() {
22334/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22335///
22336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22338/// #     secret,
22339/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22340/// # ).build().await.unwrap();
22341///
22342/// # let client = hyper_util::client::legacy::Client::builder(
22343/// #     hyper_util::rt::TokioExecutor::new()
22344/// # )
22345/// # .build(
22346/// #     hyper_rustls::HttpsConnectorBuilder::new()
22347/// #         .with_native_roots()
22348/// #         .unwrap()
22349/// #         .https_or_http()
22350/// #         .enable_http1()
22351/// #         .build()
22352/// # );
22353/// # let mut hub = Dfareporting::new(client, auth);
22354/// // As the method needs a request, you would usually fill it with the desired information
22355/// // into the respective structure. Some of the parts shown here might not be applicable !
22356/// // Values shown here are possibly random and not representative !
22357/// let mut req = AdvertiserGroup::default();
22358///
22359/// // You can configure optional parameters by calling the respective setters at will, and
22360/// // execute the final call using `doit()`.
22361/// // Values shown here are possibly random and not representative !
22362/// let result = hub.advertiser_groups().insert(req, -6)
22363///              .doit().await;
22364/// # }
22365/// ```
22366pub struct AdvertiserGroupInsertCall<'a, C>
22367where
22368    C: 'a,
22369{
22370    hub: &'a Dfareporting<C>,
22371    _request: AdvertiserGroup,
22372    _profile_id: i64,
22373    _delegate: Option<&'a mut dyn common::Delegate>,
22374    _additional_params: HashMap<String, String>,
22375    _scopes: BTreeSet<String>,
22376}
22377
22378impl<'a, C> common::CallBuilder for AdvertiserGroupInsertCall<'a, C> {}
22379
22380impl<'a, C> AdvertiserGroupInsertCall<'a, C>
22381where
22382    C: common::Connector,
22383{
22384    /// Perform the operation you have build so far.
22385    pub async fn doit(mut self) -> common::Result<(common::Response, AdvertiserGroup)> {
22386        use std::borrow::Cow;
22387        use std::io::{Read, Seek};
22388
22389        use common::{url::Params, ToParts};
22390        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22391
22392        let mut dd = common::DefaultDelegate;
22393        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22394        dlg.begin(common::MethodInfo {
22395            id: "dfareporting.advertiserGroups.insert",
22396            http_method: hyper::Method::POST,
22397        });
22398
22399        for &field in ["alt", "profileId"].iter() {
22400            if self._additional_params.contains_key(field) {
22401                dlg.finished(false);
22402                return Err(common::Error::FieldClash(field));
22403            }
22404        }
22405
22406        let mut params = Params::with_capacity(4 + self._additional_params.len());
22407        params.push("profileId", self._profile_id.to_string());
22408
22409        params.extend(self._additional_params.iter());
22410
22411        params.push("alt", "json");
22412        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups";
22413        if self._scopes.is_empty() {
22414            self._scopes
22415                .insert(Scope::Dfatrafficking.as_ref().to_string());
22416        }
22417
22418        #[allow(clippy::single_element_loop)]
22419        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
22420            url = params.uri_replacement(url, param_name, find_this, false);
22421        }
22422        {
22423            let to_remove = ["profileId"];
22424            params.remove_params(&to_remove);
22425        }
22426
22427        let url = params.parse_with_url(&url);
22428
22429        let mut json_mime_type = mime::APPLICATION_JSON;
22430        let mut request_value_reader = {
22431            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22432            common::remove_json_null_values(&mut value);
22433            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22434            serde_json::to_writer(&mut dst, &value).unwrap();
22435            dst
22436        };
22437        let request_size = request_value_reader
22438            .seek(std::io::SeekFrom::End(0))
22439            .unwrap();
22440        request_value_reader
22441            .seek(std::io::SeekFrom::Start(0))
22442            .unwrap();
22443
22444        loop {
22445            let token = match self
22446                .hub
22447                .auth
22448                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22449                .await
22450            {
22451                Ok(token) => token,
22452                Err(e) => match dlg.token(e) {
22453                    Ok(token) => token,
22454                    Err(e) => {
22455                        dlg.finished(false);
22456                        return Err(common::Error::MissingToken(e));
22457                    }
22458                },
22459            };
22460            request_value_reader
22461                .seek(std::io::SeekFrom::Start(0))
22462                .unwrap();
22463            let mut req_result = {
22464                let client = &self.hub.client;
22465                dlg.pre_request();
22466                let mut req_builder = hyper::Request::builder()
22467                    .method(hyper::Method::POST)
22468                    .uri(url.as_str())
22469                    .header(USER_AGENT, self.hub._user_agent.clone());
22470
22471                if let Some(token) = token.as_ref() {
22472                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22473                }
22474
22475                let request = req_builder
22476                    .header(CONTENT_TYPE, json_mime_type.to_string())
22477                    .header(CONTENT_LENGTH, request_size as u64)
22478                    .body(common::to_body(
22479                        request_value_reader.get_ref().clone().into(),
22480                    ));
22481
22482                client.request(request.unwrap()).await
22483            };
22484
22485            match req_result {
22486                Err(err) => {
22487                    if let common::Retry::After(d) = dlg.http_error(&err) {
22488                        sleep(d).await;
22489                        continue;
22490                    }
22491                    dlg.finished(false);
22492                    return Err(common::Error::HttpError(err));
22493                }
22494                Ok(res) => {
22495                    let (mut parts, body) = res.into_parts();
22496                    let mut body = common::Body::new(body);
22497                    if !parts.status.is_success() {
22498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22499                        let error = serde_json::from_str(&common::to_string(&bytes));
22500                        let response = common::to_response(parts, bytes.into());
22501
22502                        if let common::Retry::After(d) =
22503                            dlg.http_failure(&response, error.as_ref().ok())
22504                        {
22505                            sleep(d).await;
22506                            continue;
22507                        }
22508
22509                        dlg.finished(false);
22510
22511                        return Err(match error {
22512                            Ok(value) => common::Error::BadRequest(value),
22513                            _ => common::Error::Failure(response),
22514                        });
22515                    }
22516                    let response = {
22517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22518                        let encoded = common::to_string(&bytes);
22519                        match serde_json::from_str(&encoded) {
22520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22521                            Err(error) => {
22522                                dlg.response_json_decode_error(&encoded, &error);
22523                                return Err(common::Error::JsonDecodeError(
22524                                    encoded.to_string(),
22525                                    error,
22526                                ));
22527                            }
22528                        }
22529                    };
22530
22531                    dlg.finished(true);
22532                    return Ok(response);
22533                }
22534            }
22535        }
22536    }
22537
22538    ///
22539    /// Sets the *request* property to the given value.
22540    ///
22541    /// Even though the property as already been set when instantiating this call,
22542    /// we provide this method for API completeness.
22543    pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, C> {
22544        self._request = new_value;
22545        self
22546    }
22547    /// User profile ID associated with this request.
22548    ///
22549    /// Sets the *profile id* path property to the given value.
22550    ///
22551    /// Even though the property as already been set when instantiating this call,
22552    /// we provide this method for API completeness.
22553    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupInsertCall<'a, C> {
22554        self._profile_id = new_value;
22555        self
22556    }
22557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22558    /// while executing the actual API request.
22559    ///
22560    /// ````text
22561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22562    /// ````
22563    ///
22564    /// Sets the *delegate* property to the given value.
22565    pub fn delegate(
22566        mut self,
22567        new_value: &'a mut dyn common::Delegate,
22568    ) -> AdvertiserGroupInsertCall<'a, C> {
22569        self._delegate = Some(new_value);
22570        self
22571    }
22572
22573    /// Set any additional parameter of the query string used in the request.
22574    /// It should be used to set parameters which are not yet available through their own
22575    /// setters.
22576    ///
22577    /// Please note that this method must not be used to set any of the known parameters
22578    /// which have their own setter method. If done anyway, the request will fail.
22579    ///
22580    /// # Additional Parameters
22581    ///
22582    /// * *alt* (query-string) - Data format for the response.
22583    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22584    /// * *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.
22585    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22586    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22587    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22588    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22589    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupInsertCall<'a, C>
22590    where
22591        T: AsRef<str>,
22592    {
22593        self._additional_params
22594            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22595        self
22596    }
22597
22598    /// Identifies the authorization scope for the method you are building.
22599    ///
22600    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22601    /// [`Scope::Dfatrafficking`].
22602    ///
22603    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22604    /// tokens for more than one scope.
22605    ///
22606    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22607    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22608    /// sufficient, a read-write scope will do as well.
22609    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupInsertCall<'a, C>
22610    where
22611        St: AsRef<str>,
22612    {
22613        self._scopes.insert(String::from(scope.as_ref()));
22614        self
22615    }
22616    /// Identifies the authorization scope(s) for the method you are building.
22617    ///
22618    /// See [`Self::add_scope()`] for details.
22619    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupInsertCall<'a, C>
22620    where
22621        I: IntoIterator<Item = St>,
22622        St: AsRef<str>,
22623    {
22624        self._scopes
22625            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22626        self
22627    }
22628
22629    /// Removes all scopes, and no default scope will be used either.
22630    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22631    /// for details).
22632    pub fn clear_scopes(mut self) -> AdvertiserGroupInsertCall<'a, C> {
22633        self._scopes.clear();
22634        self
22635    }
22636}
22637
22638/// Retrieves a list of advertiser groups, possibly filtered. This method supports paging.
22639///
22640/// A builder for the *list* method supported by a *advertiserGroup* resource.
22641/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
22642///
22643/// # Example
22644///
22645/// Instantiate a resource method builder
22646///
22647/// ```test_harness,no_run
22648/// # extern crate hyper;
22649/// # extern crate hyper_rustls;
22650/// # extern crate google_dfareporting3d2 as dfareporting3d2;
22651/// # async fn dox() {
22652/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22653///
22654/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22656/// #     secret,
22657/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22658/// # ).build().await.unwrap();
22659///
22660/// # let client = hyper_util::client::legacy::Client::builder(
22661/// #     hyper_util::rt::TokioExecutor::new()
22662/// # )
22663/// # .build(
22664/// #     hyper_rustls::HttpsConnectorBuilder::new()
22665/// #         .with_native_roots()
22666/// #         .unwrap()
22667/// #         .https_or_http()
22668/// #         .enable_http1()
22669/// #         .build()
22670/// # );
22671/// # let mut hub = Dfareporting::new(client, auth);
22672/// // You can configure optional parameters by calling the respective setters at will, and
22673/// // execute the final call using `doit()`.
22674/// // Values shown here are possibly random and not representative !
22675/// let result = hub.advertiser_groups().list(-38)
22676///              .sort_order("no")
22677///              .sort_field("est")
22678///              .search_string("At")
22679///              .page_token("sed")
22680///              .max_results(-98)
22681///              .add_ids(-35)
22682///              .doit().await;
22683/// # }
22684/// ```
22685pub struct AdvertiserGroupListCall<'a, C>
22686where
22687    C: 'a,
22688{
22689    hub: &'a Dfareporting<C>,
22690    _profile_id: i64,
22691    _sort_order: Option<String>,
22692    _sort_field: Option<String>,
22693    _search_string: Option<String>,
22694    _page_token: Option<String>,
22695    _max_results: Option<i32>,
22696    _ids: Vec<i64>,
22697    _delegate: Option<&'a mut dyn common::Delegate>,
22698    _additional_params: HashMap<String, String>,
22699    _scopes: BTreeSet<String>,
22700}
22701
22702impl<'a, C> common::CallBuilder for AdvertiserGroupListCall<'a, C> {}
22703
22704impl<'a, C> AdvertiserGroupListCall<'a, C>
22705where
22706    C: common::Connector,
22707{
22708    /// Perform the operation you have build so far.
22709    pub async fn doit(
22710        mut self,
22711    ) -> common::Result<(common::Response, AdvertiserGroupsListResponse)> {
22712        use std::borrow::Cow;
22713        use std::io::{Read, Seek};
22714
22715        use common::{url::Params, ToParts};
22716        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22717
22718        let mut dd = common::DefaultDelegate;
22719        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22720        dlg.begin(common::MethodInfo {
22721            id: "dfareporting.advertiserGroups.list",
22722            http_method: hyper::Method::GET,
22723        });
22724
22725        for &field in [
22726            "alt",
22727            "profileId",
22728            "sortOrder",
22729            "sortField",
22730            "searchString",
22731            "pageToken",
22732            "maxResults",
22733            "ids",
22734        ]
22735        .iter()
22736        {
22737            if self._additional_params.contains_key(field) {
22738                dlg.finished(false);
22739                return Err(common::Error::FieldClash(field));
22740            }
22741        }
22742
22743        let mut params = Params::with_capacity(9 + self._additional_params.len());
22744        params.push("profileId", self._profile_id.to_string());
22745        if let Some(value) = self._sort_order.as_ref() {
22746            params.push("sortOrder", value);
22747        }
22748        if let Some(value) = self._sort_field.as_ref() {
22749            params.push("sortField", value);
22750        }
22751        if let Some(value) = self._search_string.as_ref() {
22752            params.push("searchString", value);
22753        }
22754        if let Some(value) = self._page_token.as_ref() {
22755            params.push("pageToken", value);
22756        }
22757        if let Some(value) = self._max_results.as_ref() {
22758            params.push("maxResults", value.to_string());
22759        }
22760        if !self._ids.is_empty() {
22761            for f in self._ids.iter() {
22762                params.push("ids", f.to_string());
22763            }
22764        }
22765
22766        params.extend(self._additional_params.iter());
22767
22768        params.push("alt", "json");
22769        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups";
22770        if self._scopes.is_empty() {
22771            self._scopes
22772                .insert(Scope::Dfatrafficking.as_ref().to_string());
22773        }
22774
22775        #[allow(clippy::single_element_loop)]
22776        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
22777            url = params.uri_replacement(url, param_name, find_this, false);
22778        }
22779        {
22780            let to_remove = ["profileId"];
22781            params.remove_params(&to_remove);
22782        }
22783
22784        let url = params.parse_with_url(&url);
22785
22786        loop {
22787            let token = match self
22788                .hub
22789                .auth
22790                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22791                .await
22792            {
22793                Ok(token) => token,
22794                Err(e) => match dlg.token(e) {
22795                    Ok(token) => token,
22796                    Err(e) => {
22797                        dlg.finished(false);
22798                        return Err(common::Error::MissingToken(e));
22799                    }
22800                },
22801            };
22802            let mut req_result = {
22803                let client = &self.hub.client;
22804                dlg.pre_request();
22805                let mut req_builder = hyper::Request::builder()
22806                    .method(hyper::Method::GET)
22807                    .uri(url.as_str())
22808                    .header(USER_AGENT, self.hub._user_agent.clone());
22809
22810                if let Some(token) = token.as_ref() {
22811                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22812                }
22813
22814                let request = req_builder
22815                    .header(CONTENT_LENGTH, 0_u64)
22816                    .body(common::to_body::<String>(None));
22817
22818                client.request(request.unwrap()).await
22819            };
22820
22821            match req_result {
22822                Err(err) => {
22823                    if let common::Retry::After(d) = dlg.http_error(&err) {
22824                        sleep(d).await;
22825                        continue;
22826                    }
22827                    dlg.finished(false);
22828                    return Err(common::Error::HttpError(err));
22829                }
22830                Ok(res) => {
22831                    let (mut parts, body) = res.into_parts();
22832                    let mut body = common::Body::new(body);
22833                    if !parts.status.is_success() {
22834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22835                        let error = serde_json::from_str(&common::to_string(&bytes));
22836                        let response = common::to_response(parts, bytes.into());
22837
22838                        if let common::Retry::After(d) =
22839                            dlg.http_failure(&response, error.as_ref().ok())
22840                        {
22841                            sleep(d).await;
22842                            continue;
22843                        }
22844
22845                        dlg.finished(false);
22846
22847                        return Err(match error {
22848                            Ok(value) => common::Error::BadRequest(value),
22849                            _ => common::Error::Failure(response),
22850                        });
22851                    }
22852                    let response = {
22853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22854                        let encoded = common::to_string(&bytes);
22855                        match serde_json::from_str(&encoded) {
22856                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22857                            Err(error) => {
22858                                dlg.response_json_decode_error(&encoded, &error);
22859                                return Err(common::Error::JsonDecodeError(
22860                                    encoded.to_string(),
22861                                    error,
22862                                ));
22863                            }
22864                        }
22865                    };
22866
22867                    dlg.finished(true);
22868                    return Ok(response);
22869                }
22870            }
22871        }
22872    }
22873
22874    /// User profile ID associated with this request.
22875    ///
22876    /// Sets the *profile id* path property to the given value.
22877    ///
22878    /// Even though the property as already been set when instantiating this call,
22879    /// we provide this method for API completeness.
22880    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupListCall<'a, C> {
22881        self._profile_id = new_value;
22882        self
22883    }
22884    /// Order of sorted results.
22885    ///
22886    /// Sets the *sort order* query property to the given value.
22887    pub fn sort_order(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C> {
22888        self._sort_order = Some(new_value.to_string());
22889        self
22890    }
22891    /// Field by which to sort the list.
22892    ///
22893    /// Sets the *sort field* query property to the given value.
22894    pub fn sort_field(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C> {
22895        self._sort_field = Some(new_value.to_string());
22896        self
22897    }
22898    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser group June 2015", "advertiser group April 2015", or simply "advertiser group 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertisergroup" will match objects with name "my advertisergroup", "advertisergroup 2015", or simply "advertisergroup".
22899    ///
22900    /// Sets the *search string* query property to the given value.
22901    pub fn search_string(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C> {
22902        self._search_string = Some(new_value.to_string());
22903        self
22904    }
22905    /// Value of the nextPageToken from the previous result page.
22906    ///
22907    /// Sets the *page token* query property to the given value.
22908    pub fn page_token(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, C> {
22909        self._page_token = Some(new_value.to_string());
22910        self
22911    }
22912    /// Maximum number of results to return.
22913    ///
22914    /// Sets the *max results* query property to the given value.
22915    pub fn max_results(mut self, new_value: i32) -> AdvertiserGroupListCall<'a, C> {
22916        self._max_results = Some(new_value);
22917        self
22918    }
22919    /// Select only advertiser groups with these IDs.
22920    ///
22921    /// Append the given value to the *ids* query property.
22922    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
22923    pub fn add_ids(mut self, new_value: i64) -> AdvertiserGroupListCall<'a, C> {
22924        self._ids.push(new_value);
22925        self
22926    }
22927    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22928    /// while executing the actual API request.
22929    ///
22930    /// ````text
22931    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22932    /// ````
22933    ///
22934    /// Sets the *delegate* property to the given value.
22935    pub fn delegate(
22936        mut self,
22937        new_value: &'a mut dyn common::Delegate,
22938    ) -> AdvertiserGroupListCall<'a, C> {
22939        self._delegate = Some(new_value);
22940        self
22941    }
22942
22943    /// Set any additional parameter of the query string used in the request.
22944    /// It should be used to set parameters which are not yet available through their own
22945    /// setters.
22946    ///
22947    /// Please note that this method must not be used to set any of the known parameters
22948    /// which have their own setter method. If done anyway, the request will fail.
22949    ///
22950    /// # Additional Parameters
22951    ///
22952    /// * *alt* (query-string) - Data format for the response.
22953    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22954    /// * *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.
22955    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22956    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22957    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
22958    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
22959    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupListCall<'a, C>
22960    where
22961        T: AsRef<str>,
22962    {
22963        self._additional_params
22964            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22965        self
22966    }
22967
22968    /// Identifies the authorization scope for the method you are building.
22969    ///
22970    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22971    /// [`Scope::Dfatrafficking`].
22972    ///
22973    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22974    /// tokens for more than one scope.
22975    ///
22976    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22977    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22978    /// sufficient, a read-write scope will do as well.
22979    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupListCall<'a, C>
22980    where
22981        St: AsRef<str>,
22982    {
22983        self._scopes.insert(String::from(scope.as_ref()));
22984        self
22985    }
22986    /// Identifies the authorization scope(s) for the method you are building.
22987    ///
22988    /// See [`Self::add_scope()`] for details.
22989    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupListCall<'a, C>
22990    where
22991        I: IntoIterator<Item = St>,
22992        St: AsRef<str>,
22993    {
22994        self._scopes
22995            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22996        self
22997    }
22998
22999    /// Removes all scopes, and no default scope will be used either.
23000    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23001    /// for details).
23002    pub fn clear_scopes(mut self) -> AdvertiserGroupListCall<'a, C> {
23003        self._scopes.clear();
23004        self
23005    }
23006}
23007
23008/// Updates an existing advertiser group. This method supports patch semantics.
23009///
23010/// A builder for the *patch* method supported by a *advertiserGroup* resource.
23011/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
23012///
23013/// # Example
23014///
23015/// Instantiate a resource method builder
23016///
23017/// ```test_harness,no_run
23018/// # extern crate hyper;
23019/// # extern crate hyper_rustls;
23020/// # extern crate google_dfareporting3d2 as dfareporting3d2;
23021/// use dfareporting3d2::api::AdvertiserGroup;
23022/// # async fn dox() {
23023/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23024///
23025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23026/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23027/// #     secret,
23028/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23029/// # ).build().await.unwrap();
23030///
23031/// # let client = hyper_util::client::legacy::Client::builder(
23032/// #     hyper_util::rt::TokioExecutor::new()
23033/// # )
23034/// # .build(
23035/// #     hyper_rustls::HttpsConnectorBuilder::new()
23036/// #         .with_native_roots()
23037/// #         .unwrap()
23038/// #         .https_or_http()
23039/// #         .enable_http1()
23040/// #         .build()
23041/// # );
23042/// # let mut hub = Dfareporting::new(client, auth);
23043/// // As the method needs a request, you would usually fill it with the desired information
23044/// // into the respective structure. Some of the parts shown here might not be applicable !
23045/// // Values shown here are possibly random and not representative !
23046/// let mut req = AdvertiserGroup::default();
23047///
23048/// // You can configure optional parameters by calling the respective setters at will, and
23049/// // execute the final call using `doit()`.
23050/// // Values shown here are possibly random and not representative !
23051/// let result = hub.advertiser_groups().patch(req, -39, -32)
23052///              .doit().await;
23053/// # }
23054/// ```
23055pub struct AdvertiserGroupPatchCall<'a, C>
23056where
23057    C: 'a,
23058{
23059    hub: &'a Dfareporting<C>,
23060    _request: AdvertiserGroup,
23061    _profile_id: i64,
23062    _id: i64,
23063    _delegate: Option<&'a mut dyn common::Delegate>,
23064    _additional_params: HashMap<String, String>,
23065    _scopes: BTreeSet<String>,
23066}
23067
23068impl<'a, C> common::CallBuilder for AdvertiserGroupPatchCall<'a, C> {}
23069
23070impl<'a, C> AdvertiserGroupPatchCall<'a, C>
23071where
23072    C: common::Connector,
23073{
23074    /// Perform the operation you have build so far.
23075    pub async fn doit(mut self) -> common::Result<(common::Response, AdvertiserGroup)> {
23076        use std::borrow::Cow;
23077        use std::io::{Read, Seek};
23078
23079        use common::{url::Params, ToParts};
23080        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23081
23082        let mut dd = common::DefaultDelegate;
23083        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23084        dlg.begin(common::MethodInfo {
23085            id: "dfareporting.advertiserGroups.patch",
23086            http_method: hyper::Method::PATCH,
23087        });
23088
23089        for &field in ["alt", "profileId", "id"].iter() {
23090            if self._additional_params.contains_key(field) {
23091                dlg.finished(false);
23092                return Err(common::Error::FieldClash(field));
23093            }
23094        }
23095
23096        let mut params = Params::with_capacity(5 + self._additional_params.len());
23097        params.push("profileId", self._profile_id.to_string());
23098        params.push("id", self._id.to_string());
23099
23100        params.extend(self._additional_params.iter());
23101
23102        params.push("alt", "json");
23103        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups";
23104        if self._scopes.is_empty() {
23105            self._scopes
23106                .insert(Scope::Dfatrafficking.as_ref().to_string());
23107        }
23108
23109        #[allow(clippy::single_element_loop)]
23110        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
23111            url = params.uri_replacement(url, param_name, find_this, false);
23112        }
23113        {
23114            let to_remove = ["profileId"];
23115            params.remove_params(&to_remove);
23116        }
23117
23118        let url = params.parse_with_url(&url);
23119
23120        let mut json_mime_type = mime::APPLICATION_JSON;
23121        let mut request_value_reader = {
23122            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23123            common::remove_json_null_values(&mut value);
23124            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23125            serde_json::to_writer(&mut dst, &value).unwrap();
23126            dst
23127        };
23128        let request_size = request_value_reader
23129            .seek(std::io::SeekFrom::End(0))
23130            .unwrap();
23131        request_value_reader
23132            .seek(std::io::SeekFrom::Start(0))
23133            .unwrap();
23134
23135        loop {
23136            let token = match self
23137                .hub
23138                .auth
23139                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23140                .await
23141            {
23142                Ok(token) => token,
23143                Err(e) => match dlg.token(e) {
23144                    Ok(token) => token,
23145                    Err(e) => {
23146                        dlg.finished(false);
23147                        return Err(common::Error::MissingToken(e));
23148                    }
23149                },
23150            };
23151            request_value_reader
23152                .seek(std::io::SeekFrom::Start(0))
23153                .unwrap();
23154            let mut req_result = {
23155                let client = &self.hub.client;
23156                dlg.pre_request();
23157                let mut req_builder = hyper::Request::builder()
23158                    .method(hyper::Method::PATCH)
23159                    .uri(url.as_str())
23160                    .header(USER_AGENT, self.hub._user_agent.clone());
23161
23162                if let Some(token) = token.as_ref() {
23163                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23164                }
23165
23166                let request = req_builder
23167                    .header(CONTENT_TYPE, json_mime_type.to_string())
23168                    .header(CONTENT_LENGTH, request_size as u64)
23169                    .body(common::to_body(
23170                        request_value_reader.get_ref().clone().into(),
23171                    ));
23172
23173                client.request(request.unwrap()).await
23174            };
23175
23176            match req_result {
23177                Err(err) => {
23178                    if let common::Retry::After(d) = dlg.http_error(&err) {
23179                        sleep(d).await;
23180                        continue;
23181                    }
23182                    dlg.finished(false);
23183                    return Err(common::Error::HttpError(err));
23184                }
23185                Ok(res) => {
23186                    let (mut parts, body) = res.into_parts();
23187                    let mut body = common::Body::new(body);
23188                    if !parts.status.is_success() {
23189                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23190                        let error = serde_json::from_str(&common::to_string(&bytes));
23191                        let response = common::to_response(parts, bytes.into());
23192
23193                        if let common::Retry::After(d) =
23194                            dlg.http_failure(&response, error.as_ref().ok())
23195                        {
23196                            sleep(d).await;
23197                            continue;
23198                        }
23199
23200                        dlg.finished(false);
23201
23202                        return Err(match error {
23203                            Ok(value) => common::Error::BadRequest(value),
23204                            _ => common::Error::Failure(response),
23205                        });
23206                    }
23207                    let response = {
23208                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23209                        let encoded = common::to_string(&bytes);
23210                        match serde_json::from_str(&encoded) {
23211                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23212                            Err(error) => {
23213                                dlg.response_json_decode_error(&encoded, &error);
23214                                return Err(common::Error::JsonDecodeError(
23215                                    encoded.to_string(),
23216                                    error,
23217                                ));
23218                            }
23219                        }
23220                    };
23221
23222                    dlg.finished(true);
23223                    return Ok(response);
23224                }
23225            }
23226        }
23227    }
23228
23229    ///
23230    /// Sets the *request* property to the given value.
23231    ///
23232    /// Even though the property as already been set when instantiating this call,
23233    /// we provide this method for API completeness.
23234    pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, C> {
23235        self._request = new_value;
23236        self
23237    }
23238    /// User profile ID associated with this request.
23239    ///
23240    /// Sets the *profile id* path property to the given value.
23241    ///
23242    /// Even though the property as already been set when instantiating this call,
23243    /// we provide this method for API completeness.
23244    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupPatchCall<'a, C> {
23245        self._profile_id = new_value;
23246        self
23247    }
23248    /// Advertiser group ID.
23249    ///
23250    /// Sets the *id* query property to the given value.
23251    ///
23252    /// Even though the property as already been set when instantiating this call,
23253    /// we provide this method for API completeness.
23254    pub fn id(mut self, new_value: i64) -> AdvertiserGroupPatchCall<'a, C> {
23255        self._id = new_value;
23256        self
23257    }
23258    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23259    /// while executing the actual API request.
23260    ///
23261    /// ````text
23262    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23263    /// ````
23264    ///
23265    /// Sets the *delegate* property to the given value.
23266    pub fn delegate(
23267        mut self,
23268        new_value: &'a mut dyn common::Delegate,
23269    ) -> AdvertiserGroupPatchCall<'a, C> {
23270        self._delegate = Some(new_value);
23271        self
23272    }
23273
23274    /// Set any additional parameter of the query string used in the request.
23275    /// It should be used to set parameters which are not yet available through their own
23276    /// setters.
23277    ///
23278    /// Please note that this method must not be used to set any of the known parameters
23279    /// which have their own setter method. If done anyway, the request will fail.
23280    ///
23281    /// # Additional Parameters
23282    ///
23283    /// * *alt* (query-string) - Data format for the response.
23284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23285    /// * *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.
23286    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23287    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23288    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23289    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23290    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupPatchCall<'a, C>
23291    where
23292        T: AsRef<str>,
23293    {
23294        self._additional_params
23295            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23296        self
23297    }
23298
23299    /// Identifies the authorization scope for the method you are building.
23300    ///
23301    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23302    /// [`Scope::Dfatrafficking`].
23303    ///
23304    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23305    /// tokens for more than one scope.
23306    ///
23307    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23308    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23309    /// sufficient, a read-write scope will do as well.
23310    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupPatchCall<'a, C>
23311    where
23312        St: AsRef<str>,
23313    {
23314        self._scopes.insert(String::from(scope.as_ref()));
23315        self
23316    }
23317    /// Identifies the authorization scope(s) for the method you are building.
23318    ///
23319    /// See [`Self::add_scope()`] for details.
23320    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupPatchCall<'a, C>
23321    where
23322        I: IntoIterator<Item = St>,
23323        St: AsRef<str>,
23324    {
23325        self._scopes
23326            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23327        self
23328    }
23329
23330    /// Removes all scopes, and no default scope will be used either.
23331    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23332    /// for details).
23333    pub fn clear_scopes(mut self) -> AdvertiserGroupPatchCall<'a, C> {
23334        self._scopes.clear();
23335        self
23336    }
23337}
23338
23339/// Updates an existing advertiser group.
23340///
23341/// A builder for the *update* method supported by a *advertiserGroup* resource.
23342/// It is not used directly, but through a [`AdvertiserGroupMethods`] instance.
23343///
23344/// # Example
23345///
23346/// Instantiate a resource method builder
23347///
23348/// ```test_harness,no_run
23349/// # extern crate hyper;
23350/// # extern crate hyper_rustls;
23351/// # extern crate google_dfareporting3d2 as dfareporting3d2;
23352/// use dfareporting3d2::api::AdvertiserGroup;
23353/// # async fn dox() {
23354/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23355///
23356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23357/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23358/// #     secret,
23359/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23360/// # ).build().await.unwrap();
23361///
23362/// # let client = hyper_util::client::legacy::Client::builder(
23363/// #     hyper_util::rt::TokioExecutor::new()
23364/// # )
23365/// # .build(
23366/// #     hyper_rustls::HttpsConnectorBuilder::new()
23367/// #         .with_native_roots()
23368/// #         .unwrap()
23369/// #         .https_or_http()
23370/// #         .enable_http1()
23371/// #         .build()
23372/// # );
23373/// # let mut hub = Dfareporting::new(client, auth);
23374/// // As the method needs a request, you would usually fill it with the desired information
23375/// // into the respective structure. Some of the parts shown here might not be applicable !
23376/// // Values shown here are possibly random and not representative !
23377/// let mut req = AdvertiserGroup::default();
23378///
23379/// // You can configure optional parameters by calling the respective setters at will, and
23380/// // execute the final call using `doit()`.
23381/// // Values shown here are possibly random and not representative !
23382/// let result = hub.advertiser_groups().update(req, -5)
23383///              .doit().await;
23384/// # }
23385/// ```
23386pub struct AdvertiserGroupUpdateCall<'a, C>
23387where
23388    C: 'a,
23389{
23390    hub: &'a Dfareporting<C>,
23391    _request: AdvertiserGroup,
23392    _profile_id: i64,
23393    _delegate: Option<&'a mut dyn common::Delegate>,
23394    _additional_params: HashMap<String, String>,
23395    _scopes: BTreeSet<String>,
23396}
23397
23398impl<'a, C> common::CallBuilder for AdvertiserGroupUpdateCall<'a, C> {}
23399
23400impl<'a, C> AdvertiserGroupUpdateCall<'a, C>
23401where
23402    C: common::Connector,
23403{
23404    /// Perform the operation you have build so far.
23405    pub async fn doit(mut self) -> common::Result<(common::Response, AdvertiserGroup)> {
23406        use std::borrow::Cow;
23407        use std::io::{Read, Seek};
23408
23409        use common::{url::Params, ToParts};
23410        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23411
23412        let mut dd = common::DefaultDelegate;
23413        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23414        dlg.begin(common::MethodInfo {
23415            id: "dfareporting.advertiserGroups.update",
23416            http_method: hyper::Method::PUT,
23417        });
23418
23419        for &field in ["alt", "profileId"].iter() {
23420            if self._additional_params.contains_key(field) {
23421                dlg.finished(false);
23422                return Err(common::Error::FieldClash(field));
23423            }
23424        }
23425
23426        let mut params = Params::with_capacity(4 + self._additional_params.len());
23427        params.push("profileId", self._profile_id.to_string());
23428
23429        params.extend(self._additional_params.iter());
23430
23431        params.push("alt", "json");
23432        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups";
23433        if self._scopes.is_empty() {
23434            self._scopes
23435                .insert(Scope::Dfatrafficking.as_ref().to_string());
23436        }
23437
23438        #[allow(clippy::single_element_loop)]
23439        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
23440            url = params.uri_replacement(url, param_name, find_this, false);
23441        }
23442        {
23443            let to_remove = ["profileId"];
23444            params.remove_params(&to_remove);
23445        }
23446
23447        let url = params.parse_with_url(&url);
23448
23449        let mut json_mime_type = mime::APPLICATION_JSON;
23450        let mut request_value_reader = {
23451            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23452            common::remove_json_null_values(&mut value);
23453            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23454            serde_json::to_writer(&mut dst, &value).unwrap();
23455            dst
23456        };
23457        let request_size = request_value_reader
23458            .seek(std::io::SeekFrom::End(0))
23459            .unwrap();
23460        request_value_reader
23461            .seek(std::io::SeekFrom::Start(0))
23462            .unwrap();
23463
23464        loop {
23465            let token = match self
23466                .hub
23467                .auth
23468                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23469                .await
23470            {
23471                Ok(token) => token,
23472                Err(e) => match dlg.token(e) {
23473                    Ok(token) => token,
23474                    Err(e) => {
23475                        dlg.finished(false);
23476                        return Err(common::Error::MissingToken(e));
23477                    }
23478                },
23479            };
23480            request_value_reader
23481                .seek(std::io::SeekFrom::Start(0))
23482                .unwrap();
23483            let mut req_result = {
23484                let client = &self.hub.client;
23485                dlg.pre_request();
23486                let mut req_builder = hyper::Request::builder()
23487                    .method(hyper::Method::PUT)
23488                    .uri(url.as_str())
23489                    .header(USER_AGENT, self.hub._user_agent.clone());
23490
23491                if let Some(token) = token.as_ref() {
23492                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23493                }
23494
23495                let request = req_builder
23496                    .header(CONTENT_TYPE, json_mime_type.to_string())
23497                    .header(CONTENT_LENGTH, request_size as u64)
23498                    .body(common::to_body(
23499                        request_value_reader.get_ref().clone().into(),
23500                    ));
23501
23502                client.request(request.unwrap()).await
23503            };
23504
23505            match req_result {
23506                Err(err) => {
23507                    if let common::Retry::After(d) = dlg.http_error(&err) {
23508                        sleep(d).await;
23509                        continue;
23510                    }
23511                    dlg.finished(false);
23512                    return Err(common::Error::HttpError(err));
23513                }
23514                Ok(res) => {
23515                    let (mut parts, body) = res.into_parts();
23516                    let mut body = common::Body::new(body);
23517                    if !parts.status.is_success() {
23518                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23519                        let error = serde_json::from_str(&common::to_string(&bytes));
23520                        let response = common::to_response(parts, bytes.into());
23521
23522                        if let common::Retry::After(d) =
23523                            dlg.http_failure(&response, error.as_ref().ok())
23524                        {
23525                            sleep(d).await;
23526                            continue;
23527                        }
23528
23529                        dlg.finished(false);
23530
23531                        return Err(match error {
23532                            Ok(value) => common::Error::BadRequest(value),
23533                            _ => common::Error::Failure(response),
23534                        });
23535                    }
23536                    let response = {
23537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23538                        let encoded = common::to_string(&bytes);
23539                        match serde_json::from_str(&encoded) {
23540                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23541                            Err(error) => {
23542                                dlg.response_json_decode_error(&encoded, &error);
23543                                return Err(common::Error::JsonDecodeError(
23544                                    encoded.to_string(),
23545                                    error,
23546                                ));
23547                            }
23548                        }
23549                    };
23550
23551                    dlg.finished(true);
23552                    return Ok(response);
23553                }
23554            }
23555        }
23556    }
23557
23558    ///
23559    /// Sets the *request* property to the given value.
23560    ///
23561    /// Even though the property as already been set when instantiating this call,
23562    /// we provide this method for API completeness.
23563    pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, C> {
23564        self._request = new_value;
23565        self
23566    }
23567    /// User profile ID associated with this request.
23568    ///
23569    /// Sets the *profile id* path property to the given value.
23570    ///
23571    /// Even though the property as already been set when instantiating this call,
23572    /// we provide this method for API completeness.
23573    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGroupUpdateCall<'a, C> {
23574        self._profile_id = new_value;
23575        self
23576    }
23577    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23578    /// while executing the actual API request.
23579    ///
23580    /// ````text
23581    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23582    /// ````
23583    ///
23584    /// Sets the *delegate* property to the given value.
23585    pub fn delegate(
23586        mut self,
23587        new_value: &'a mut dyn common::Delegate,
23588    ) -> AdvertiserGroupUpdateCall<'a, C> {
23589        self._delegate = Some(new_value);
23590        self
23591    }
23592
23593    /// Set any additional parameter of the query string used in the request.
23594    /// It should be used to set parameters which are not yet available through their own
23595    /// setters.
23596    ///
23597    /// Please note that this method must not be used to set any of the known parameters
23598    /// which have their own setter method. If done anyway, the request will fail.
23599    ///
23600    /// # Additional Parameters
23601    ///
23602    /// * *alt* (query-string) - Data format for the response.
23603    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23604    /// * *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.
23605    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23606    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23607    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23608    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23609    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGroupUpdateCall<'a, C>
23610    where
23611        T: AsRef<str>,
23612    {
23613        self._additional_params
23614            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23615        self
23616    }
23617
23618    /// Identifies the authorization scope for the method you are building.
23619    ///
23620    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23621    /// [`Scope::Dfatrafficking`].
23622    ///
23623    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23624    /// tokens for more than one scope.
23625    ///
23626    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23627    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23628    /// sufficient, a read-write scope will do as well.
23629    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGroupUpdateCall<'a, C>
23630    where
23631        St: AsRef<str>,
23632    {
23633        self._scopes.insert(String::from(scope.as_ref()));
23634        self
23635    }
23636    /// Identifies the authorization scope(s) for the method you are building.
23637    ///
23638    /// See [`Self::add_scope()`] for details.
23639    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGroupUpdateCall<'a, C>
23640    where
23641        I: IntoIterator<Item = St>,
23642        St: AsRef<str>,
23643    {
23644        self._scopes
23645            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23646        self
23647    }
23648
23649    /// Removes all scopes, and no default scope will be used either.
23650    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23651    /// for details).
23652    pub fn clear_scopes(mut self) -> AdvertiserGroupUpdateCall<'a, C> {
23653        self._scopes.clear();
23654        self
23655    }
23656}
23657
23658/// Gets one landing page by ID.
23659///
23660/// A builder for the *get* method supported by a *advertiserLandingPage* resource.
23661/// It is not used directly, but through a [`AdvertiserLandingPageMethods`] instance.
23662///
23663/// # Example
23664///
23665/// Instantiate a resource method builder
23666///
23667/// ```test_harness,no_run
23668/// # extern crate hyper;
23669/// # extern crate hyper_rustls;
23670/// # extern crate google_dfareporting3d2 as dfareporting3d2;
23671/// # async fn dox() {
23672/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23673///
23674/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23675/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23676/// #     secret,
23677/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23678/// # ).build().await.unwrap();
23679///
23680/// # let client = hyper_util::client::legacy::Client::builder(
23681/// #     hyper_util::rt::TokioExecutor::new()
23682/// # )
23683/// # .build(
23684/// #     hyper_rustls::HttpsConnectorBuilder::new()
23685/// #         .with_native_roots()
23686/// #         .unwrap()
23687/// #         .https_or_http()
23688/// #         .enable_http1()
23689/// #         .build()
23690/// # );
23691/// # let mut hub = Dfareporting::new(client, auth);
23692/// // You can configure optional parameters by calling the respective setters at will, and
23693/// // execute the final call using `doit()`.
23694/// // Values shown here are possibly random and not representative !
23695/// let result = hub.advertiser_landing_pages().get(-18, -8)
23696///              .doit().await;
23697/// # }
23698/// ```
23699pub struct AdvertiserLandingPageGetCall<'a, C>
23700where
23701    C: 'a,
23702{
23703    hub: &'a Dfareporting<C>,
23704    _profile_id: i64,
23705    _id: i64,
23706    _delegate: Option<&'a mut dyn common::Delegate>,
23707    _additional_params: HashMap<String, String>,
23708    _scopes: BTreeSet<String>,
23709}
23710
23711impl<'a, C> common::CallBuilder for AdvertiserLandingPageGetCall<'a, C> {}
23712
23713impl<'a, C> AdvertiserLandingPageGetCall<'a, C>
23714where
23715    C: common::Connector,
23716{
23717    /// Perform the operation you have build so far.
23718    pub async fn doit(mut self) -> common::Result<(common::Response, LandingPage)> {
23719        use std::borrow::Cow;
23720        use std::io::{Read, Seek};
23721
23722        use common::{url::Params, ToParts};
23723        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23724
23725        let mut dd = common::DefaultDelegate;
23726        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23727        dlg.begin(common::MethodInfo {
23728            id: "dfareporting.advertiserLandingPages.get",
23729            http_method: hyper::Method::GET,
23730        });
23731
23732        for &field in ["alt", "profileId", "id"].iter() {
23733            if self._additional_params.contains_key(field) {
23734                dlg.finished(false);
23735                return Err(common::Error::FieldClash(field));
23736            }
23737        }
23738
23739        let mut params = Params::with_capacity(4 + self._additional_params.len());
23740        params.push("profileId", self._profile_id.to_string());
23741        params.push("id", self._id.to_string());
23742
23743        params.extend(self._additional_params.iter());
23744
23745        params.push("alt", "json");
23746        let mut url =
23747            self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages/{id}";
23748        if self._scopes.is_empty() {
23749            self._scopes
23750                .insert(Scope::Dfatrafficking.as_ref().to_string());
23751        }
23752
23753        #[allow(clippy::single_element_loop)]
23754        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
23755            url = params.uri_replacement(url, param_name, find_this, false);
23756        }
23757        {
23758            let to_remove = ["id", "profileId"];
23759            params.remove_params(&to_remove);
23760        }
23761
23762        let url = params.parse_with_url(&url);
23763
23764        loop {
23765            let token = match self
23766                .hub
23767                .auth
23768                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23769                .await
23770            {
23771                Ok(token) => token,
23772                Err(e) => match dlg.token(e) {
23773                    Ok(token) => token,
23774                    Err(e) => {
23775                        dlg.finished(false);
23776                        return Err(common::Error::MissingToken(e));
23777                    }
23778                },
23779            };
23780            let mut req_result = {
23781                let client = &self.hub.client;
23782                dlg.pre_request();
23783                let mut req_builder = hyper::Request::builder()
23784                    .method(hyper::Method::GET)
23785                    .uri(url.as_str())
23786                    .header(USER_AGENT, self.hub._user_agent.clone());
23787
23788                if let Some(token) = token.as_ref() {
23789                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23790                }
23791
23792                let request = req_builder
23793                    .header(CONTENT_LENGTH, 0_u64)
23794                    .body(common::to_body::<String>(None));
23795
23796                client.request(request.unwrap()).await
23797            };
23798
23799            match req_result {
23800                Err(err) => {
23801                    if let common::Retry::After(d) = dlg.http_error(&err) {
23802                        sleep(d).await;
23803                        continue;
23804                    }
23805                    dlg.finished(false);
23806                    return Err(common::Error::HttpError(err));
23807                }
23808                Ok(res) => {
23809                    let (mut parts, body) = res.into_parts();
23810                    let mut body = common::Body::new(body);
23811                    if !parts.status.is_success() {
23812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23813                        let error = serde_json::from_str(&common::to_string(&bytes));
23814                        let response = common::to_response(parts, bytes.into());
23815
23816                        if let common::Retry::After(d) =
23817                            dlg.http_failure(&response, error.as_ref().ok())
23818                        {
23819                            sleep(d).await;
23820                            continue;
23821                        }
23822
23823                        dlg.finished(false);
23824
23825                        return Err(match error {
23826                            Ok(value) => common::Error::BadRequest(value),
23827                            _ => common::Error::Failure(response),
23828                        });
23829                    }
23830                    let response = {
23831                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23832                        let encoded = common::to_string(&bytes);
23833                        match serde_json::from_str(&encoded) {
23834                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23835                            Err(error) => {
23836                                dlg.response_json_decode_error(&encoded, &error);
23837                                return Err(common::Error::JsonDecodeError(
23838                                    encoded.to_string(),
23839                                    error,
23840                                ));
23841                            }
23842                        }
23843                    };
23844
23845                    dlg.finished(true);
23846                    return Ok(response);
23847                }
23848            }
23849        }
23850    }
23851
23852    /// User profile ID associated with this request.
23853    ///
23854    /// Sets the *profile id* path property to the given value.
23855    ///
23856    /// Even though the property as already been set when instantiating this call,
23857    /// we provide this method for API completeness.
23858    pub fn profile_id(mut self, new_value: i64) -> AdvertiserLandingPageGetCall<'a, C> {
23859        self._profile_id = new_value;
23860        self
23861    }
23862    /// Landing page ID.
23863    ///
23864    /// Sets the *id* path property to the given value.
23865    ///
23866    /// Even though the property as already been set when instantiating this call,
23867    /// we provide this method for API completeness.
23868    pub fn id(mut self, new_value: i64) -> AdvertiserLandingPageGetCall<'a, C> {
23869        self._id = new_value;
23870        self
23871    }
23872    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23873    /// while executing the actual API request.
23874    ///
23875    /// ````text
23876    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23877    /// ````
23878    ///
23879    /// Sets the *delegate* property to the given value.
23880    pub fn delegate(
23881        mut self,
23882        new_value: &'a mut dyn common::Delegate,
23883    ) -> AdvertiserLandingPageGetCall<'a, C> {
23884        self._delegate = Some(new_value);
23885        self
23886    }
23887
23888    /// Set any additional parameter of the query string used in the request.
23889    /// It should be used to set parameters which are not yet available through their own
23890    /// setters.
23891    ///
23892    /// Please note that this method must not be used to set any of the known parameters
23893    /// which have their own setter method. If done anyway, the request will fail.
23894    ///
23895    /// # Additional Parameters
23896    ///
23897    /// * *alt* (query-string) - Data format for the response.
23898    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23899    /// * *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.
23900    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23901    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23902    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
23903    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
23904    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserLandingPageGetCall<'a, C>
23905    where
23906        T: AsRef<str>,
23907    {
23908        self._additional_params
23909            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23910        self
23911    }
23912
23913    /// Identifies the authorization scope for the method you are building.
23914    ///
23915    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23916    /// [`Scope::Dfatrafficking`].
23917    ///
23918    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23919    /// tokens for more than one scope.
23920    ///
23921    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23922    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23923    /// sufficient, a read-write scope will do as well.
23924    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserLandingPageGetCall<'a, C>
23925    where
23926        St: AsRef<str>,
23927    {
23928        self._scopes.insert(String::from(scope.as_ref()));
23929        self
23930    }
23931    /// Identifies the authorization scope(s) for the method you are building.
23932    ///
23933    /// See [`Self::add_scope()`] for details.
23934    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserLandingPageGetCall<'a, C>
23935    where
23936        I: IntoIterator<Item = St>,
23937        St: AsRef<str>,
23938    {
23939        self._scopes
23940            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23941        self
23942    }
23943
23944    /// Removes all scopes, and no default scope will be used either.
23945    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23946    /// for details).
23947    pub fn clear_scopes(mut self) -> AdvertiserLandingPageGetCall<'a, C> {
23948        self._scopes.clear();
23949        self
23950    }
23951}
23952
23953/// Inserts a new landing page.
23954///
23955/// A builder for the *insert* method supported by a *advertiserLandingPage* resource.
23956/// It is not used directly, but through a [`AdvertiserLandingPageMethods`] instance.
23957///
23958/// # Example
23959///
23960/// Instantiate a resource method builder
23961///
23962/// ```test_harness,no_run
23963/// # extern crate hyper;
23964/// # extern crate hyper_rustls;
23965/// # extern crate google_dfareporting3d2 as dfareporting3d2;
23966/// use dfareporting3d2::api::LandingPage;
23967/// # async fn dox() {
23968/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23969///
23970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23972/// #     secret,
23973/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23974/// # ).build().await.unwrap();
23975///
23976/// # let client = hyper_util::client::legacy::Client::builder(
23977/// #     hyper_util::rt::TokioExecutor::new()
23978/// # )
23979/// # .build(
23980/// #     hyper_rustls::HttpsConnectorBuilder::new()
23981/// #         .with_native_roots()
23982/// #         .unwrap()
23983/// #         .https_or_http()
23984/// #         .enable_http1()
23985/// #         .build()
23986/// # );
23987/// # let mut hub = Dfareporting::new(client, auth);
23988/// // As the method needs a request, you would usually fill it with the desired information
23989/// // into the respective structure. Some of the parts shown here might not be applicable !
23990/// // Values shown here are possibly random and not representative !
23991/// let mut req = LandingPage::default();
23992///
23993/// // You can configure optional parameters by calling the respective setters at will, and
23994/// // execute the final call using `doit()`.
23995/// // Values shown here are possibly random and not representative !
23996/// let result = hub.advertiser_landing_pages().insert(req, -56)
23997///              .doit().await;
23998/// # }
23999/// ```
24000pub struct AdvertiserLandingPageInsertCall<'a, C>
24001where
24002    C: 'a,
24003{
24004    hub: &'a Dfareporting<C>,
24005    _request: LandingPage,
24006    _profile_id: i64,
24007    _delegate: Option<&'a mut dyn common::Delegate>,
24008    _additional_params: HashMap<String, String>,
24009    _scopes: BTreeSet<String>,
24010}
24011
24012impl<'a, C> common::CallBuilder for AdvertiserLandingPageInsertCall<'a, C> {}
24013
24014impl<'a, C> AdvertiserLandingPageInsertCall<'a, C>
24015where
24016    C: common::Connector,
24017{
24018    /// Perform the operation you have build so far.
24019    pub async fn doit(mut self) -> common::Result<(common::Response, LandingPage)> {
24020        use std::borrow::Cow;
24021        use std::io::{Read, Seek};
24022
24023        use common::{url::Params, ToParts};
24024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24025
24026        let mut dd = common::DefaultDelegate;
24027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24028        dlg.begin(common::MethodInfo {
24029            id: "dfareporting.advertiserLandingPages.insert",
24030            http_method: hyper::Method::POST,
24031        });
24032
24033        for &field in ["alt", "profileId"].iter() {
24034            if self._additional_params.contains_key(field) {
24035                dlg.finished(false);
24036                return Err(common::Error::FieldClash(field));
24037            }
24038        }
24039
24040        let mut params = Params::with_capacity(4 + self._additional_params.len());
24041        params.push("profileId", self._profile_id.to_string());
24042
24043        params.extend(self._additional_params.iter());
24044
24045        params.push("alt", "json");
24046        let mut url =
24047            self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages";
24048        if self._scopes.is_empty() {
24049            self._scopes
24050                .insert(Scope::Dfatrafficking.as_ref().to_string());
24051        }
24052
24053        #[allow(clippy::single_element_loop)]
24054        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
24055            url = params.uri_replacement(url, param_name, find_this, false);
24056        }
24057        {
24058            let to_remove = ["profileId"];
24059            params.remove_params(&to_remove);
24060        }
24061
24062        let url = params.parse_with_url(&url);
24063
24064        let mut json_mime_type = mime::APPLICATION_JSON;
24065        let mut request_value_reader = {
24066            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24067            common::remove_json_null_values(&mut value);
24068            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24069            serde_json::to_writer(&mut dst, &value).unwrap();
24070            dst
24071        };
24072        let request_size = request_value_reader
24073            .seek(std::io::SeekFrom::End(0))
24074            .unwrap();
24075        request_value_reader
24076            .seek(std::io::SeekFrom::Start(0))
24077            .unwrap();
24078
24079        loop {
24080            let token = match self
24081                .hub
24082                .auth
24083                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24084                .await
24085            {
24086                Ok(token) => token,
24087                Err(e) => match dlg.token(e) {
24088                    Ok(token) => token,
24089                    Err(e) => {
24090                        dlg.finished(false);
24091                        return Err(common::Error::MissingToken(e));
24092                    }
24093                },
24094            };
24095            request_value_reader
24096                .seek(std::io::SeekFrom::Start(0))
24097                .unwrap();
24098            let mut req_result = {
24099                let client = &self.hub.client;
24100                dlg.pre_request();
24101                let mut req_builder = hyper::Request::builder()
24102                    .method(hyper::Method::POST)
24103                    .uri(url.as_str())
24104                    .header(USER_AGENT, self.hub._user_agent.clone());
24105
24106                if let Some(token) = token.as_ref() {
24107                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24108                }
24109
24110                let request = req_builder
24111                    .header(CONTENT_TYPE, json_mime_type.to_string())
24112                    .header(CONTENT_LENGTH, request_size as u64)
24113                    .body(common::to_body(
24114                        request_value_reader.get_ref().clone().into(),
24115                    ));
24116
24117                client.request(request.unwrap()).await
24118            };
24119
24120            match req_result {
24121                Err(err) => {
24122                    if let common::Retry::After(d) = dlg.http_error(&err) {
24123                        sleep(d).await;
24124                        continue;
24125                    }
24126                    dlg.finished(false);
24127                    return Err(common::Error::HttpError(err));
24128                }
24129                Ok(res) => {
24130                    let (mut parts, body) = res.into_parts();
24131                    let mut body = common::Body::new(body);
24132                    if !parts.status.is_success() {
24133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24134                        let error = serde_json::from_str(&common::to_string(&bytes));
24135                        let response = common::to_response(parts, bytes.into());
24136
24137                        if let common::Retry::After(d) =
24138                            dlg.http_failure(&response, error.as_ref().ok())
24139                        {
24140                            sleep(d).await;
24141                            continue;
24142                        }
24143
24144                        dlg.finished(false);
24145
24146                        return Err(match error {
24147                            Ok(value) => common::Error::BadRequest(value),
24148                            _ => common::Error::Failure(response),
24149                        });
24150                    }
24151                    let response = {
24152                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24153                        let encoded = common::to_string(&bytes);
24154                        match serde_json::from_str(&encoded) {
24155                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24156                            Err(error) => {
24157                                dlg.response_json_decode_error(&encoded, &error);
24158                                return Err(common::Error::JsonDecodeError(
24159                                    encoded.to_string(),
24160                                    error,
24161                                ));
24162                            }
24163                        }
24164                    };
24165
24166                    dlg.finished(true);
24167                    return Ok(response);
24168                }
24169            }
24170        }
24171    }
24172
24173    ///
24174    /// Sets the *request* property to the given value.
24175    ///
24176    /// Even though the property as already been set when instantiating this call,
24177    /// we provide this method for API completeness.
24178    pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPageInsertCall<'a, C> {
24179        self._request = new_value;
24180        self
24181    }
24182    /// User profile ID associated with this request.
24183    ///
24184    /// Sets the *profile id* path property to the given value.
24185    ///
24186    /// Even though the property as already been set when instantiating this call,
24187    /// we provide this method for API completeness.
24188    pub fn profile_id(mut self, new_value: i64) -> AdvertiserLandingPageInsertCall<'a, C> {
24189        self._profile_id = new_value;
24190        self
24191    }
24192    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24193    /// while executing the actual API request.
24194    ///
24195    /// ````text
24196    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24197    /// ````
24198    ///
24199    /// Sets the *delegate* property to the given value.
24200    pub fn delegate(
24201        mut self,
24202        new_value: &'a mut dyn common::Delegate,
24203    ) -> AdvertiserLandingPageInsertCall<'a, C> {
24204        self._delegate = Some(new_value);
24205        self
24206    }
24207
24208    /// Set any additional parameter of the query string used in the request.
24209    /// It should be used to set parameters which are not yet available through their own
24210    /// setters.
24211    ///
24212    /// Please note that this method must not be used to set any of the known parameters
24213    /// which have their own setter method. If done anyway, the request will fail.
24214    ///
24215    /// # Additional Parameters
24216    ///
24217    /// * *alt* (query-string) - Data format for the response.
24218    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24219    /// * *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.
24220    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24221    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24222    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24223    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24224    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserLandingPageInsertCall<'a, C>
24225    where
24226        T: AsRef<str>,
24227    {
24228        self._additional_params
24229            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24230        self
24231    }
24232
24233    /// Identifies the authorization scope for the method you are building.
24234    ///
24235    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24236    /// [`Scope::Dfatrafficking`].
24237    ///
24238    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24239    /// tokens for more than one scope.
24240    ///
24241    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24242    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24243    /// sufficient, a read-write scope will do as well.
24244    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserLandingPageInsertCall<'a, C>
24245    where
24246        St: AsRef<str>,
24247    {
24248        self._scopes.insert(String::from(scope.as_ref()));
24249        self
24250    }
24251    /// Identifies the authorization scope(s) for the method you are building.
24252    ///
24253    /// See [`Self::add_scope()`] for details.
24254    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserLandingPageInsertCall<'a, C>
24255    where
24256        I: IntoIterator<Item = St>,
24257        St: AsRef<str>,
24258    {
24259        self._scopes
24260            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24261        self
24262    }
24263
24264    /// Removes all scopes, and no default scope will be used either.
24265    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24266    /// for details).
24267    pub fn clear_scopes(mut self) -> AdvertiserLandingPageInsertCall<'a, C> {
24268        self._scopes.clear();
24269        self
24270    }
24271}
24272
24273/// Retrieves a list of landing pages.
24274///
24275/// A builder for the *list* method supported by a *advertiserLandingPage* resource.
24276/// It is not used directly, but through a [`AdvertiserLandingPageMethods`] instance.
24277///
24278/// # Example
24279///
24280/// Instantiate a resource method builder
24281///
24282/// ```test_harness,no_run
24283/// # extern crate hyper;
24284/// # extern crate hyper_rustls;
24285/// # extern crate google_dfareporting3d2 as dfareporting3d2;
24286/// # async fn dox() {
24287/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24288///
24289/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24290/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24291/// #     secret,
24292/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24293/// # ).build().await.unwrap();
24294///
24295/// # let client = hyper_util::client::legacy::Client::builder(
24296/// #     hyper_util::rt::TokioExecutor::new()
24297/// # )
24298/// # .build(
24299/// #     hyper_rustls::HttpsConnectorBuilder::new()
24300/// #         .with_native_roots()
24301/// #         .unwrap()
24302/// #         .https_or_http()
24303/// #         .enable_http1()
24304/// #         .build()
24305/// # );
24306/// # let mut hub = Dfareporting::new(client, auth);
24307/// // You can configure optional parameters by calling the respective setters at will, and
24308/// // execute the final call using `doit()`.
24309/// // Values shown here are possibly random and not representative !
24310/// let result = hub.advertiser_landing_pages().list(-7)
24311///              .subaccount_id(-30)
24312///              .sort_order("diam")
24313///              .sort_field("dolores")
24314///              .search_string("dolores")
24315///              .page_token("et")
24316///              .max_results(-93)
24317///              .add_ids(-11)
24318///              .add_campaign_ids(-85)
24319///              .archived(false)
24320///              .add_advertiser_ids(-80)
24321///              .doit().await;
24322/// # }
24323/// ```
24324pub struct AdvertiserLandingPageListCall<'a, C>
24325where
24326    C: 'a,
24327{
24328    hub: &'a Dfareporting<C>,
24329    _profile_id: i64,
24330    _subaccount_id: Option<i64>,
24331    _sort_order: Option<String>,
24332    _sort_field: Option<String>,
24333    _search_string: Option<String>,
24334    _page_token: Option<String>,
24335    _max_results: Option<i32>,
24336    _ids: Vec<i64>,
24337    _campaign_ids: Vec<i64>,
24338    _archived: Option<bool>,
24339    _advertiser_ids: Vec<i64>,
24340    _delegate: Option<&'a mut dyn common::Delegate>,
24341    _additional_params: HashMap<String, String>,
24342    _scopes: BTreeSet<String>,
24343}
24344
24345impl<'a, C> common::CallBuilder for AdvertiserLandingPageListCall<'a, C> {}
24346
24347impl<'a, C> AdvertiserLandingPageListCall<'a, C>
24348where
24349    C: common::Connector,
24350{
24351    /// Perform the operation you have build so far.
24352    pub async fn doit(
24353        mut self,
24354    ) -> common::Result<(common::Response, AdvertiserLandingPagesListResponse)> {
24355        use std::borrow::Cow;
24356        use std::io::{Read, Seek};
24357
24358        use common::{url::Params, ToParts};
24359        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24360
24361        let mut dd = common::DefaultDelegate;
24362        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24363        dlg.begin(common::MethodInfo {
24364            id: "dfareporting.advertiserLandingPages.list",
24365            http_method: hyper::Method::GET,
24366        });
24367
24368        for &field in [
24369            "alt",
24370            "profileId",
24371            "subaccountId",
24372            "sortOrder",
24373            "sortField",
24374            "searchString",
24375            "pageToken",
24376            "maxResults",
24377            "ids",
24378            "campaignIds",
24379            "archived",
24380            "advertiserIds",
24381        ]
24382        .iter()
24383        {
24384            if self._additional_params.contains_key(field) {
24385                dlg.finished(false);
24386                return Err(common::Error::FieldClash(field));
24387            }
24388        }
24389
24390        let mut params = Params::with_capacity(13 + self._additional_params.len());
24391        params.push("profileId", self._profile_id.to_string());
24392        if let Some(value) = self._subaccount_id.as_ref() {
24393            params.push("subaccountId", value.to_string());
24394        }
24395        if let Some(value) = self._sort_order.as_ref() {
24396            params.push("sortOrder", value);
24397        }
24398        if let Some(value) = self._sort_field.as_ref() {
24399            params.push("sortField", value);
24400        }
24401        if let Some(value) = self._search_string.as_ref() {
24402            params.push("searchString", value);
24403        }
24404        if let Some(value) = self._page_token.as_ref() {
24405            params.push("pageToken", value);
24406        }
24407        if let Some(value) = self._max_results.as_ref() {
24408            params.push("maxResults", value.to_string());
24409        }
24410        if !self._ids.is_empty() {
24411            for f in self._ids.iter() {
24412                params.push("ids", f.to_string());
24413            }
24414        }
24415        if !self._campaign_ids.is_empty() {
24416            for f in self._campaign_ids.iter() {
24417                params.push("campaignIds", f.to_string());
24418            }
24419        }
24420        if let Some(value) = self._archived.as_ref() {
24421            params.push("archived", value.to_string());
24422        }
24423        if !self._advertiser_ids.is_empty() {
24424            for f in self._advertiser_ids.iter() {
24425                params.push("advertiserIds", f.to_string());
24426            }
24427        }
24428
24429        params.extend(self._additional_params.iter());
24430
24431        params.push("alt", "json");
24432        let mut url =
24433            self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages";
24434        if self._scopes.is_empty() {
24435            self._scopes
24436                .insert(Scope::Dfatrafficking.as_ref().to_string());
24437        }
24438
24439        #[allow(clippy::single_element_loop)]
24440        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
24441            url = params.uri_replacement(url, param_name, find_this, false);
24442        }
24443        {
24444            let to_remove = ["profileId"];
24445            params.remove_params(&to_remove);
24446        }
24447
24448        let url = params.parse_with_url(&url);
24449
24450        loop {
24451            let token = match self
24452                .hub
24453                .auth
24454                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24455                .await
24456            {
24457                Ok(token) => token,
24458                Err(e) => match dlg.token(e) {
24459                    Ok(token) => token,
24460                    Err(e) => {
24461                        dlg.finished(false);
24462                        return Err(common::Error::MissingToken(e));
24463                    }
24464                },
24465            };
24466            let mut req_result = {
24467                let client = &self.hub.client;
24468                dlg.pre_request();
24469                let mut req_builder = hyper::Request::builder()
24470                    .method(hyper::Method::GET)
24471                    .uri(url.as_str())
24472                    .header(USER_AGENT, self.hub._user_agent.clone());
24473
24474                if let Some(token) = token.as_ref() {
24475                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24476                }
24477
24478                let request = req_builder
24479                    .header(CONTENT_LENGTH, 0_u64)
24480                    .body(common::to_body::<String>(None));
24481
24482                client.request(request.unwrap()).await
24483            };
24484
24485            match req_result {
24486                Err(err) => {
24487                    if let common::Retry::After(d) = dlg.http_error(&err) {
24488                        sleep(d).await;
24489                        continue;
24490                    }
24491                    dlg.finished(false);
24492                    return Err(common::Error::HttpError(err));
24493                }
24494                Ok(res) => {
24495                    let (mut parts, body) = res.into_parts();
24496                    let mut body = common::Body::new(body);
24497                    if !parts.status.is_success() {
24498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24499                        let error = serde_json::from_str(&common::to_string(&bytes));
24500                        let response = common::to_response(parts, bytes.into());
24501
24502                        if let common::Retry::After(d) =
24503                            dlg.http_failure(&response, error.as_ref().ok())
24504                        {
24505                            sleep(d).await;
24506                            continue;
24507                        }
24508
24509                        dlg.finished(false);
24510
24511                        return Err(match error {
24512                            Ok(value) => common::Error::BadRequest(value),
24513                            _ => common::Error::Failure(response),
24514                        });
24515                    }
24516                    let response = {
24517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24518                        let encoded = common::to_string(&bytes);
24519                        match serde_json::from_str(&encoded) {
24520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24521                            Err(error) => {
24522                                dlg.response_json_decode_error(&encoded, &error);
24523                                return Err(common::Error::JsonDecodeError(
24524                                    encoded.to_string(),
24525                                    error,
24526                                ));
24527                            }
24528                        }
24529                    };
24530
24531                    dlg.finished(true);
24532                    return Ok(response);
24533                }
24534            }
24535        }
24536    }
24537
24538    /// User profile ID associated with this request.
24539    ///
24540    /// Sets the *profile id* path property to the given value.
24541    ///
24542    /// Even though the property as already been set when instantiating this call,
24543    /// we provide this method for API completeness.
24544    pub fn profile_id(mut self, new_value: i64) -> AdvertiserLandingPageListCall<'a, C> {
24545        self._profile_id = new_value;
24546        self
24547    }
24548    /// Select only landing pages that belong to this subaccount.
24549    ///
24550    /// Sets the *subaccount id* query property to the given value.
24551    pub fn subaccount_id(mut self, new_value: i64) -> AdvertiserLandingPageListCall<'a, C> {
24552        self._subaccount_id = Some(new_value);
24553        self
24554    }
24555    /// Order of sorted results.
24556    ///
24557    /// Sets the *sort order* query property to the given value.
24558    pub fn sort_order(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, C> {
24559        self._sort_order = Some(new_value.to_string());
24560        self
24561    }
24562    /// Field by which to sort the list.
24563    ///
24564    /// Sets the *sort field* query property to the given value.
24565    pub fn sort_field(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, C> {
24566        self._sort_field = Some(new_value.to_string());
24567        self
24568    }
24569    /// Allows searching for landing pages by name or ID. Wildcards (*) are allowed. For example, "landingpage*2017" will return landing pages with names like "landingpage July 2017", "landingpage March 2017", or simply "landingpage 2017". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "landingpage" will match campaigns with name "my landingpage", "landingpage 2015", or simply "landingpage".
24570    ///
24571    /// Sets the *search string* query property to the given value.
24572    pub fn search_string(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, C> {
24573        self._search_string = Some(new_value.to_string());
24574        self
24575    }
24576    /// Value of the nextPageToken from the previous result page.
24577    ///
24578    /// Sets the *page token* query property to the given value.
24579    pub fn page_token(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, C> {
24580        self._page_token = Some(new_value.to_string());
24581        self
24582    }
24583    /// Maximum number of results to return.
24584    ///
24585    /// Sets the *max results* query property to the given value.
24586    pub fn max_results(mut self, new_value: i32) -> AdvertiserLandingPageListCall<'a, C> {
24587        self._max_results = Some(new_value);
24588        self
24589    }
24590    /// Select only landing pages with these IDs.
24591    ///
24592    /// Append the given value to the *ids* query property.
24593    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
24594    pub fn add_ids(mut self, new_value: i64) -> AdvertiserLandingPageListCall<'a, C> {
24595        self._ids.push(new_value);
24596        self
24597    }
24598    /// Select only landing pages that are associated with these campaigns.
24599    ///
24600    /// Append the given value to the *campaign ids* query property.
24601    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
24602    pub fn add_campaign_ids(mut self, new_value: i64) -> AdvertiserLandingPageListCall<'a, C> {
24603        self._campaign_ids.push(new_value);
24604        self
24605    }
24606    /// Select only archived landing pages. Don't set this field to select both archived and non-archived landing pages.
24607    ///
24608    /// Sets the *archived* query property to the given value.
24609    pub fn archived(mut self, new_value: bool) -> AdvertiserLandingPageListCall<'a, C> {
24610        self._archived = Some(new_value);
24611        self
24612    }
24613    /// Select only landing pages that belong to these advertisers.
24614    ///
24615    /// Append the given value to the *advertiser ids* query property.
24616    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
24617    pub fn add_advertiser_ids(mut self, new_value: i64) -> AdvertiserLandingPageListCall<'a, C> {
24618        self._advertiser_ids.push(new_value);
24619        self
24620    }
24621    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24622    /// while executing the actual API request.
24623    ///
24624    /// ````text
24625    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24626    /// ````
24627    ///
24628    /// Sets the *delegate* property to the given value.
24629    pub fn delegate(
24630        mut self,
24631        new_value: &'a mut dyn common::Delegate,
24632    ) -> AdvertiserLandingPageListCall<'a, C> {
24633        self._delegate = Some(new_value);
24634        self
24635    }
24636
24637    /// Set any additional parameter of the query string used in the request.
24638    /// It should be used to set parameters which are not yet available through their own
24639    /// setters.
24640    ///
24641    /// Please note that this method must not be used to set any of the known parameters
24642    /// which have their own setter method. If done anyway, the request will fail.
24643    ///
24644    /// # Additional Parameters
24645    ///
24646    /// * *alt* (query-string) - Data format for the response.
24647    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24648    /// * *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.
24649    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24650    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24651    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24652    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24653    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserLandingPageListCall<'a, C>
24654    where
24655        T: AsRef<str>,
24656    {
24657        self._additional_params
24658            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24659        self
24660    }
24661
24662    /// Identifies the authorization scope for the method you are building.
24663    ///
24664    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24665    /// [`Scope::Dfatrafficking`].
24666    ///
24667    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24668    /// tokens for more than one scope.
24669    ///
24670    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24671    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24672    /// sufficient, a read-write scope will do as well.
24673    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserLandingPageListCall<'a, C>
24674    where
24675        St: AsRef<str>,
24676    {
24677        self._scopes.insert(String::from(scope.as_ref()));
24678        self
24679    }
24680    /// Identifies the authorization scope(s) for the method you are building.
24681    ///
24682    /// See [`Self::add_scope()`] for details.
24683    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserLandingPageListCall<'a, C>
24684    where
24685        I: IntoIterator<Item = St>,
24686        St: AsRef<str>,
24687    {
24688        self._scopes
24689            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24690        self
24691    }
24692
24693    /// Removes all scopes, and no default scope will be used either.
24694    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24695    /// for details).
24696    pub fn clear_scopes(mut self) -> AdvertiserLandingPageListCall<'a, C> {
24697        self._scopes.clear();
24698        self
24699    }
24700}
24701
24702/// Updates an existing landing page. This method supports patch semantics.
24703///
24704/// A builder for the *patch* method supported by a *advertiserLandingPage* resource.
24705/// It is not used directly, but through a [`AdvertiserLandingPageMethods`] instance.
24706///
24707/// # Example
24708///
24709/// Instantiate a resource method builder
24710///
24711/// ```test_harness,no_run
24712/// # extern crate hyper;
24713/// # extern crate hyper_rustls;
24714/// # extern crate google_dfareporting3d2 as dfareporting3d2;
24715/// use dfareporting3d2::api::LandingPage;
24716/// # async fn dox() {
24717/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24718///
24719/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24720/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24721/// #     secret,
24722/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24723/// # ).build().await.unwrap();
24724///
24725/// # let client = hyper_util::client::legacy::Client::builder(
24726/// #     hyper_util::rt::TokioExecutor::new()
24727/// # )
24728/// # .build(
24729/// #     hyper_rustls::HttpsConnectorBuilder::new()
24730/// #         .with_native_roots()
24731/// #         .unwrap()
24732/// #         .https_or_http()
24733/// #         .enable_http1()
24734/// #         .build()
24735/// # );
24736/// # let mut hub = Dfareporting::new(client, auth);
24737/// // As the method needs a request, you would usually fill it with the desired information
24738/// // into the respective structure. Some of the parts shown here might not be applicable !
24739/// // Values shown here are possibly random and not representative !
24740/// let mut req = LandingPage::default();
24741///
24742/// // You can configure optional parameters by calling the respective setters at will, and
24743/// // execute the final call using `doit()`.
24744/// // Values shown here are possibly random and not representative !
24745/// let result = hub.advertiser_landing_pages().patch(req, -61, -91)
24746///              .doit().await;
24747/// # }
24748/// ```
24749pub struct AdvertiserLandingPagePatchCall<'a, C>
24750where
24751    C: 'a,
24752{
24753    hub: &'a Dfareporting<C>,
24754    _request: LandingPage,
24755    _profile_id: i64,
24756    _id: i64,
24757    _delegate: Option<&'a mut dyn common::Delegate>,
24758    _additional_params: HashMap<String, String>,
24759    _scopes: BTreeSet<String>,
24760}
24761
24762impl<'a, C> common::CallBuilder for AdvertiserLandingPagePatchCall<'a, C> {}
24763
24764impl<'a, C> AdvertiserLandingPagePatchCall<'a, C>
24765where
24766    C: common::Connector,
24767{
24768    /// Perform the operation you have build so far.
24769    pub async fn doit(mut self) -> common::Result<(common::Response, LandingPage)> {
24770        use std::borrow::Cow;
24771        use std::io::{Read, Seek};
24772
24773        use common::{url::Params, ToParts};
24774        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24775
24776        let mut dd = common::DefaultDelegate;
24777        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24778        dlg.begin(common::MethodInfo {
24779            id: "dfareporting.advertiserLandingPages.patch",
24780            http_method: hyper::Method::PATCH,
24781        });
24782
24783        for &field in ["alt", "profileId", "id"].iter() {
24784            if self._additional_params.contains_key(field) {
24785                dlg.finished(false);
24786                return Err(common::Error::FieldClash(field));
24787            }
24788        }
24789
24790        let mut params = Params::with_capacity(5 + self._additional_params.len());
24791        params.push("profileId", self._profile_id.to_string());
24792        params.push("id", self._id.to_string());
24793
24794        params.extend(self._additional_params.iter());
24795
24796        params.push("alt", "json");
24797        let mut url =
24798            self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages";
24799        if self._scopes.is_empty() {
24800            self._scopes
24801                .insert(Scope::Dfatrafficking.as_ref().to_string());
24802        }
24803
24804        #[allow(clippy::single_element_loop)]
24805        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
24806            url = params.uri_replacement(url, param_name, find_this, false);
24807        }
24808        {
24809            let to_remove = ["profileId"];
24810            params.remove_params(&to_remove);
24811        }
24812
24813        let url = params.parse_with_url(&url);
24814
24815        let mut json_mime_type = mime::APPLICATION_JSON;
24816        let mut request_value_reader = {
24817            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24818            common::remove_json_null_values(&mut value);
24819            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24820            serde_json::to_writer(&mut dst, &value).unwrap();
24821            dst
24822        };
24823        let request_size = request_value_reader
24824            .seek(std::io::SeekFrom::End(0))
24825            .unwrap();
24826        request_value_reader
24827            .seek(std::io::SeekFrom::Start(0))
24828            .unwrap();
24829
24830        loop {
24831            let token = match self
24832                .hub
24833                .auth
24834                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24835                .await
24836            {
24837                Ok(token) => token,
24838                Err(e) => match dlg.token(e) {
24839                    Ok(token) => token,
24840                    Err(e) => {
24841                        dlg.finished(false);
24842                        return Err(common::Error::MissingToken(e));
24843                    }
24844                },
24845            };
24846            request_value_reader
24847                .seek(std::io::SeekFrom::Start(0))
24848                .unwrap();
24849            let mut req_result = {
24850                let client = &self.hub.client;
24851                dlg.pre_request();
24852                let mut req_builder = hyper::Request::builder()
24853                    .method(hyper::Method::PATCH)
24854                    .uri(url.as_str())
24855                    .header(USER_AGENT, self.hub._user_agent.clone());
24856
24857                if let Some(token) = token.as_ref() {
24858                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24859                }
24860
24861                let request = req_builder
24862                    .header(CONTENT_TYPE, json_mime_type.to_string())
24863                    .header(CONTENT_LENGTH, request_size as u64)
24864                    .body(common::to_body(
24865                        request_value_reader.get_ref().clone().into(),
24866                    ));
24867
24868                client.request(request.unwrap()).await
24869            };
24870
24871            match req_result {
24872                Err(err) => {
24873                    if let common::Retry::After(d) = dlg.http_error(&err) {
24874                        sleep(d).await;
24875                        continue;
24876                    }
24877                    dlg.finished(false);
24878                    return Err(common::Error::HttpError(err));
24879                }
24880                Ok(res) => {
24881                    let (mut parts, body) = res.into_parts();
24882                    let mut body = common::Body::new(body);
24883                    if !parts.status.is_success() {
24884                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24885                        let error = serde_json::from_str(&common::to_string(&bytes));
24886                        let response = common::to_response(parts, bytes.into());
24887
24888                        if let common::Retry::After(d) =
24889                            dlg.http_failure(&response, error.as_ref().ok())
24890                        {
24891                            sleep(d).await;
24892                            continue;
24893                        }
24894
24895                        dlg.finished(false);
24896
24897                        return Err(match error {
24898                            Ok(value) => common::Error::BadRequest(value),
24899                            _ => common::Error::Failure(response),
24900                        });
24901                    }
24902                    let response = {
24903                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24904                        let encoded = common::to_string(&bytes);
24905                        match serde_json::from_str(&encoded) {
24906                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24907                            Err(error) => {
24908                                dlg.response_json_decode_error(&encoded, &error);
24909                                return Err(common::Error::JsonDecodeError(
24910                                    encoded.to_string(),
24911                                    error,
24912                                ));
24913                            }
24914                        }
24915                    };
24916
24917                    dlg.finished(true);
24918                    return Ok(response);
24919                }
24920            }
24921        }
24922    }
24923
24924    ///
24925    /// Sets the *request* property to the given value.
24926    ///
24927    /// Even though the property as already been set when instantiating this call,
24928    /// we provide this method for API completeness.
24929    pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPagePatchCall<'a, C> {
24930        self._request = new_value;
24931        self
24932    }
24933    /// User profile ID associated with this request.
24934    ///
24935    /// Sets the *profile id* path property to the given value.
24936    ///
24937    /// Even though the property as already been set when instantiating this call,
24938    /// we provide this method for API completeness.
24939    pub fn profile_id(mut self, new_value: i64) -> AdvertiserLandingPagePatchCall<'a, C> {
24940        self._profile_id = new_value;
24941        self
24942    }
24943    /// Landing page ID.
24944    ///
24945    /// Sets the *id* query property to the given value.
24946    ///
24947    /// Even though the property as already been set when instantiating this call,
24948    /// we provide this method for API completeness.
24949    pub fn id(mut self, new_value: i64) -> AdvertiserLandingPagePatchCall<'a, C> {
24950        self._id = new_value;
24951        self
24952    }
24953    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24954    /// while executing the actual API request.
24955    ///
24956    /// ````text
24957    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24958    /// ````
24959    ///
24960    /// Sets the *delegate* property to the given value.
24961    pub fn delegate(
24962        mut self,
24963        new_value: &'a mut dyn common::Delegate,
24964    ) -> AdvertiserLandingPagePatchCall<'a, C> {
24965        self._delegate = Some(new_value);
24966        self
24967    }
24968
24969    /// Set any additional parameter of the query string used in the request.
24970    /// It should be used to set parameters which are not yet available through their own
24971    /// setters.
24972    ///
24973    /// Please note that this method must not be used to set any of the known parameters
24974    /// which have their own setter method. If done anyway, the request will fail.
24975    ///
24976    /// # Additional Parameters
24977    ///
24978    /// * *alt* (query-string) - Data format for the response.
24979    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24980    /// * *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.
24981    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24982    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24983    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
24984    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
24985    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserLandingPagePatchCall<'a, C>
24986    where
24987        T: AsRef<str>,
24988    {
24989        self._additional_params
24990            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24991        self
24992    }
24993
24994    /// Identifies the authorization scope for the method you are building.
24995    ///
24996    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24997    /// [`Scope::Dfatrafficking`].
24998    ///
24999    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25000    /// tokens for more than one scope.
25001    ///
25002    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25003    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25004    /// sufficient, a read-write scope will do as well.
25005    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserLandingPagePatchCall<'a, C>
25006    where
25007        St: AsRef<str>,
25008    {
25009        self._scopes.insert(String::from(scope.as_ref()));
25010        self
25011    }
25012    /// Identifies the authorization scope(s) for the method you are building.
25013    ///
25014    /// See [`Self::add_scope()`] for details.
25015    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserLandingPagePatchCall<'a, C>
25016    where
25017        I: IntoIterator<Item = St>,
25018        St: AsRef<str>,
25019    {
25020        self._scopes
25021            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25022        self
25023    }
25024
25025    /// Removes all scopes, and no default scope will be used either.
25026    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25027    /// for details).
25028    pub fn clear_scopes(mut self) -> AdvertiserLandingPagePatchCall<'a, C> {
25029        self._scopes.clear();
25030        self
25031    }
25032}
25033
25034/// Updates an existing landing page.
25035///
25036/// A builder for the *update* method supported by a *advertiserLandingPage* resource.
25037/// It is not used directly, but through a [`AdvertiserLandingPageMethods`] instance.
25038///
25039/// # Example
25040///
25041/// Instantiate a resource method builder
25042///
25043/// ```test_harness,no_run
25044/// # extern crate hyper;
25045/// # extern crate hyper_rustls;
25046/// # extern crate google_dfareporting3d2 as dfareporting3d2;
25047/// use dfareporting3d2::api::LandingPage;
25048/// # async fn dox() {
25049/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25050///
25051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25053/// #     secret,
25054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25055/// # ).build().await.unwrap();
25056///
25057/// # let client = hyper_util::client::legacy::Client::builder(
25058/// #     hyper_util::rt::TokioExecutor::new()
25059/// # )
25060/// # .build(
25061/// #     hyper_rustls::HttpsConnectorBuilder::new()
25062/// #         .with_native_roots()
25063/// #         .unwrap()
25064/// #         .https_or_http()
25065/// #         .enable_http1()
25066/// #         .build()
25067/// # );
25068/// # let mut hub = Dfareporting::new(client, auth);
25069/// // As the method needs a request, you would usually fill it with the desired information
25070/// // into the respective structure. Some of the parts shown here might not be applicable !
25071/// // Values shown here are possibly random and not representative !
25072/// let mut req = LandingPage::default();
25073///
25074/// // You can configure optional parameters by calling the respective setters at will, and
25075/// // execute the final call using `doit()`.
25076/// // Values shown here are possibly random and not representative !
25077/// let result = hub.advertiser_landing_pages().update(req, -77)
25078///              .doit().await;
25079/// # }
25080/// ```
25081pub struct AdvertiserLandingPageUpdateCall<'a, C>
25082where
25083    C: 'a,
25084{
25085    hub: &'a Dfareporting<C>,
25086    _request: LandingPage,
25087    _profile_id: i64,
25088    _delegate: Option<&'a mut dyn common::Delegate>,
25089    _additional_params: HashMap<String, String>,
25090    _scopes: BTreeSet<String>,
25091}
25092
25093impl<'a, C> common::CallBuilder for AdvertiserLandingPageUpdateCall<'a, C> {}
25094
25095impl<'a, C> AdvertiserLandingPageUpdateCall<'a, C>
25096where
25097    C: common::Connector,
25098{
25099    /// Perform the operation you have build so far.
25100    pub async fn doit(mut self) -> common::Result<(common::Response, LandingPage)> {
25101        use std::borrow::Cow;
25102        use std::io::{Read, Seek};
25103
25104        use common::{url::Params, ToParts};
25105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25106
25107        let mut dd = common::DefaultDelegate;
25108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25109        dlg.begin(common::MethodInfo {
25110            id: "dfareporting.advertiserLandingPages.update",
25111            http_method: hyper::Method::PUT,
25112        });
25113
25114        for &field in ["alt", "profileId"].iter() {
25115            if self._additional_params.contains_key(field) {
25116                dlg.finished(false);
25117                return Err(common::Error::FieldClash(field));
25118            }
25119        }
25120
25121        let mut params = Params::with_capacity(4 + self._additional_params.len());
25122        params.push("profileId", self._profile_id.to_string());
25123
25124        params.extend(self._additional_params.iter());
25125
25126        params.push("alt", "json");
25127        let mut url =
25128            self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages";
25129        if self._scopes.is_empty() {
25130            self._scopes
25131                .insert(Scope::Dfatrafficking.as_ref().to_string());
25132        }
25133
25134        #[allow(clippy::single_element_loop)]
25135        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
25136            url = params.uri_replacement(url, param_name, find_this, false);
25137        }
25138        {
25139            let to_remove = ["profileId"];
25140            params.remove_params(&to_remove);
25141        }
25142
25143        let url = params.parse_with_url(&url);
25144
25145        let mut json_mime_type = mime::APPLICATION_JSON;
25146        let mut request_value_reader = {
25147            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25148            common::remove_json_null_values(&mut value);
25149            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25150            serde_json::to_writer(&mut dst, &value).unwrap();
25151            dst
25152        };
25153        let request_size = request_value_reader
25154            .seek(std::io::SeekFrom::End(0))
25155            .unwrap();
25156        request_value_reader
25157            .seek(std::io::SeekFrom::Start(0))
25158            .unwrap();
25159
25160        loop {
25161            let token = match self
25162                .hub
25163                .auth
25164                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25165                .await
25166            {
25167                Ok(token) => token,
25168                Err(e) => match dlg.token(e) {
25169                    Ok(token) => token,
25170                    Err(e) => {
25171                        dlg.finished(false);
25172                        return Err(common::Error::MissingToken(e));
25173                    }
25174                },
25175            };
25176            request_value_reader
25177                .seek(std::io::SeekFrom::Start(0))
25178                .unwrap();
25179            let mut req_result = {
25180                let client = &self.hub.client;
25181                dlg.pre_request();
25182                let mut req_builder = hyper::Request::builder()
25183                    .method(hyper::Method::PUT)
25184                    .uri(url.as_str())
25185                    .header(USER_AGENT, self.hub._user_agent.clone());
25186
25187                if let Some(token) = token.as_ref() {
25188                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25189                }
25190
25191                let request = req_builder
25192                    .header(CONTENT_TYPE, json_mime_type.to_string())
25193                    .header(CONTENT_LENGTH, request_size as u64)
25194                    .body(common::to_body(
25195                        request_value_reader.get_ref().clone().into(),
25196                    ));
25197
25198                client.request(request.unwrap()).await
25199            };
25200
25201            match req_result {
25202                Err(err) => {
25203                    if let common::Retry::After(d) = dlg.http_error(&err) {
25204                        sleep(d).await;
25205                        continue;
25206                    }
25207                    dlg.finished(false);
25208                    return Err(common::Error::HttpError(err));
25209                }
25210                Ok(res) => {
25211                    let (mut parts, body) = res.into_parts();
25212                    let mut body = common::Body::new(body);
25213                    if !parts.status.is_success() {
25214                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25215                        let error = serde_json::from_str(&common::to_string(&bytes));
25216                        let response = common::to_response(parts, bytes.into());
25217
25218                        if let common::Retry::After(d) =
25219                            dlg.http_failure(&response, error.as_ref().ok())
25220                        {
25221                            sleep(d).await;
25222                            continue;
25223                        }
25224
25225                        dlg.finished(false);
25226
25227                        return Err(match error {
25228                            Ok(value) => common::Error::BadRequest(value),
25229                            _ => common::Error::Failure(response),
25230                        });
25231                    }
25232                    let response = {
25233                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25234                        let encoded = common::to_string(&bytes);
25235                        match serde_json::from_str(&encoded) {
25236                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25237                            Err(error) => {
25238                                dlg.response_json_decode_error(&encoded, &error);
25239                                return Err(common::Error::JsonDecodeError(
25240                                    encoded.to_string(),
25241                                    error,
25242                                ));
25243                            }
25244                        }
25245                    };
25246
25247                    dlg.finished(true);
25248                    return Ok(response);
25249                }
25250            }
25251        }
25252    }
25253
25254    ///
25255    /// Sets the *request* property to the given value.
25256    ///
25257    /// Even though the property as already been set when instantiating this call,
25258    /// we provide this method for API completeness.
25259    pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPageUpdateCall<'a, C> {
25260        self._request = new_value;
25261        self
25262    }
25263    /// User profile ID associated with this request.
25264    ///
25265    /// Sets the *profile id* path property to the given value.
25266    ///
25267    /// Even though the property as already been set when instantiating this call,
25268    /// we provide this method for API completeness.
25269    pub fn profile_id(mut self, new_value: i64) -> AdvertiserLandingPageUpdateCall<'a, C> {
25270        self._profile_id = new_value;
25271        self
25272    }
25273    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25274    /// while executing the actual API request.
25275    ///
25276    /// ````text
25277    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25278    /// ````
25279    ///
25280    /// Sets the *delegate* property to the given value.
25281    pub fn delegate(
25282        mut self,
25283        new_value: &'a mut dyn common::Delegate,
25284    ) -> AdvertiserLandingPageUpdateCall<'a, C> {
25285        self._delegate = Some(new_value);
25286        self
25287    }
25288
25289    /// Set any additional parameter of the query string used in the request.
25290    /// It should be used to set parameters which are not yet available through their own
25291    /// setters.
25292    ///
25293    /// Please note that this method must not be used to set any of the known parameters
25294    /// which have their own setter method. If done anyway, the request will fail.
25295    ///
25296    /// # Additional Parameters
25297    ///
25298    /// * *alt* (query-string) - Data format for the response.
25299    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25300    /// * *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.
25301    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25302    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25303    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25304    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25305    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserLandingPageUpdateCall<'a, C>
25306    where
25307        T: AsRef<str>,
25308    {
25309        self._additional_params
25310            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25311        self
25312    }
25313
25314    /// Identifies the authorization scope for the method you are building.
25315    ///
25316    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25317    /// [`Scope::Dfatrafficking`].
25318    ///
25319    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25320    /// tokens for more than one scope.
25321    ///
25322    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25323    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25324    /// sufficient, a read-write scope will do as well.
25325    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserLandingPageUpdateCall<'a, C>
25326    where
25327        St: AsRef<str>,
25328    {
25329        self._scopes.insert(String::from(scope.as_ref()));
25330        self
25331    }
25332    /// Identifies the authorization scope(s) for the method you are building.
25333    ///
25334    /// See [`Self::add_scope()`] for details.
25335    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserLandingPageUpdateCall<'a, C>
25336    where
25337        I: IntoIterator<Item = St>,
25338        St: AsRef<str>,
25339    {
25340        self._scopes
25341            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25342        self
25343    }
25344
25345    /// Removes all scopes, and no default scope will be used either.
25346    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25347    /// for details).
25348    pub fn clear_scopes(mut self) -> AdvertiserLandingPageUpdateCall<'a, C> {
25349        self._scopes.clear();
25350        self
25351    }
25352}
25353
25354/// Gets one advertiser by ID.
25355///
25356/// A builder for the *get* method supported by a *advertiser* resource.
25357/// It is not used directly, but through a [`AdvertiserMethods`] instance.
25358///
25359/// # Example
25360///
25361/// Instantiate a resource method builder
25362///
25363/// ```test_harness,no_run
25364/// # extern crate hyper;
25365/// # extern crate hyper_rustls;
25366/// # extern crate google_dfareporting3d2 as dfareporting3d2;
25367/// # async fn dox() {
25368/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25369///
25370/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25371/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25372/// #     secret,
25373/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25374/// # ).build().await.unwrap();
25375///
25376/// # let client = hyper_util::client::legacy::Client::builder(
25377/// #     hyper_util::rt::TokioExecutor::new()
25378/// # )
25379/// # .build(
25380/// #     hyper_rustls::HttpsConnectorBuilder::new()
25381/// #         .with_native_roots()
25382/// #         .unwrap()
25383/// #         .https_or_http()
25384/// #         .enable_http1()
25385/// #         .build()
25386/// # );
25387/// # let mut hub = Dfareporting::new(client, auth);
25388/// // You can configure optional parameters by calling the respective setters at will, and
25389/// // execute the final call using `doit()`.
25390/// // Values shown here are possibly random and not representative !
25391/// let result = hub.advertisers().get(-45, -32)
25392///              .doit().await;
25393/// # }
25394/// ```
25395pub struct AdvertiserGetCall<'a, C>
25396where
25397    C: 'a,
25398{
25399    hub: &'a Dfareporting<C>,
25400    _profile_id: i64,
25401    _id: i64,
25402    _delegate: Option<&'a mut dyn common::Delegate>,
25403    _additional_params: HashMap<String, String>,
25404    _scopes: BTreeSet<String>,
25405}
25406
25407impl<'a, C> common::CallBuilder for AdvertiserGetCall<'a, C> {}
25408
25409impl<'a, C> AdvertiserGetCall<'a, C>
25410where
25411    C: common::Connector,
25412{
25413    /// Perform the operation you have build so far.
25414    pub async fn doit(mut self) -> common::Result<(common::Response, Advertiser)> {
25415        use std::borrow::Cow;
25416        use std::io::{Read, Seek};
25417
25418        use common::{url::Params, ToParts};
25419        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25420
25421        let mut dd = common::DefaultDelegate;
25422        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25423        dlg.begin(common::MethodInfo {
25424            id: "dfareporting.advertisers.get",
25425            http_method: hyper::Method::GET,
25426        });
25427
25428        for &field in ["alt", "profileId", "id"].iter() {
25429            if self._additional_params.contains_key(field) {
25430                dlg.finished(false);
25431                return Err(common::Error::FieldClash(field));
25432            }
25433        }
25434
25435        let mut params = Params::with_capacity(4 + self._additional_params.len());
25436        params.push("profileId", self._profile_id.to_string());
25437        params.push("id", self._id.to_string());
25438
25439        params.extend(self._additional_params.iter());
25440
25441        params.push("alt", "json");
25442        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers/{id}";
25443        if self._scopes.is_empty() {
25444            self._scopes
25445                .insert(Scope::Dfatrafficking.as_ref().to_string());
25446        }
25447
25448        #[allow(clippy::single_element_loop)]
25449        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
25450            url = params.uri_replacement(url, param_name, find_this, false);
25451        }
25452        {
25453            let to_remove = ["id", "profileId"];
25454            params.remove_params(&to_remove);
25455        }
25456
25457        let url = params.parse_with_url(&url);
25458
25459        loop {
25460            let token = match self
25461                .hub
25462                .auth
25463                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25464                .await
25465            {
25466                Ok(token) => token,
25467                Err(e) => match dlg.token(e) {
25468                    Ok(token) => token,
25469                    Err(e) => {
25470                        dlg.finished(false);
25471                        return Err(common::Error::MissingToken(e));
25472                    }
25473                },
25474            };
25475            let mut req_result = {
25476                let client = &self.hub.client;
25477                dlg.pre_request();
25478                let mut req_builder = hyper::Request::builder()
25479                    .method(hyper::Method::GET)
25480                    .uri(url.as_str())
25481                    .header(USER_AGENT, self.hub._user_agent.clone());
25482
25483                if let Some(token) = token.as_ref() {
25484                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25485                }
25486
25487                let request = req_builder
25488                    .header(CONTENT_LENGTH, 0_u64)
25489                    .body(common::to_body::<String>(None));
25490
25491                client.request(request.unwrap()).await
25492            };
25493
25494            match req_result {
25495                Err(err) => {
25496                    if let common::Retry::After(d) = dlg.http_error(&err) {
25497                        sleep(d).await;
25498                        continue;
25499                    }
25500                    dlg.finished(false);
25501                    return Err(common::Error::HttpError(err));
25502                }
25503                Ok(res) => {
25504                    let (mut parts, body) = res.into_parts();
25505                    let mut body = common::Body::new(body);
25506                    if !parts.status.is_success() {
25507                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25508                        let error = serde_json::from_str(&common::to_string(&bytes));
25509                        let response = common::to_response(parts, bytes.into());
25510
25511                        if let common::Retry::After(d) =
25512                            dlg.http_failure(&response, error.as_ref().ok())
25513                        {
25514                            sleep(d).await;
25515                            continue;
25516                        }
25517
25518                        dlg.finished(false);
25519
25520                        return Err(match error {
25521                            Ok(value) => common::Error::BadRequest(value),
25522                            _ => common::Error::Failure(response),
25523                        });
25524                    }
25525                    let response = {
25526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25527                        let encoded = common::to_string(&bytes);
25528                        match serde_json::from_str(&encoded) {
25529                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25530                            Err(error) => {
25531                                dlg.response_json_decode_error(&encoded, &error);
25532                                return Err(common::Error::JsonDecodeError(
25533                                    encoded.to_string(),
25534                                    error,
25535                                ));
25536                            }
25537                        }
25538                    };
25539
25540                    dlg.finished(true);
25541                    return Ok(response);
25542                }
25543            }
25544        }
25545    }
25546
25547    /// User profile ID associated with this request.
25548    ///
25549    /// Sets the *profile id* path property to the given value.
25550    ///
25551    /// Even though the property as already been set when instantiating this call,
25552    /// we provide this method for API completeness.
25553    pub fn profile_id(mut self, new_value: i64) -> AdvertiserGetCall<'a, C> {
25554        self._profile_id = new_value;
25555        self
25556    }
25557    /// Advertiser ID.
25558    ///
25559    /// Sets the *id* path property to the given value.
25560    ///
25561    /// Even though the property as already been set when instantiating this call,
25562    /// we provide this method for API completeness.
25563    pub fn id(mut self, new_value: i64) -> AdvertiserGetCall<'a, C> {
25564        self._id = new_value;
25565        self
25566    }
25567    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25568    /// while executing the actual API request.
25569    ///
25570    /// ````text
25571    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25572    /// ````
25573    ///
25574    /// Sets the *delegate* property to the given value.
25575    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AdvertiserGetCall<'a, C> {
25576        self._delegate = Some(new_value);
25577        self
25578    }
25579
25580    /// Set any additional parameter of the query string used in the request.
25581    /// It should be used to set parameters which are not yet available through their own
25582    /// setters.
25583    ///
25584    /// Please note that this method must not be used to set any of the known parameters
25585    /// which have their own setter method. If done anyway, the request will fail.
25586    ///
25587    /// # Additional Parameters
25588    ///
25589    /// * *alt* (query-string) - Data format for the response.
25590    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25591    /// * *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.
25592    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25593    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25594    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25595    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25596    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserGetCall<'a, C>
25597    where
25598        T: AsRef<str>,
25599    {
25600        self._additional_params
25601            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25602        self
25603    }
25604
25605    /// Identifies the authorization scope for the method you are building.
25606    ///
25607    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25608    /// [`Scope::Dfatrafficking`].
25609    ///
25610    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25611    /// tokens for more than one scope.
25612    ///
25613    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25614    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25615    /// sufficient, a read-write scope will do as well.
25616    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserGetCall<'a, C>
25617    where
25618        St: AsRef<str>,
25619    {
25620        self._scopes.insert(String::from(scope.as_ref()));
25621        self
25622    }
25623    /// Identifies the authorization scope(s) for the method you are building.
25624    ///
25625    /// See [`Self::add_scope()`] for details.
25626    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserGetCall<'a, C>
25627    where
25628        I: IntoIterator<Item = St>,
25629        St: AsRef<str>,
25630    {
25631        self._scopes
25632            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25633        self
25634    }
25635
25636    /// Removes all scopes, and no default scope will be used either.
25637    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25638    /// for details).
25639    pub fn clear_scopes(mut self) -> AdvertiserGetCall<'a, C> {
25640        self._scopes.clear();
25641        self
25642    }
25643}
25644
25645/// Inserts a new advertiser.
25646///
25647/// A builder for the *insert* method supported by a *advertiser* resource.
25648/// It is not used directly, but through a [`AdvertiserMethods`] instance.
25649///
25650/// # Example
25651///
25652/// Instantiate a resource method builder
25653///
25654/// ```test_harness,no_run
25655/// # extern crate hyper;
25656/// # extern crate hyper_rustls;
25657/// # extern crate google_dfareporting3d2 as dfareporting3d2;
25658/// use dfareporting3d2::api::Advertiser;
25659/// # async fn dox() {
25660/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25661///
25662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25663/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25664/// #     secret,
25665/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25666/// # ).build().await.unwrap();
25667///
25668/// # let client = hyper_util::client::legacy::Client::builder(
25669/// #     hyper_util::rt::TokioExecutor::new()
25670/// # )
25671/// # .build(
25672/// #     hyper_rustls::HttpsConnectorBuilder::new()
25673/// #         .with_native_roots()
25674/// #         .unwrap()
25675/// #         .https_or_http()
25676/// #         .enable_http1()
25677/// #         .build()
25678/// # );
25679/// # let mut hub = Dfareporting::new(client, auth);
25680/// // As the method needs a request, you would usually fill it with the desired information
25681/// // into the respective structure. Some of the parts shown here might not be applicable !
25682/// // Values shown here are possibly random and not representative !
25683/// let mut req = Advertiser::default();
25684///
25685/// // You can configure optional parameters by calling the respective setters at will, and
25686/// // execute the final call using `doit()`.
25687/// // Values shown here are possibly random and not representative !
25688/// let result = hub.advertisers().insert(req, -69)
25689///              .doit().await;
25690/// # }
25691/// ```
25692pub struct AdvertiserInsertCall<'a, C>
25693where
25694    C: 'a,
25695{
25696    hub: &'a Dfareporting<C>,
25697    _request: Advertiser,
25698    _profile_id: i64,
25699    _delegate: Option<&'a mut dyn common::Delegate>,
25700    _additional_params: HashMap<String, String>,
25701    _scopes: BTreeSet<String>,
25702}
25703
25704impl<'a, C> common::CallBuilder for AdvertiserInsertCall<'a, C> {}
25705
25706impl<'a, C> AdvertiserInsertCall<'a, C>
25707where
25708    C: common::Connector,
25709{
25710    /// Perform the operation you have build so far.
25711    pub async fn doit(mut self) -> common::Result<(common::Response, Advertiser)> {
25712        use std::borrow::Cow;
25713        use std::io::{Read, Seek};
25714
25715        use common::{url::Params, ToParts};
25716        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25717
25718        let mut dd = common::DefaultDelegate;
25719        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25720        dlg.begin(common::MethodInfo {
25721            id: "dfareporting.advertisers.insert",
25722            http_method: hyper::Method::POST,
25723        });
25724
25725        for &field in ["alt", "profileId"].iter() {
25726            if self._additional_params.contains_key(field) {
25727                dlg.finished(false);
25728                return Err(common::Error::FieldClash(field));
25729            }
25730        }
25731
25732        let mut params = Params::with_capacity(4 + self._additional_params.len());
25733        params.push("profileId", self._profile_id.to_string());
25734
25735        params.extend(self._additional_params.iter());
25736
25737        params.push("alt", "json");
25738        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers";
25739        if self._scopes.is_empty() {
25740            self._scopes
25741                .insert(Scope::Dfatrafficking.as_ref().to_string());
25742        }
25743
25744        #[allow(clippy::single_element_loop)]
25745        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
25746            url = params.uri_replacement(url, param_name, find_this, false);
25747        }
25748        {
25749            let to_remove = ["profileId"];
25750            params.remove_params(&to_remove);
25751        }
25752
25753        let url = params.parse_with_url(&url);
25754
25755        let mut json_mime_type = mime::APPLICATION_JSON;
25756        let mut request_value_reader = {
25757            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25758            common::remove_json_null_values(&mut value);
25759            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25760            serde_json::to_writer(&mut dst, &value).unwrap();
25761            dst
25762        };
25763        let request_size = request_value_reader
25764            .seek(std::io::SeekFrom::End(0))
25765            .unwrap();
25766        request_value_reader
25767            .seek(std::io::SeekFrom::Start(0))
25768            .unwrap();
25769
25770        loop {
25771            let token = match self
25772                .hub
25773                .auth
25774                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25775                .await
25776            {
25777                Ok(token) => token,
25778                Err(e) => match dlg.token(e) {
25779                    Ok(token) => token,
25780                    Err(e) => {
25781                        dlg.finished(false);
25782                        return Err(common::Error::MissingToken(e));
25783                    }
25784                },
25785            };
25786            request_value_reader
25787                .seek(std::io::SeekFrom::Start(0))
25788                .unwrap();
25789            let mut req_result = {
25790                let client = &self.hub.client;
25791                dlg.pre_request();
25792                let mut req_builder = hyper::Request::builder()
25793                    .method(hyper::Method::POST)
25794                    .uri(url.as_str())
25795                    .header(USER_AGENT, self.hub._user_agent.clone());
25796
25797                if let Some(token) = token.as_ref() {
25798                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25799                }
25800
25801                let request = req_builder
25802                    .header(CONTENT_TYPE, json_mime_type.to_string())
25803                    .header(CONTENT_LENGTH, request_size as u64)
25804                    .body(common::to_body(
25805                        request_value_reader.get_ref().clone().into(),
25806                    ));
25807
25808                client.request(request.unwrap()).await
25809            };
25810
25811            match req_result {
25812                Err(err) => {
25813                    if let common::Retry::After(d) = dlg.http_error(&err) {
25814                        sleep(d).await;
25815                        continue;
25816                    }
25817                    dlg.finished(false);
25818                    return Err(common::Error::HttpError(err));
25819                }
25820                Ok(res) => {
25821                    let (mut parts, body) = res.into_parts();
25822                    let mut body = common::Body::new(body);
25823                    if !parts.status.is_success() {
25824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25825                        let error = serde_json::from_str(&common::to_string(&bytes));
25826                        let response = common::to_response(parts, bytes.into());
25827
25828                        if let common::Retry::After(d) =
25829                            dlg.http_failure(&response, error.as_ref().ok())
25830                        {
25831                            sleep(d).await;
25832                            continue;
25833                        }
25834
25835                        dlg.finished(false);
25836
25837                        return Err(match error {
25838                            Ok(value) => common::Error::BadRequest(value),
25839                            _ => common::Error::Failure(response),
25840                        });
25841                    }
25842                    let response = {
25843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25844                        let encoded = common::to_string(&bytes);
25845                        match serde_json::from_str(&encoded) {
25846                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25847                            Err(error) => {
25848                                dlg.response_json_decode_error(&encoded, &error);
25849                                return Err(common::Error::JsonDecodeError(
25850                                    encoded.to_string(),
25851                                    error,
25852                                ));
25853                            }
25854                        }
25855                    };
25856
25857                    dlg.finished(true);
25858                    return Ok(response);
25859                }
25860            }
25861        }
25862    }
25863
25864    ///
25865    /// Sets the *request* property to the given value.
25866    ///
25867    /// Even though the property as already been set when instantiating this call,
25868    /// we provide this method for API completeness.
25869    pub fn request(mut self, new_value: Advertiser) -> AdvertiserInsertCall<'a, C> {
25870        self._request = new_value;
25871        self
25872    }
25873    /// User profile ID associated with this request.
25874    ///
25875    /// Sets the *profile id* path property to the given value.
25876    ///
25877    /// Even though the property as already been set when instantiating this call,
25878    /// we provide this method for API completeness.
25879    pub fn profile_id(mut self, new_value: i64) -> AdvertiserInsertCall<'a, C> {
25880        self._profile_id = new_value;
25881        self
25882    }
25883    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25884    /// while executing the actual API request.
25885    ///
25886    /// ````text
25887    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25888    /// ````
25889    ///
25890    /// Sets the *delegate* property to the given value.
25891    pub fn delegate(
25892        mut self,
25893        new_value: &'a mut dyn common::Delegate,
25894    ) -> AdvertiserInsertCall<'a, C> {
25895        self._delegate = Some(new_value);
25896        self
25897    }
25898
25899    /// Set any additional parameter of the query string used in the request.
25900    /// It should be used to set parameters which are not yet available through their own
25901    /// setters.
25902    ///
25903    /// Please note that this method must not be used to set any of the known parameters
25904    /// which have their own setter method. If done anyway, the request will fail.
25905    ///
25906    /// # Additional Parameters
25907    ///
25908    /// * *alt* (query-string) - Data format for the response.
25909    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25910    /// * *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.
25911    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25912    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25913    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
25914    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
25915    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserInsertCall<'a, C>
25916    where
25917        T: AsRef<str>,
25918    {
25919        self._additional_params
25920            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25921        self
25922    }
25923
25924    /// Identifies the authorization scope for the method you are building.
25925    ///
25926    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25927    /// [`Scope::Dfatrafficking`].
25928    ///
25929    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25930    /// tokens for more than one scope.
25931    ///
25932    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25933    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25934    /// sufficient, a read-write scope will do as well.
25935    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserInsertCall<'a, C>
25936    where
25937        St: AsRef<str>,
25938    {
25939        self._scopes.insert(String::from(scope.as_ref()));
25940        self
25941    }
25942    /// Identifies the authorization scope(s) for the method you are building.
25943    ///
25944    /// See [`Self::add_scope()`] for details.
25945    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserInsertCall<'a, C>
25946    where
25947        I: IntoIterator<Item = St>,
25948        St: AsRef<str>,
25949    {
25950        self._scopes
25951            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25952        self
25953    }
25954
25955    /// Removes all scopes, and no default scope will be used either.
25956    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25957    /// for details).
25958    pub fn clear_scopes(mut self) -> AdvertiserInsertCall<'a, C> {
25959        self._scopes.clear();
25960        self
25961    }
25962}
25963
25964/// Retrieves a list of advertisers, possibly filtered. This method supports paging.
25965///
25966/// A builder for the *list* method supported by a *advertiser* resource.
25967/// It is not used directly, but through a [`AdvertiserMethods`] instance.
25968///
25969/// # Example
25970///
25971/// Instantiate a resource method builder
25972///
25973/// ```test_harness,no_run
25974/// # extern crate hyper;
25975/// # extern crate hyper_rustls;
25976/// # extern crate google_dfareporting3d2 as dfareporting3d2;
25977/// # async fn dox() {
25978/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25979///
25980/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25981/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
25982/// #     secret,
25983/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25984/// # ).build().await.unwrap();
25985///
25986/// # let client = hyper_util::client::legacy::Client::builder(
25987/// #     hyper_util::rt::TokioExecutor::new()
25988/// # )
25989/// # .build(
25990/// #     hyper_rustls::HttpsConnectorBuilder::new()
25991/// #         .with_native_roots()
25992/// #         .unwrap()
25993/// #         .https_or_http()
25994/// #         .enable_http1()
25995/// #         .build()
25996/// # );
25997/// # let mut hub = Dfareporting::new(client, auth);
25998/// // You can configure optional parameters by calling the respective setters at will, and
25999/// // execute the final call using `doit()`.
26000/// // Values shown here are possibly random and not representative !
26001/// let result = hub.advertisers().list(-95)
26002///              .subaccount_id(-31)
26003///              .status("aliquyam")
26004///              .sort_order("amet")
26005///              .sort_field("est")
26006///              .search_string("et")
26007///              .page_token("sea")
26008///              .only_parent(false)
26009///              .max_results(-46)
26010///              .include_advertisers_without_groups_only(true)
26011///              .add_ids(-7)
26012///              .add_floodlight_configuration_ids(-82)
26013///              .add_advertiser_group_ids(-94)
26014///              .doit().await;
26015/// # }
26016/// ```
26017pub struct AdvertiserListCall<'a, C>
26018where
26019    C: 'a,
26020{
26021    hub: &'a Dfareporting<C>,
26022    _profile_id: i64,
26023    _subaccount_id: Option<i64>,
26024    _status: Option<String>,
26025    _sort_order: Option<String>,
26026    _sort_field: Option<String>,
26027    _search_string: Option<String>,
26028    _page_token: Option<String>,
26029    _only_parent: Option<bool>,
26030    _max_results: Option<i32>,
26031    _include_advertisers_without_groups_only: Option<bool>,
26032    _ids: Vec<i64>,
26033    _floodlight_configuration_ids: Vec<i64>,
26034    _advertiser_group_ids: Vec<i64>,
26035    _delegate: Option<&'a mut dyn common::Delegate>,
26036    _additional_params: HashMap<String, String>,
26037    _scopes: BTreeSet<String>,
26038}
26039
26040impl<'a, C> common::CallBuilder for AdvertiserListCall<'a, C> {}
26041
26042impl<'a, C> AdvertiserListCall<'a, C>
26043where
26044    C: common::Connector,
26045{
26046    /// Perform the operation you have build so far.
26047    pub async fn doit(mut self) -> common::Result<(common::Response, AdvertisersListResponse)> {
26048        use std::borrow::Cow;
26049        use std::io::{Read, Seek};
26050
26051        use common::{url::Params, ToParts};
26052        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26053
26054        let mut dd = common::DefaultDelegate;
26055        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26056        dlg.begin(common::MethodInfo {
26057            id: "dfareporting.advertisers.list",
26058            http_method: hyper::Method::GET,
26059        });
26060
26061        for &field in [
26062            "alt",
26063            "profileId",
26064            "subaccountId",
26065            "status",
26066            "sortOrder",
26067            "sortField",
26068            "searchString",
26069            "pageToken",
26070            "onlyParent",
26071            "maxResults",
26072            "includeAdvertisersWithoutGroupsOnly",
26073            "ids",
26074            "floodlightConfigurationIds",
26075            "advertiserGroupIds",
26076        ]
26077        .iter()
26078        {
26079            if self._additional_params.contains_key(field) {
26080                dlg.finished(false);
26081                return Err(common::Error::FieldClash(field));
26082            }
26083        }
26084
26085        let mut params = Params::with_capacity(15 + self._additional_params.len());
26086        params.push("profileId", self._profile_id.to_string());
26087        if let Some(value) = self._subaccount_id.as_ref() {
26088            params.push("subaccountId", value.to_string());
26089        }
26090        if let Some(value) = self._status.as_ref() {
26091            params.push("status", value);
26092        }
26093        if let Some(value) = self._sort_order.as_ref() {
26094            params.push("sortOrder", value);
26095        }
26096        if let Some(value) = self._sort_field.as_ref() {
26097            params.push("sortField", value);
26098        }
26099        if let Some(value) = self._search_string.as_ref() {
26100            params.push("searchString", value);
26101        }
26102        if let Some(value) = self._page_token.as_ref() {
26103            params.push("pageToken", value);
26104        }
26105        if let Some(value) = self._only_parent.as_ref() {
26106            params.push("onlyParent", value.to_string());
26107        }
26108        if let Some(value) = self._max_results.as_ref() {
26109            params.push("maxResults", value.to_string());
26110        }
26111        if let Some(value) = self._include_advertisers_without_groups_only.as_ref() {
26112            params.push("includeAdvertisersWithoutGroupsOnly", value.to_string());
26113        }
26114        if !self._ids.is_empty() {
26115            for f in self._ids.iter() {
26116                params.push("ids", f.to_string());
26117            }
26118        }
26119        if !self._floodlight_configuration_ids.is_empty() {
26120            for f in self._floodlight_configuration_ids.iter() {
26121                params.push("floodlightConfigurationIds", f.to_string());
26122            }
26123        }
26124        if !self._advertiser_group_ids.is_empty() {
26125            for f in self._advertiser_group_ids.iter() {
26126                params.push("advertiserGroupIds", f.to_string());
26127            }
26128        }
26129
26130        params.extend(self._additional_params.iter());
26131
26132        params.push("alt", "json");
26133        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers";
26134        if self._scopes.is_empty() {
26135            self._scopes
26136                .insert(Scope::Dfatrafficking.as_ref().to_string());
26137        }
26138
26139        #[allow(clippy::single_element_loop)]
26140        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
26141            url = params.uri_replacement(url, param_name, find_this, false);
26142        }
26143        {
26144            let to_remove = ["profileId"];
26145            params.remove_params(&to_remove);
26146        }
26147
26148        let url = params.parse_with_url(&url);
26149
26150        loop {
26151            let token = match self
26152                .hub
26153                .auth
26154                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26155                .await
26156            {
26157                Ok(token) => token,
26158                Err(e) => match dlg.token(e) {
26159                    Ok(token) => token,
26160                    Err(e) => {
26161                        dlg.finished(false);
26162                        return Err(common::Error::MissingToken(e));
26163                    }
26164                },
26165            };
26166            let mut req_result = {
26167                let client = &self.hub.client;
26168                dlg.pre_request();
26169                let mut req_builder = hyper::Request::builder()
26170                    .method(hyper::Method::GET)
26171                    .uri(url.as_str())
26172                    .header(USER_AGENT, self.hub._user_agent.clone());
26173
26174                if let Some(token) = token.as_ref() {
26175                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26176                }
26177
26178                let request = req_builder
26179                    .header(CONTENT_LENGTH, 0_u64)
26180                    .body(common::to_body::<String>(None));
26181
26182                client.request(request.unwrap()).await
26183            };
26184
26185            match req_result {
26186                Err(err) => {
26187                    if let common::Retry::After(d) = dlg.http_error(&err) {
26188                        sleep(d).await;
26189                        continue;
26190                    }
26191                    dlg.finished(false);
26192                    return Err(common::Error::HttpError(err));
26193                }
26194                Ok(res) => {
26195                    let (mut parts, body) = res.into_parts();
26196                    let mut body = common::Body::new(body);
26197                    if !parts.status.is_success() {
26198                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26199                        let error = serde_json::from_str(&common::to_string(&bytes));
26200                        let response = common::to_response(parts, bytes.into());
26201
26202                        if let common::Retry::After(d) =
26203                            dlg.http_failure(&response, error.as_ref().ok())
26204                        {
26205                            sleep(d).await;
26206                            continue;
26207                        }
26208
26209                        dlg.finished(false);
26210
26211                        return Err(match error {
26212                            Ok(value) => common::Error::BadRequest(value),
26213                            _ => common::Error::Failure(response),
26214                        });
26215                    }
26216                    let response = {
26217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26218                        let encoded = common::to_string(&bytes);
26219                        match serde_json::from_str(&encoded) {
26220                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26221                            Err(error) => {
26222                                dlg.response_json_decode_error(&encoded, &error);
26223                                return Err(common::Error::JsonDecodeError(
26224                                    encoded.to_string(),
26225                                    error,
26226                                ));
26227                            }
26228                        }
26229                    };
26230
26231                    dlg.finished(true);
26232                    return Ok(response);
26233                }
26234            }
26235        }
26236    }
26237
26238    /// User profile ID associated with this request.
26239    ///
26240    /// Sets the *profile id* path property to the given value.
26241    ///
26242    /// Even though the property as already been set when instantiating this call,
26243    /// we provide this method for API completeness.
26244    pub fn profile_id(mut self, new_value: i64) -> AdvertiserListCall<'a, C> {
26245        self._profile_id = new_value;
26246        self
26247    }
26248    /// Select only advertisers with these subaccount IDs.
26249    ///
26250    /// Sets the *subaccount id* query property to the given value.
26251    pub fn subaccount_id(mut self, new_value: i64) -> AdvertiserListCall<'a, C> {
26252        self._subaccount_id = Some(new_value);
26253        self
26254    }
26255    /// Select only advertisers with the specified status.
26256    ///
26257    /// Sets the *status* query property to the given value.
26258    pub fn status(mut self, new_value: &str) -> AdvertiserListCall<'a, C> {
26259        self._status = Some(new_value.to_string());
26260        self
26261    }
26262    /// Order of sorted results.
26263    ///
26264    /// Sets the *sort order* query property to the given value.
26265    pub fn sort_order(mut self, new_value: &str) -> AdvertiserListCall<'a, C> {
26266        self._sort_order = Some(new_value.to_string());
26267        self
26268    }
26269    /// Field by which to sort the list.
26270    ///
26271    /// Sets the *sort field* query property to the given value.
26272    pub fn sort_field(mut self, new_value: &str) -> AdvertiserListCall<'a, C> {
26273        self._sort_field = Some(new_value.to_string());
26274        self
26275    }
26276    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "advertiser*2015" will return objects with names like "advertiser June 2015", "advertiser April 2015", or simply "advertiser 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "advertiser" will match objects with name "my advertiser", "advertiser 2015", or simply "advertiser".
26277    ///
26278    /// Sets the *search string* query property to the given value.
26279    pub fn search_string(mut self, new_value: &str) -> AdvertiserListCall<'a, C> {
26280        self._search_string = Some(new_value.to_string());
26281        self
26282    }
26283    /// Value of the nextPageToken from the previous result page.
26284    ///
26285    /// Sets the *page token* query property to the given value.
26286    pub fn page_token(mut self, new_value: &str) -> AdvertiserListCall<'a, C> {
26287        self._page_token = Some(new_value.to_string());
26288        self
26289    }
26290    /// Select only advertisers which use another advertiser's floodlight configuration.
26291    ///
26292    /// Sets the *only parent* query property to the given value.
26293    pub fn only_parent(mut self, new_value: bool) -> AdvertiserListCall<'a, C> {
26294        self._only_parent = Some(new_value);
26295        self
26296    }
26297    /// Maximum number of results to return.
26298    ///
26299    /// Sets the *max results* query property to the given value.
26300    pub fn max_results(mut self, new_value: i32) -> AdvertiserListCall<'a, C> {
26301        self._max_results = Some(new_value);
26302        self
26303    }
26304    /// Select only advertisers which do not belong to any advertiser group.
26305    ///
26306    /// Sets the *include advertisers without groups only* query property to the given value.
26307    pub fn include_advertisers_without_groups_only(
26308        mut self,
26309        new_value: bool,
26310    ) -> AdvertiserListCall<'a, C> {
26311        self._include_advertisers_without_groups_only = Some(new_value);
26312        self
26313    }
26314    /// Select only advertisers with these IDs.
26315    ///
26316    /// Append the given value to the *ids* query property.
26317    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
26318    pub fn add_ids(mut self, new_value: i64) -> AdvertiserListCall<'a, C> {
26319        self._ids.push(new_value);
26320        self
26321    }
26322    /// Select only advertisers with these floodlight configuration IDs.
26323    ///
26324    /// Append the given value to the *floodlight configuration ids* query property.
26325    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
26326    pub fn add_floodlight_configuration_ids(mut self, new_value: i64) -> AdvertiserListCall<'a, C> {
26327        self._floodlight_configuration_ids.push(new_value);
26328        self
26329    }
26330    /// Select only advertisers with these advertiser group IDs.
26331    ///
26332    /// Append the given value to the *advertiser group ids* query property.
26333    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
26334    pub fn add_advertiser_group_ids(mut self, new_value: i64) -> AdvertiserListCall<'a, C> {
26335        self._advertiser_group_ids.push(new_value);
26336        self
26337    }
26338    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26339    /// while executing the actual API request.
26340    ///
26341    /// ````text
26342    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26343    /// ````
26344    ///
26345    /// Sets the *delegate* property to the given value.
26346    pub fn delegate(
26347        mut self,
26348        new_value: &'a mut dyn common::Delegate,
26349    ) -> AdvertiserListCall<'a, C> {
26350        self._delegate = Some(new_value);
26351        self
26352    }
26353
26354    /// Set any additional parameter of the query string used in the request.
26355    /// It should be used to set parameters which are not yet available through their own
26356    /// setters.
26357    ///
26358    /// Please note that this method must not be used to set any of the known parameters
26359    /// which have their own setter method. If done anyway, the request will fail.
26360    ///
26361    /// # Additional Parameters
26362    ///
26363    /// * *alt* (query-string) - Data format for the response.
26364    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26365    /// * *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.
26366    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26367    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26368    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26369    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26370    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserListCall<'a, C>
26371    where
26372        T: AsRef<str>,
26373    {
26374        self._additional_params
26375            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26376        self
26377    }
26378
26379    /// Identifies the authorization scope for the method you are building.
26380    ///
26381    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26382    /// [`Scope::Dfatrafficking`].
26383    ///
26384    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26385    /// tokens for more than one scope.
26386    ///
26387    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26388    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26389    /// sufficient, a read-write scope will do as well.
26390    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserListCall<'a, C>
26391    where
26392        St: AsRef<str>,
26393    {
26394        self._scopes.insert(String::from(scope.as_ref()));
26395        self
26396    }
26397    /// Identifies the authorization scope(s) for the method you are building.
26398    ///
26399    /// See [`Self::add_scope()`] for details.
26400    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserListCall<'a, C>
26401    where
26402        I: IntoIterator<Item = St>,
26403        St: AsRef<str>,
26404    {
26405        self._scopes
26406            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26407        self
26408    }
26409
26410    /// Removes all scopes, and no default scope will be used either.
26411    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26412    /// for details).
26413    pub fn clear_scopes(mut self) -> AdvertiserListCall<'a, C> {
26414        self._scopes.clear();
26415        self
26416    }
26417}
26418
26419/// Updates an existing advertiser. This method supports patch semantics.
26420///
26421/// A builder for the *patch* method supported by a *advertiser* resource.
26422/// It is not used directly, but through a [`AdvertiserMethods`] instance.
26423///
26424/// # Example
26425///
26426/// Instantiate a resource method builder
26427///
26428/// ```test_harness,no_run
26429/// # extern crate hyper;
26430/// # extern crate hyper_rustls;
26431/// # extern crate google_dfareporting3d2 as dfareporting3d2;
26432/// use dfareporting3d2::api::Advertiser;
26433/// # async fn dox() {
26434/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26435///
26436/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26437/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26438/// #     secret,
26439/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26440/// # ).build().await.unwrap();
26441///
26442/// # let client = hyper_util::client::legacy::Client::builder(
26443/// #     hyper_util::rt::TokioExecutor::new()
26444/// # )
26445/// # .build(
26446/// #     hyper_rustls::HttpsConnectorBuilder::new()
26447/// #         .with_native_roots()
26448/// #         .unwrap()
26449/// #         .https_or_http()
26450/// #         .enable_http1()
26451/// #         .build()
26452/// # );
26453/// # let mut hub = Dfareporting::new(client, auth);
26454/// // As the method needs a request, you would usually fill it with the desired information
26455/// // into the respective structure. Some of the parts shown here might not be applicable !
26456/// // Values shown here are possibly random and not representative !
26457/// let mut req = Advertiser::default();
26458///
26459/// // You can configure optional parameters by calling the respective setters at will, and
26460/// // execute the final call using `doit()`.
26461/// // Values shown here are possibly random and not representative !
26462/// let result = hub.advertisers().patch(req, -20, -42)
26463///              .doit().await;
26464/// # }
26465/// ```
26466pub struct AdvertiserPatchCall<'a, C>
26467where
26468    C: 'a,
26469{
26470    hub: &'a Dfareporting<C>,
26471    _request: Advertiser,
26472    _profile_id: i64,
26473    _id: i64,
26474    _delegate: Option<&'a mut dyn common::Delegate>,
26475    _additional_params: HashMap<String, String>,
26476    _scopes: BTreeSet<String>,
26477}
26478
26479impl<'a, C> common::CallBuilder for AdvertiserPatchCall<'a, C> {}
26480
26481impl<'a, C> AdvertiserPatchCall<'a, C>
26482where
26483    C: common::Connector,
26484{
26485    /// Perform the operation you have build so far.
26486    pub async fn doit(mut self) -> common::Result<(common::Response, Advertiser)> {
26487        use std::borrow::Cow;
26488        use std::io::{Read, Seek};
26489
26490        use common::{url::Params, ToParts};
26491        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26492
26493        let mut dd = common::DefaultDelegate;
26494        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26495        dlg.begin(common::MethodInfo {
26496            id: "dfareporting.advertisers.patch",
26497            http_method: hyper::Method::PATCH,
26498        });
26499
26500        for &field in ["alt", "profileId", "id"].iter() {
26501            if self._additional_params.contains_key(field) {
26502                dlg.finished(false);
26503                return Err(common::Error::FieldClash(field));
26504            }
26505        }
26506
26507        let mut params = Params::with_capacity(5 + self._additional_params.len());
26508        params.push("profileId", self._profile_id.to_string());
26509        params.push("id", self._id.to_string());
26510
26511        params.extend(self._additional_params.iter());
26512
26513        params.push("alt", "json");
26514        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers";
26515        if self._scopes.is_empty() {
26516            self._scopes
26517                .insert(Scope::Dfatrafficking.as_ref().to_string());
26518        }
26519
26520        #[allow(clippy::single_element_loop)]
26521        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
26522            url = params.uri_replacement(url, param_name, find_this, false);
26523        }
26524        {
26525            let to_remove = ["profileId"];
26526            params.remove_params(&to_remove);
26527        }
26528
26529        let url = params.parse_with_url(&url);
26530
26531        let mut json_mime_type = mime::APPLICATION_JSON;
26532        let mut request_value_reader = {
26533            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26534            common::remove_json_null_values(&mut value);
26535            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26536            serde_json::to_writer(&mut dst, &value).unwrap();
26537            dst
26538        };
26539        let request_size = request_value_reader
26540            .seek(std::io::SeekFrom::End(0))
26541            .unwrap();
26542        request_value_reader
26543            .seek(std::io::SeekFrom::Start(0))
26544            .unwrap();
26545
26546        loop {
26547            let token = match self
26548                .hub
26549                .auth
26550                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26551                .await
26552            {
26553                Ok(token) => token,
26554                Err(e) => match dlg.token(e) {
26555                    Ok(token) => token,
26556                    Err(e) => {
26557                        dlg.finished(false);
26558                        return Err(common::Error::MissingToken(e));
26559                    }
26560                },
26561            };
26562            request_value_reader
26563                .seek(std::io::SeekFrom::Start(0))
26564                .unwrap();
26565            let mut req_result = {
26566                let client = &self.hub.client;
26567                dlg.pre_request();
26568                let mut req_builder = hyper::Request::builder()
26569                    .method(hyper::Method::PATCH)
26570                    .uri(url.as_str())
26571                    .header(USER_AGENT, self.hub._user_agent.clone());
26572
26573                if let Some(token) = token.as_ref() {
26574                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26575                }
26576
26577                let request = req_builder
26578                    .header(CONTENT_TYPE, json_mime_type.to_string())
26579                    .header(CONTENT_LENGTH, request_size as u64)
26580                    .body(common::to_body(
26581                        request_value_reader.get_ref().clone().into(),
26582                    ));
26583
26584                client.request(request.unwrap()).await
26585            };
26586
26587            match req_result {
26588                Err(err) => {
26589                    if let common::Retry::After(d) = dlg.http_error(&err) {
26590                        sleep(d).await;
26591                        continue;
26592                    }
26593                    dlg.finished(false);
26594                    return Err(common::Error::HttpError(err));
26595                }
26596                Ok(res) => {
26597                    let (mut parts, body) = res.into_parts();
26598                    let mut body = common::Body::new(body);
26599                    if !parts.status.is_success() {
26600                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26601                        let error = serde_json::from_str(&common::to_string(&bytes));
26602                        let response = common::to_response(parts, bytes.into());
26603
26604                        if let common::Retry::After(d) =
26605                            dlg.http_failure(&response, error.as_ref().ok())
26606                        {
26607                            sleep(d).await;
26608                            continue;
26609                        }
26610
26611                        dlg.finished(false);
26612
26613                        return Err(match error {
26614                            Ok(value) => common::Error::BadRequest(value),
26615                            _ => common::Error::Failure(response),
26616                        });
26617                    }
26618                    let response = {
26619                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26620                        let encoded = common::to_string(&bytes);
26621                        match serde_json::from_str(&encoded) {
26622                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26623                            Err(error) => {
26624                                dlg.response_json_decode_error(&encoded, &error);
26625                                return Err(common::Error::JsonDecodeError(
26626                                    encoded.to_string(),
26627                                    error,
26628                                ));
26629                            }
26630                        }
26631                    };
26632
26633                    dlg.finished(true);
26634                    return Ok(response);
26635                }
26636            }
26637        }
26638    }
26639
26640    ///
26641    /// Sets the *request* property to the given value.
26642    ///
26643    /// Even though the property as already been set when instantiating this call,
26644    /// we provide this method for API completeness.
26645    pub fn request(mut self, new_value: Advertiser) -> AdvertiserPatchCall<'a, C> {
26646        self._request = new_value;
26647        self
26648    }
26649    /// User profile ID associated with this request.
26650    ///
26651    /// Sets the *profile id* path property to the given value.
26652    ///
26653    /// Even though the property as already been set when instantiating this call,
26654    /// we provide this method for API completeness.
26655    pub fn profile_id(mut self, new_value: i64) -> AdvertiserPatchCall<'a, C> {
26656        self._profile_id = new_value;
26657        self
26658    }
26659    /// Advertiser ID.
26660    ///
26661    /// Sets the *id* query property to the given value.
26662    ///
26663    /// Even though the property as already been set when instantiating this call,
26664    /// we provide this method for API completeness.
26665    pub fn id(mut self, new_value: i64) -> AdvertiserPatchCall<'a, C> {
26666        self._id = new_value;
26667        self
26668    }
26669    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26670    /// while executing the actual API request.
26671    ///
26672    /// ````text
26673    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26674    /// ````
26675    ///
26676    /// Sets the *delegate* property to the given value.
26677    pub fn delegate(
26678        mut self,
26679        new_value: &'a mut dyn common::Delegate,
26680    ) -> AdvertiserPatchCall<'a, C> {
26681        self._delegate = Some(new_value);
26682        self
26683    }
26684
26685    /// Set any additional parameter of the query string used in the request.
26686    /// It should be used to set parameters which are not yet available through their own
26687    /// setters.
26688    ///
26689    /// Please note that this method must not be used to set any of the known parameters
26690    /// which have their own setter method. If done anyway, the request will fail.
26691    ///
26692    /// # Additional Parameters
26693    ///
26694    /// * *alt* (query-string) - Data format for the response.
26695    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26696    /// * *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.
26697    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26698    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26699    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
26700    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
26701    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserPatchCall<'a, C>
26702    where
26703        T: AsRef<str>,
26704    {
26705        self._additional_params
26706            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26707        self
26708    }
26709
26710    /// Identifies the authorization scope for the method you are building.
26711    ///
26712    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26713    /// [`Scope::Dfatrafficking`].
26714    ///
26715    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26716    /// tokens for more than one scope.
26717    ///
26718    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26719    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26720    /// sufficient, a read-write scope will do as well.
26721    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserPatchCall<'a, C>
26722    where
26723        St: AsRef<str>,
26724    {
26725        self._scopes.insert(String::from(scope.as_ref()));
26726        self
26727    }
26728    /// Identifies the authorization scope(s) for the method you are building.
26729    ///
26730    /// See [`Self::add_scope()`] for details.
26731    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserPatchCall<'a, C>
26732    where
26733        I: IntoIterator<Item = St>,
26734        St: AsRef<str>,
26735    {
26736        self._scopes
26737            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26738        self
26739    }
26740
26741    /// Removes all scopes, and no default scope will be used either.
26742    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26743    /// for details).
26744    pub fn clear_scopes(mut self) -> AdvertiserPatchCall<'a, C> {
26745        self._scopes.clear();
26746        self
26747    }
26748}
26749
26750/// Updates an existing advertiser.
26751///
26752/// A builder for the *update* method supported by a *advertiser* resource.
26753/// It is not used directly, but through a [`AdvertiserMethods`] instance.
26754///
26755/// # Example
26756///
26757/// Instantiate a resource method builder
26758///
26759/// ```test_harness,no_run
26760/// # extern crate hyper;
26761/// # extern crate hyper_rustls;
26762/// # extern crate google_dfareporting3d2 as dfareporting3d2;
26763/// use dfareporting3d2::api::Advertiser;
26764/// # async fn dox() {
26765/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26766///
26767/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26768/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
26769/// #     secret,
26770/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26771/// # ).build().await.unwrap();
26772///
26773/// # let client = hyper_util::client::legacy::Client::builder(
26774/// #     hyper_util::rt::TokioExecutor::new()
26775/// # )
26776/// # .build(
26777/// #     hyper_rustls::HttpsConnectorBuilder::new()
26778/// #         .with_native_roots()
26779/// #         .unwrap()
26780/// #         .https_or_http()
26781/// #         .enable_http1()
26782/// #         .build()
26783/// # );
26784/// # let mut hub = Dfareporting::new(client, auth);
26785/// // As the method needs a request, you would usually fill it with the desired information
26786/// // into the respective structure. Some of the parts shown here might not be applicable !
26787/// // Values shown here are possibly random and not representative !
26788/// let mut req = Advertiser::default();
26789///
26790/// // You can configure optional parameters by calling the respective setters at will, and
26791/// // execute the final call using `doit()`.
26792/// // Values shown here are possibly random and not representative !
26793/// let result = hub.advertisers().update(req, -57)
26794///              .doit().await;
26795/// # }
26796/// ```
26797pub struct AdvertiserUpdateCall<'a, C>
26798where
26799    C: 'a,
26800{
26801    hub: &'a Dfareporting<C>,
26802    _request: Advertiser,
26803    _profile_id: i64,
26804    _delegate: Option<&'a mut dyn common::Delegate>,
26805    _additional_params: HashMap<String, String>,
26806    _scopes: BTreeSet<String>,
26807}
26808
26809impl<'a, C> common::CallBuilder for AdvertiserUpdateCall<'a, C> {}
26810
26811impl<'a, C> AdvertiserUpdateCall<'a, C>
26812where
26813    C: common::Connector,
26814{
26815    /// Perform the operation you have build so far.
26816    pub async fn doit(mut self) -> common::Result<(common::Response, Advertiser)> {
26817        use std::borrow::Cow;
26818        use std::io::{Read, Seek};
26819
26820        use common::{url::Params, ToParts};
26821        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26822
26823        let mut dd = common::DefaultDelegate;
26824        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26825        dlg.begin(common::MethodInfo {
26826            id: "dfareporting.advertisers.update",
26827            http_method: hyper::Method::PUT,
26828        });
26829
26830        for &field in ["alt", "profileId"].iter() {
26831            if self._additional_params.contains_key(field) {
26832                dlg.finished(false);
26833                return Err(common::Error::FieldClash(field));
26834            }
26835        }
26836
26837        let mut params = Params::with_capacity(4 + self._additional_params.len());
26838        params.push("profileId", self._profile_id.to_string());
26839
26840        params.extend(self._additional_params.iter());
26841
26842        params.push("alt", "json");
26843        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers";
26844        if self._scopes.is_empty() {
26845            self._scopes
26846                .insert(Scope::Dfatrafficking.as_ref().to_string());
26847        }
26848
26849        #[allow(clippy::single_element_loop)]
26850        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
26851            url = params.uri_replacement(url, param_name, find_this, false);
26852        }
26853        {
26854            let to_remove = ["profileId"];
26855            params.remove_params(&to_remove);
26856        }
26857
26858        let url = params.parse_with_url(&url);
26859
26860        let mut json_mime_type = mime::APPLICATION_JSON;
26861        let mut request_value_reader = {
26862            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26863            common::remove_json_null_values(&mut value);
26864            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26865            serde_json::to_writer(&mut dst, &value).unwrap();
26866            dst
26867        };
26868        let request_size = request_value_reader
26869            .seek(std::io::SeekFrom::End(0))
26870            .unwrap();
26871        request_value_reader
26872            .seek(std::io::SeekFrom::Start(0))
26873            .unwrap();
26874
26875        loop {
26876            let token = match self
26877                .hub
26878                .auth
26879                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26880                .await
26881            {
26882                Ok(token) => token,
26883                Err(e) => match dlg.token(e) {
26884                    Ok(token) => token,
26885                    Err(e) => {
26886                        dlg.finished(false);
26887                        return Err(common::Error::MissingToken(e));
26888                    }
26889                },
26890            };
26891            request_value_reader
26892                .seek(std::io::SeekFrom::Start(0))
26893                .unwrap();
26894            let mut req_result = {
26895                let client = &self.hub.client;
26896                dlg.pre_request();
26897                let mut req_builder = hyper::Request::builder()
26898                    .method(hyper::Method::PUT)
26899                    .uri(url.as_str())
26900                    .header(USER_AGENT, self.hub._user_agent.clone());
26901
26902                if let Some(token) = token.as_ref() {
26903                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26904                }
26905
26906                let request = req_builder
26907                    .header(CONTENT_TYPE, json_mime_type.to_string())
26908                    .header(CONTENT_LENGTH, request_size as u64)
26909                    .body(common::to_body(
26910                        request_value_reader.get_ref().clone().into(),
26911                    ));
26912
26913                client.request(request.unwrap()).await
26914            };
26915
26916            match req_result {
26917                Err(err) => {
26918                    if let common::Retry::After(d) = dlg.http_error(&err) {
26919                        sleep(d).await;
26920                        continue;
26921                    }
26922                    dlg.finished(false);
26923                    return Err(common::Error::HttpError(err));
26924                }
26925                Ok(res) => {
26926                    let (mut parts, body) = res.into_parts();
26927                    let mut body = common::Body::new(body);
26928                    if !parts.status.is_success() {
26929                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26930                        let error = serde_json::from_str(&common::to_string(&bytes));
26931                        let response = common::to_response(parts, bytes.into());
26932
26933                        if let common::Retry::After(d) =
26934                            dlg.http_failure(&response, error.as_ref().ok())
26935                        {
26936                            sleep(d).await;
26937                            continue;
26938                        }
26939
26940                        dlg.finished(false);
26941
26942                        return Err(match error {
26943                            Ok(value) => common::Error::BadRequest(value),
26944                            _ => common::Error::Failure(response),
26945                        });
26946                    }
26947                    let response = {
26948                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26949                        let encoded = common::to_string(&bytes);
26950                        match serde_json::from_str(&encoded) {
26951                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26952                            Err(error) => {
26953                                dlg.response_json_decode_error(&encoded, &error);
26954                                return Err(common::Error::JsonDecodeError(
26955                                    encoded.to_string(),
26956                                    error,
26957                                ));
26958                            }
26959                        }
26960                    };
26961
26962                    dlg.finished(true);
26963                    return Ok(response);
26964                }
26965            }
26966        }
26967    }
26968
26969    ///
26970    /// Sets the *request* property to the given value.
26971    ///
26972    /// Even though the property as already been set when instantiating this call,
26973    /// we provide this method for API completeness.
26974    pub fn request(mut self, new_value: Advertiser) -> AdvertiserUpdateCall<'a, C> {
26975        self._request = new_value;
26976        self
26977    }
26978    /// User profile ID associated with this request.
26979    ///
26980    /// Sets the *profile id* path property to the given value.
26981    ///
26982    /// Even though the property as already been set when instantiating this call,
26983    /// we provide this method for API completeness.
26984    pub fn profile_id(mut self, new_value: i64) -> AdvertiserUpdateCall<'a, C> {
26985        self._profile_id = new_value;
26986        self
26987    }
26988    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26989    /// while executing the actual API request.
26990    ///
26991    /// ````text
26992    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26993    /// ````
26994    ///
26995    /// Sets the *delegate* property to the given value.
26996    pub fn delegate(
26997        mut self,
26998        new_value: &'a mut dyn common::Delegate,
26999    ) -> AdvertiserUpdateCall<'a, C> {
27000        self._delegate = Some(new_value);
27001        self
27002    }
27003
27004    /// Set any additional parameter of the query string used in the request.
27005    /// It should be used to set parameters which are not yet available through their own
27006    /// setters.
27007    ///
27008    /// Please note that this method must not be used to set any of the known parameters
27009    /// which have their own setter method. If done anyway, the request will fail.
27010    ///
27011    /// # Additional Parameters
27012    ///
27013    /// * *alt* (query-string) - Data format for the response.
27014    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27015    /// * *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.
27016    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27017    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27018    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27019    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27020    pub fn param<T>(mut self, name: T, value: T) -> AdvertiserUpdateCall<'a, C>
27021    where
27022        T: AsRef<str>,
27023    {
27024        self._additional_params
27025            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27026        self
27027    }
27028
27029    /// Identifies the authorization scope for the method you are building.
27030    ///
27031    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27032    /// [`Scope::Dfatrafficking`].
27033    ///
27034    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27035    /// tokens for more than one scope.
27036    ///
27037    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27038    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27039    /// sufficient, a read-write scope will do as well.
27040    pub fn add_scope<St>(mut self, scope: St) -> AdvertiserUpdateCall<'a, C>
27041    where
27042        St: AsRef<str>,
27043    {
27044        self._scopes.insert(String::from(scope.as_ref()));
27045        self
27046    }
27047    /// Identifies the authorization scope(s) for the method you are building.
27048    ///
27049    /// See [`Self::add_scope()`] for details.
27050    pub fn add_scopes<I, St>(mut self, scopes: I) -> AdvertiserUpdateCall<'a, C>
27051    where
27052        I: IntoIterator<Item = St>,
27053        St: AsRef<str>,
27054    {
27055        self._scopes
27056            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27057        self
27058    }
27059
27060    /// Removes all scopes, and no default scope will be used either.
27061    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27062    /// for details).
27063    pub fn clear_scopes(mut self) -> AdvertiserUpdateCall<'a, C> {
27064        self._scopes.clear();
27065        self
27066    }
27067}
27068
27069/// Retrieves a list of browsers.
27070///
27071/// A builder for the *list* method supported by a *browser* resource.
27072/// It is not used directly, but through a [`BrowserMethods`] instance.
27073///
27074/// # Example
27075///
27076/// Instantiate a resource method builder
27077///
27078/// ```test_harness,no_run
27079/// # extern crate hyper;
27080/// # extern crate hyper_rustls;
27081/// # extern crate google_dfareporting3d2 as dfareporting3d2;
27082/// # async fn dox() {
27083/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27084///
27085/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27086/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27087/// #     secret,
27088/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27089/// # ).build().await.unwrap();
27090///
27091/// # let client = hyper_util::client::legacy::Client::builder(
27092/// #     hyper_util::rt::TokioExecutor::new()
27093/// # )
27094/// # .build(
27095/// #     hyper_rustls::HttpsConnectorBuilder::new()
27096/// #         .with_native_roots()
27097/// #         .unwrap()
27098/// #         .https_or_http()
27099/// #         .enable_http1()
27100/// #         .build()
27101/// # );
27102/// # let mut hub = Dfareporting::new(client, auth);
27103/// // You can configure optional parameters by calling the respective setters at will, and
27104/// // execute the final call using `doit()`.
27105/// // Values shown here are possibly random and not representative !
27106/// let result = hub.browsers().list(-53)
27107///              .doit().await;
27108/// # }
27109/// ```
27110pub struct BrowserListCall<'a, C>
27111where
27112    C: 'a,
27113{
27114    hub: &'a Dfareporting<C>,
27115    _profile_id: i64,
27116    _delegate: Option<&'a mut dyn common::Delegate>,
27117    _additional_params: HashMap<String, String>,
27118    _scopes: BTreeSet<String>,
27119}
27120
27121impl<'a, C> common::CallBuilder for BrowserListCall<'a, C> {}
27122
27123impl<'a, C> BrowserListCall<'a, C>
27124where
27125    C: common::Connector,
27126{
27127    /// Perform the operation you have build so far.
27128    pub async fn doit(mut self) -> common::Result<(common::Response, BrowsersListResponse)> {
27129        use std::borrow::Cow;
27130        use std::io::{Read, Seek};
27131
27132        use common::{url::Params, ToParts};
27133        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27134
27135        let mut dd = common::DefaultDelegate;
27136        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27137        dlg.begin(common::MethodInfo {
27138            id: "dfareporting.browsers.list",
27139            http_method: hyper::Method::GET,
27140        });
27141
27142        for &field in ["alt", "profileId"].iter() {
27143            if self._additional_params.contains_key(field) {
27144                dlg.finished(false);
27145                return Err(common::Error::FieldClash(field));
27146            }
27147        }
27148
27149        let mut params = Params::with_capacity(3 + self._additional_params.len());
27150        params.push("profileId", self._profile_id.to_string());
27151
27152        params.extend(self._additional_params.iter());
27153
27154        params.push("alt", "json");
27155        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/browsers";
27156        if self._scopes.is_empty() {
27157            self._scopes
27158                .insert(Scope::Dfatrafficking.as_ref().to_string());
27159        }
27160
27161        #[allow(clippy::single_element_loop)]
27162        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
27163            url = params.uri_replacement(url, param_name, find_this, false);
27164        }
27165        {
27166            let to_remove = ["profileId"];
27167            params.remove_params(&to_remove);
27168        }
27169
27170        let url = params.parse_with_url(&url);
27171
27172        loop {
27173            let token = match self
27174                .hub
27175                .auth
27176                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27177                .await
27178            {
27179                Ok(token) => token,
27180                Err(e) => match dlg.token(e) {
27181                    Ok(token) => token,
27182                    Err(e) => {
27183                        dlg.finished(false);
27184                        return Err(common::Error::MissingToken(e));
27185                    }
27186                },
27187            };
27188            let mut req_result = {
27189                let client = &self.hub.client;
27190                dlg.pre_request();
27191                let mut req_builder = hyper::Request::builder()
27192                    .method(hyper::Method::GET)
27193                    .uri(url.as_str())
27194                    .header(USER_AGENT, self.hub._user_agent.clone());
27195
27196                if let Some(token) = token.as_ref() {
27197                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27198                }
27199
27200                let request = req_builder
27201                    .header(CONTENT_LENGTH, 0_u64)
27202                    .body(common::to_body::<String>(None));
27203
27204                client.request(request.unwrap()).await
27205            };
27206
27207            match req_result {
27208                Err(err) => {
27209                    if let common::Retry::After(d) = dlg.http_error(&err) {
27210                        sleep(d).await;
27211                        continue;
27212                    }
27213                    dlg.finished(false);
27214                    return Err(common::Error::HttpError(err));
27215                }
27216                Ok(res) => {
27217                    let (mut parts, body) = res.into_parts();
27218                    let mut body = common::Body::new(body);
27219                    if !parts.status.is_success() {
27220                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27221                        let error = serde_json::from_str(&common::to_string(&bytes));
27222                        let response = common::to_response(parts, bytes.into());
27223
27224                        if let common::Retry::After(d) =
27225                            dlg.http_failure(&response, error.as_ref().ok())
27226                        {
27227                            sleep(d).await;
27228                            continue;
27229                        }
27230
27231                        dlg.finished(false);
27232
27233                        return Err(match error {
27234                            Ok(value) => common::Error::BadRequest(value),
27235                            _ => common::Error::Failure(response),
27236                        });
27237                    }
27238                    let response = {
27239                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27240                        let encoded = common::to_string(&bytes);
27241                        match serde_json::from_str(&encoded) {
27242                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27243                            Err(error) => {
27244                                dlg.response_json_decode_error(&encoded, &error);
27245                                return Err(common::Error::JsonDecodeError(
27246                                    encoded.to_string(),
27247                                    error,
27248                                ));
27249                            }
27250                        }
27251                    };
27252
27253                    dlg.finished(true);
27254                    return Ok(response);
27255                }
27256            }
27257        }
27258    }
27259
27260    /// User profile ID associated with this request.
27261    ///
27262    /// Sets the *profile id* path property to the given value.
27263    ///
27264    /// Even though the property as already been set when instantiating this call,
27265    /// we provide this method for API completeness.
27266    pub fn profile_id(mut self, new_value: i64) -> BrowserListCall<'a, C> {
27267        self._profile_id = new_value;
27268        self
27269    }
27270    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27271    /// while executing the actual API request.
27272    ///
27273    /// ````text
27274    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27275    /// ````
27276    ///
27277    /// Sets the *delegate* property to the given value.
27278    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> BrowserListCall<'a, C> {
27279        self._delegate = Some(new_value);
27280        self
27281    }
27282
27283    /// Set any additional parameter of the query string used in the request.
27284    /// It should be used to set parameters which are not yet available through their own
27285    /// setters.
27286    ///
27287    /// Please note that this method must not be used to set any of the known parameters
27288    /// which have their own setter method. If done anyway, the request will fail.
27289    ///
27290    /// # Additional Parameters
27291    ///
27292    /// * *alt* (query-string) - Data format for the response.
27293    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27294    /// * *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.
27295    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27296    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27297    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27298    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27299    pub fn param<T>(mut self, name: T, value: T) -> BrowserListCall<'a, C>
27300    where
27301        T: AsRef<str>,
27302    {
27303        self._additional_params
27304            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27305        self
27306    }
27307
27308    /// Identifies the authorization scope for the method you are building.
27309    ///
27310    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27311    /// [`Scope::Dfatrafficking`].
27312    ///
27313    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27314    /// tokens for more than one scope.
27315    ///
27316    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27317    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27318    /// sufficient, a read-write scope will do as well.
27319    pub fn add_scope<St>(mut self, scope: St) -> BrowserListCall<'a, C>
27320    where
27321        St: AsRef<str>,
27322    {
27323        self._scopes.insert(String::from(scope.as_ref()));
27324        self
27325    }
27326    /// Identifies the authorization scope(s) for the method you are building.
27327    ///
27328    /// See [`Self::add_scope()`] for details.
27329    pub fn add_scopes<I, St>(mut self, scopes: I) -> BrowserListCall<'a, C>
27330    where
27331        I: IntoIterator<Item = St>,
27332        St: AsRef<str>,
27333    {
27334        self._scopes
27335            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27336        self
27337    }
27338
27339    /// Removes all scopes, and no default scope will be used either.
27340    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27341    /// for details).
27342    pub fn clear_scopes(mut self) -> BrowserListCall<'a, C> {
27343        self._scopes.clear();
27344        self
27345    }
27346}
27347
27348/// Associates a creative with the specified campaign. This method creates a default ad with dimensions matching the creative in the campaign if such a default ad does not exist already.
27349///
27350/// A builder for the *insert* method supported by a *campaignCreativeAssociation* resource.
27351/// It is not used directly, but through a [`CampaignCreativeAssociationMethods`] instance.
27352///
27353/// # Example
27354///
27355/// Instantiate a resource method builder
27356///
27357/// ```test_harness,no_run
27358/// # extern crate hyper;
27359/// # extern crate hyper_rustls;
27360/// # extern crate google_dfareporting3d2 as dfareporting3d2;
27361/// use dfareporting3d2::api::CampaignCreativeAssociation;
27362/// # async fn dox() {
27363/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27364///
27365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27366/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27367/// #     secret,
27368/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27369/// # ).build().await.unwrap();
27370///
27371/// # let client = hyper_util::client::legacy::Client::builder(
27372/// #     hyper_util::rt::TokioExecutor::new()
27373/// # )
27374/// # .build(
27375/// #     hyper_rustls::HttpsConnectorBuilder::new()
27376/// #         .with_native_roots()
27377/// #         .unwrap()
27378/// #         .https_or_http()
27379/// #         .enable_http1()
27380/// #         .build()
27381/// # );
27382/// # let mut hub = Dfareporting::new(client, auth);
27383/// // As the method needs a request, you would usually fill it with the desired information
27384/// // into the respective structure. Some of the parts shown here might not be applicable !
27385/// // Values shown here are possibly random and not representative !
27386/// let mut req = CampaignCreativeAssociation::default();
27387///
27388/// // You can configure optional parameters by calling the respective setters at will, and
27389/// // execute the final call using `doit()`.
27390/// // Values shown here are possibly random and not representative !
27391/// let result = hub.campaign_creative_associations().insert(req, -93, -75)
27392///              .doit().await;
27393/// # }
27394/// ```
27395pub struct CampaignCreativeAssociationInsertCall<'a, C>
27396where
27397    C: 'a,
27398{
27399    hub: &'a Dfareporting<C>,
27400    _request: CampaignCreativeAssociation,
27401    _profile_id: i64,
27402    _campaign_id: i64,
27403    _delegate: Option<&'a mut dyn common::Delegate>,
27404    _additional_params: HashMap<String, String>,
27405    _scopes: BTreeSet<String>,
27406}
27407
27408impl<'a, C> common::CallBuilder for CampaignCreativeAssociationInsertCall<'a, C> {}
27409
27410impl<'a, C> CampaignCreativeAssociationInsertCall<'a, C>
27411where
27412    C: common::Connector,
27413{
27414    /// Perform the operation you have build so far.
27415    pub async fn doit(mut self) -> common::Result<(common::Response, CampaignCreativeAssociation)> {
27416        use std::borrow::Cow;
27417        use std::io::{Read, Seek};
27418
27419        use common::{url::Params, ToParts};
27420        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27421
27422        let mut dd = common::DefaultDelegate;
27423        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27424        dlg.begin(common::MethodInfo {
27425            id: "dfareporting.campaignCreativeAssociations.insert",
27426            http_method: hyper::Method::POST,
27427        });
27428
27429        for &field in ["alt", "profileId", "campaignId"].iter() {
27430            if self._additional_params.contains_key(field) {
27431                dlg.finished(false);
27432                return Err(common::Error::FieldClash(field));
27433            }
27434        }
27435
27436        let mut params = Params::with_capacity(5 + self._additional_params.len());
27437        params.push("profileId", self._profile_id.to_string());
27438        params.push("campaignId", self._campaign_id.to_string());
27439
27440        params.extend(self._additional_params.iter());
27441
27442        params.push("alt", "json");
27443        let mut url = self.hub._base_url.clone()
27444            + "userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations";
27445        if self._scopes.is_empty() {
27446            self._scopes
27447                .insert(Scope::Dfatrafficking.as_ref().to_string());
27448        }
27449
27450        #[allow(clippy::single_element_loop)]
27451        for &(find_this, param_name) in
27452            [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].iter()
27453        {
27454            url = params.uri_replacement(url, param_name, find_this, false);
27455        }
27456        {
27457            let to_remove = ["campaignId", "profileId"];
27458            params.remove_params(&to_remove);
27459        }
27460
27461        let url = params.parse_with_url(&url);
27462
27463        let mut json_mime_type = mime::APPLICATION_JSON;
27464        let mut request_value_reader = {
27465            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27466            common::remove_json_null_values(&mut value);
27467            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27468            serde_json::to_writer(&mut dst, &value).unwrap();
27469            dst
27470        };
27471        let request_size = request_value_reader
27472            .seek(std::io::SeekFrom::End(0))
27473            .unwrap();
27474        request_value_reader
27475            .seek(std::io::SeekFrom::Start(0))
27476            .unwrap();
27477
27478        loop {
27479            let token = match self
27480                .hub
27481                .auth
27482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27483                .await
27484            {
27485                Ok(token) => token,
27486                Err(e) => match dlg.token(e) {
27487                    Ok(token) => token,
27488                    Err(e) => {
27489                        dlg.finished(false);
27490                        return Err(common::Error::MissingToken(e));
27491                    }
27492                },
27493            };
27494            request_value_reader
27495                .seek(std::io::SeekFrom::Start(0))
27496                .unwrap();
27497            let mut req_result = {
27498                let client = &self.hub.client;
27499                dlg.pre_request();
27500                let mut req_builder = hyper::Request::builder()
27501                    .method(hyper::Method::POST)
27502                    .uri(url.as_str())
27503                    .header(USER_AGENT, self.hub._user_agent.clone());
27504
27505                if let Some(token) = token.as_ref() {
27506                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27507                }
27508
27509                let request = req_builder
27510                    .header(CONTENT_TYPE, json_mime_type.to_string())
27511                    .header(CONTENT_LENGTH, request_size as u64)
27512                    .body(common::to_body(
27513                        request_value_reader.get_ref().clone().into(),
27514                    ));
27515
27516                client.request(request.unwrap()).await
27517            };
27518
27519            match req_result {
27520                Err(err) => {
27521                    if let common::Retry::After(d) = dlg.http_error(&err) {
27522                        sleep(d).await;
27523                        continue;
27524                    }
27525                    dlg.finished(false);
27526                    return Err(common::Error::HttpError(err));
27527                }
27528                Ok(res) => {
27529                    let (mut parts, body) = res.into_parts();
27530                    let mut body = common::Body::new(body);
27531                    if !parts.status.is_success() {
27532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27533                        let error = serde_json::from_str(&common::to_string(&bytes));
27534                        let response = common::to_response(parts, bytes.into());
27535
27536                        if let common::Retry::After(d) =
27537                            dlg.http_failure(&response, error.as_ref().ok())
27538                        {
27539                            sleep(d).await;
27540                            continue;
27541                        }
27542
27543                        dlg.finished(false);
27544
27545                        return Err(match error {
27546                            Ok(value) => common::Error::BadRequest(value),
27547                            _ => common::Error::Failure(response),
27548                        });
27549                    }
27550                    let response = {
27551                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27552                        let encoded = common::to_string(&bytes);
27553                        match serde_json::from_str(&encoded) {
27554                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27555                            Err(error) => {
27556                                dlg.response_json_decode_error(&encoded, &error);
27557                                return Err(common::Error::JsonDecodeError(
27558                                    encoded.to_string(),
27559                                    error,
27560                                ));
27561                            }
27562                        }
27563                    };
27564
27565                    dlg.finished(true);
27566                    return Ok(response);
27567                }
27568            }
27569        }
27570    }
27571
27572    ///
27573    /// Sets the *request* property to the given value.
27574    ///
27575    /// Even though the property as already been set when instantiating this call,
27576    /// we provide this method for API completeness.
27577    pub fn request(
27578        mut self,
27579        new_value: CampaignCreativeAssociation,
27580    ) -> CampaignCreativeAssociationInsertCall<'a, C> {
27581        self._request = new_value;
27582        self
27583    }
27584    /// User profile ID associated with this request.
27585    ///
27586    /// Sets the *profile id* path property to the given value.
27587    ///
27588    /// Even though the property as already been set when instantiating this call,
27589    /// we provide this method for API completeness.
27590    pub fn profile_id(mut self, new_value: i64) -> CampaignCreativeAssociationInsertCall<'a, C> {
27591        self._profile_id = new_value;
27592        self
27593    }
27594    /// Campaign ID in this association.
27595    ///
27596    /// Sets the *campaign id* path property to the given value.
27597    ///
27598    /// Even though the property as already been set when instantiating this call,
27599    /// we provide this method for API completeness.
27600    pub fn campaign_id(mut self, new_value: i64) -> CampaignCreativeAssociationInsertCall<'a, C> {
27601        self._campaign_id = new_value;
27602        self
27603    }
27604    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27605    /// while executing the actual API request.
27606    ///
27607    /// ````text
27608    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27609    /// ````
27610    ///
27611    /// Sets the *delegate* property to the given value.
27612    pub fn delegate(
27613        mut self,
27614        new_value: &'a mut dyn common::Delegate,
27615    ) -> CampaignCreativeAssociationInsertCall<'a, C> {
27616        self._delegate = Some(new_value);
27617        self
27618    }
27619
27620    /// Set any additional parameter of the query string used in the request.
27621    /// It should be used to set parameters which are not yet available through their own
27622    /// setters.
27623    ///
27624    /// Please note that this method must not be used to set any of the known parameters
27625    /// which have their own setter method. If done anyway, the request will fail.
27626    ///
27627    /// # Additional Parameters
27628    ///
27629    /// * *alt* (query-string) - Data format for the response.
27630    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27631    /// * *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.
27632    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27633    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27634    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27635    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27636    pub fn param<T>(mut self, name: T, value: T) -> CampaignCreativeAssociationInsertCall<'a, C>
27637    where
27638        T: AsRef<str>,
27639    {
27640        self._additional_params
27641            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27642        self
27643    }
27644
27645    /// Identifies the authorization scope for the method you are building.
27646    ///
27647    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27648    /// [`Scope::Dfatrafficking`].
27649    ///
27650    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27651    /// tokens for more than one scope.
27652    ///
27653    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27654    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27655    /// sufficient, a read-write scope will do as well.
27656    pub fn add_scope<St>(mut self, scope: St) -> CampaignCreativeAssociationInsertCall<'a, C>
27657    where
27658        St: AsRef<str>,
27659    {
27660        self._scopes.insert(String::from(scope.as_ref()));
27661        self
27662    }
27663    /// Identifies the authorization scope(s) for the method you are building.
27664    ///
27665    /// See [`Self::add_scope()`] for details.
27666    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignCreativeAssociationInsertCall<'a, C>
27667    where
27668        I: IntoIterator<Item = St>,
27669        St: AsRef<str>,
27670    {
27671        self._scopes
27672            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27673        self
27674    }
27675
27676    /// Removes all scopes, and no default scope will be used either.
27677    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27678    /// for details).
27679    pub fn clear_scopes(mut self) -> CampaignCreativeAssociationInsertCall<'a, C> {
27680        self._scopes.clear();
27681        self
27682    }
27683}
27684
27685/// Retrieves the list of creative IDs associated with the specified campaign. This method supports paging.
27686///
27687/// A builder for the *list* method supported by a *campaignCreativeAssociation* resource.
27688/// It is not used directly, but through a [`CampaignCreativeAssociationMethods`] instance.
27689///
27690/// # Example
27691///
27692/// Instantiate a resource method builder
27693///
27694/// ```test_harness,no_run
27695/// # extern crate hyper;
27696/// # extern crate hyper_rustls;
27697/// # extern crate google_dfareporting3d2 as dfareporting3d2;
27698/// # async fn dox() {
27699/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27700///
27701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27702/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
27703/// #     secret,
27704/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27705/// # ).build().await.unwrap();
27706///
27707/// # let client = hyper_util::client::legacy::Client::builder(
27708/// #     hyper_util::rt::TokioExecutor::new()
27709/// # )
27710/// # .build(
27711/// #     hyper_rustls::HttpsConnectorBuilder::new()
27712/// #         .with_native_roots()
27713/// #         .unwrap()
27714/// #         .https_or_http()
27715/// #         .enable_http1()
27716/// #         .build()
27717/// # );
27718/// # let mut hub = Dfareporting::new(client, auth);
27719/// // You can configure optional parameters by calling the respective setters at will, and
27720/// // execute the final call using `doit()`.
27721/// // Values shown here are possibly random and not representative !
27722/// let result = hub.campaign_creative_associations().list(-56, -17)
27723///              .sort_order("Stet")
27724///              .page_token("dolores")
27725///              .max_results(-25)
27726///              .doit().await;
27727/// # }
27728/// ```
27729pub struct CampaignCreativeAssociationListCall<'a, C>
27730where
27731    C: 'a,
27732{
27733    hub: &'a Dfareporting<C>,
27734    _profile_id: i64,
27735    _campaign_id: i64,
27736    _sort_order: Option<String>,
27737    _page_token: Option<String>,
27738    _max_results: Option<i32>,
27739    _delegate: Option<&'a mut dyn common::Delegate>,
27740    _additional_params: HashMap<String, String>,
27741    _scopes: BTreeSet<String>,
27742}
27743
27744impl<'a, C> common::CallBuilder for CampaignCreativeAssociationListCall<'a, C> {}
27745
27746impl<'a, C> CampaignCreativeAssociationListCall<'a, C>
27747where
27748    C: common::Connector,
27749{
27750    /// Perform the operation you have build so far.
27751    pub async fn doit(
27752        mut self,
27753    ) -> common::Result<(common::Response, CampaignCreativeAssociationsListResponse)> {
27754        use std::borrow::Cow;
27755        use std::io::{Read, Seek};
27756
27757        use common::{url::Params, ToParts};
27758        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27759
27760        let mut dd = common::DefaultDelegate;
27761        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27762        dlg.begin(common::MethodInfo {
27763            id: "dfareporting.campaignCreativeAssociations.list",
27764            http_method: hyper::Method::GET,
27765        });
27766
27767        for &field in [
27768            "alt",
27769            "profileId",
27770            "campaignId",
27771            "sortOrder",
27772            "pageToken",
27773            "maxResults",
27774        ]
27775        .iter()
27776        {
27777            if self._additional_params.contains_key(field) {
27778                dlg.finished(false);
27779                return Err(common::Error::FieldClash(field));
27780            }
27781        }
27782
27783        let mut params = Params::with_capacity(7 + self._additional_params.len());
27784        params.push("profileId", self._profile_id.to_string());
27785        params.push("campaignId", self._campaign_id.to_string());
27786        if let Some(value) = self._sort_order.as_ref() {
27787            params.push("sortOrder", value);
27788        }
27789        if let Some(value) = self._page_token.as_ref() {
27790            params.push("pageToken", value);
27791        }
27792        if let Some(value) = self._max_results.as_ref() {
27793            params.push("maxResults", value.to_string());
27794        }
27795
27796        params.extend(self._additional_params.iter());
27797
27798        params.push("alt", "json");
27799        let mut url = self.hub._base_url.clone()
27800            + "userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations";
27801        if self._scopes.is_empty() {
27802            self._scopes
27803                .insert(Scope::Dfatrafficking.as_ref().to_string());
27804        }
27805
27806        #[allow(clippy::single_element_loop)]
27807        for &(find_this, param_name) in
27808            [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].iter()
27809        {
27810            url = params.uri_replacement(url, param_name, find_this, false);
27811        }
27812        {
27813            let to_remove = ["campaignId", "profileId"];
27814            params.remove_params(&to_remove);
27815        }
27816
27817        let url = params.parse_with_url(&url);
27818
27819        loop {
27820            let token = match self
27821                .hub
27822                .auth
27823                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27824                .await
27825            {
27826                Ok(token) => token,
27827                Err(e) => match dlg.token(e) {
27828                    Ok(token) => token,
27829                    Err(e) => {
27830                        dlg.finished(false);
27831                        return Err(common::Error::MissingToken(e));
27832                    }
27833                },
27834            };
27835            let mut req_result = {
27836                let client = &self.hub.client;
27837                dlg.pre_request();
27838                let mut req_builder = hyper::Request::builder()
27839                    .method(hyper::Method::GET)
27840                    .uri(url.as_str())
27841                    .header(USER_AGENT, self.hub._user_agent.clone());
27842
27843                if let Some(token) = token.as_ref() {
27844                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27845                }
27846
27847                let request = req_builder
27848                    .header(CONTENT_LENGTH, 0_u64)
27849                    .body(common::to_body::<String>(None));
27850
27851                client.request(request.unwrap()).await
27852            };
27853
27854            match req_result {
27855                Err(err) => {
27856                    if let common::Retry::After(d) = dlg.http_error(&err) {
27857                        sleep(d).await;
27858                        continue;
27859                    }
27860                    dlg.finished(false);
27861                    return Err(common::Error::HttpError(err));
27862                }
27863                Ok(res) => {
27864                    let (mut parts, body) = res.into_parts();
27865                    let mut body = common::Body::new(body);
27866                    if !parts.status.is_success() {
27867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27868                        let error = serde_json::from_str(&common::to_string(&bytes));
27869                        let response = common::to_response(parts, bytes.into());
27870
27871                        if let common::Retry::After(d) =
27872                            dlg.http_failure(&response, error.as_ref().ok())
27873                        {
27874                            sleep(d).await;
27875                            continue;
27876                        }
27877
27878                        dlg.finished(false);
27879
27880                        return Err(match error {
27881                            Ok(value) => common::Error::BadRequest(value),
27882                            _ => common::Error::Failure(response),
27883                        });
27884                    }
27885                    let response = {
27886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27887                        let encoded = common::to_string(&bytes);
27888                        match serde_json::from_str(&encoded) {
27889                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27890                            Err(error) => {
27891                                dlg.response_json_decode_error(&encoded, &error);
27892                                return Err(common::Error::JsonDecodeError(
27893                                    encoded.to_string(),
27894                                    error,
27895                                ));
27896                            }
27897                        }
27898                    };
27899
27900                    dlg.finished(true);
27901                    return Ok(response);
27902                }
27903            }
27904        }
27905    }
27906
27907    /// User profile ID associated with this request.
27908    ///
27909    /// Sets the *profile id* path property to the given value.
27910    ///
27911    /// Even though the property as already been set when instantiating this call,
27912    /// we provide this method for API completeness.
27913    pub fn profile_id(mut self, new_value: i64) -> CampaignCreativeAssociationListCall<'a, C> {
27914        self._profile_id = new_value;
27915        self
27916    }
27917    /// Campaign ID in this association.
27918    ///
27919    /// Sets the *campaign id* path property to the given value.
27920    ///
27921    /// Even though the property as already been set when instantiating this call,
27922    /// we provide this method for API completeness.
27923    pub fn campaign_id(mut self, new_value: i64) -> CampaignCreativeAssociationListCall<'a, C> {
27924        self._campaign_id = new_value;
27925        self
27926    }
27927    /// Order of sorted results.
27928    ///
27929    /// Sets the *sort order* query property to the given value.
27930    pub fn sort_order(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C> {
27931        self._sort_order = Some(new_value.to_string());
27932        self
27933    }
27934    /// Value of the nextPageToken from the previous result page.
27935    ///
27936    /// Sets the *page token* query property to the given value.
27937    pub fn page_token(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, C> {
27938        self._page_token = Some(new_value.to_string());
27939        self
27940    }
27941    /// Maximum number of results to return.
27942    ///
27943    /// Sets the *max results* query property to the given value.
27944    pub fn max_results(mut self, new_value: i32) -> CampaignCreativeAssociationListCall<'a, C> {
27945        self._max_results = Some(new_value);
27946        self
27947    }
27948    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27949    /// while executing the actual API request.
27950    ///
27951    /// ````text
27952    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27953    /// ````
27954    ///
27955    /// Sets the *delegate* property to the given value.
27956    pub fn delegate(
27957        mut self,
27958        new_value: &'a mut dyn common::Delegate,
27959    ) -> CampaignCreativeAssociationListCall<'a, C> {
27960        self._delegate = Some(new_value);
27961        self
27962    }
27963
27964    /// Set any additional parameter of the query string used in the request.
27965    /// It should be used to set parameters which are not yet available through their own
27966    /// setters.
27967    ///
27968    /// Please note that this method must not be used to set any of the known parameters
27969    /// which have their own setter method. If done anyway, the request will fail.
27970    ///
27971    /// # Additional Parameters
27972    ///
27973    /// * *alt* (query-string) - Data format for the response.
27974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27975    /// * *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.
27976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27978    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
27979    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
27980    pub fn param<T>(mut self, name: T, value: T) -> CampaignCreativeAssociationListCall<'a, C>
27981    where
27982        T: AsRef<str>,
27983    {
27984        self._additional_params
27985            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27986        self
27987    }
27988
27989    /// Identifies the authorization scope for the method you are building.
27990    ///
27991    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27992    /// [`Scope::Dfatrafficking`].
27993    ///
27994    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27995    /// tokens for more than one scope.
27996    ///
27997    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27998    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27999    /// sufficient, a read-write scope will do as well.
28000    pub fn add_scope<St>(mut self, scope: St) -> CampaignCreativeAssociationListCall<'a, C>
28001    where
28002        St: AsRef<str>,
28003    {
28004        self._scopes.insert(String::from(scope.as_ref()));
28005        self
28006    }
28007    /// Identifies the authorization scope(s) for the method you are building.
28008    ///
28009    /// See [`Self::add_scope()`] for details.
28010    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignCreativeAssociationListCall<'a, C>
28011    where
28012        I: IntoIterator<Item = St>,
28013        St: AsRef<str>,
28014    {
28015        self._scopes
28016            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28017        self
28018    }
28019
28020    /// Removes all scopes, and no default scope will be used either.
28021    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28022    /// for details).
28023    pub fn clear_scopes(mut self) -> CampaignCreativeAssociationListCall<'a, C> {
28024        self._scopes.clear();
28025        self
28026    }
28027}
28028
28029/// Gets one campaign by ID.
28030///
28031/// A builder for the *get* method supported by a *campaign* resource.
28032/// It is not used directly, but through a [`CampaignMethods`] instance.
28033///
28034/// # Example
28035///
28036/// Instantiate a resource method builder
28037///
28038/// ```test_harness,no_run
28039/// # extern crate hyper;
28040/// # extern crate hyper_rustls;
28041/// # extern crate google_dfareporting3d2 as dfareporting3d2;
28042/// # async fn dox() {
28043/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28044///
28045/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28046/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28047/// #     secret,
28048/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28049/// # ).build().await.unwrap();
28050///
28051/// # let client = hyper_util::client::legacy::Client::builder(
28052/// #     hyper_util::rt::TokioExecutor::new()
28053/// # )
28054/// # .build(
28055/// #     hyper_rustls::HttpsConnectorBuilder::new()
28056/// #         .with_native_roots()
28057/// #         .unwrap()
28058/// #         .https_or_http()
28059/// #         .enable_http1()
28060/// #         .build()
28061/// # );
28062/// # let mut hub = Dfareporting::new(client, auth);
28063/// // You can configure optional parameters by calling the respective setters at will, and
28064/// // execute the final call using `doit()`.
28065/// // Values shown here are possibly random and not representative !
28066/// let result = hub.campaigns().get(-68, -10)
28067///              .doit().await;
28068/// # }
28069/// ```
28070pub struct CampaignGetCall<'a, C>
28071where
28072    C: 'a,
28073{
28074    hub: &'a Dfareporting<C>,
28075    _profile_id: i64,
28076    _id: i64,
28077    _delegate: Option<&'a mut dyn common::Delegate>,
28078    _additional_params: HashMap<String, String>,
28079    _scopes: BTreeSet<String>,
28080}
28081
28082impl<'a, C> common::CallBuilder for CampaignGetCall<'a, C> {}
28083
28084impl<'a, C> CampaignGetCall<'a, C>
28085where
28086    C: common::Connector,
28087{
28088    /// Perform the operation you have build so far.
28089    pub async fn doit(mut self) -> common::Result<(common::Response, Campaign)> {
28090        use std::borrow::Cow;
28091        use std::io::{Read, Seek};
28092
28093        use common::{url::Params, ToParts};
28094        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28095
28096        let mut dd = common::DefaultDelegate;
28097        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28098        dlg.begin(common::MethodInfo {
28099            id: "dfareporting.campaigns.get",
28100            http_method: hyper::Method::GET,
28101        });
28102
28103        for &field in ["alt", "profileId", "id"].iter() {
28104            if self._additional_params.contains_key(field) {
28105                dlg.finished(false);
28106                return Err(common::Error::FieldClash(field));
28107            }
28108        }
28109
28110        let mut params = Params::with_capacity(4 + self._additional_params.len());
28111        params.push("profileId", self._profile_id.to_string());
28112        params.push("id", self._id.to_string());
28113
28114        params.extend(self._additional_params.iter());
28115
28116        params.push("alt", "json");
28117        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns/{id}";
28118        if self._scopes.is_empty() {
28119            self._scopes
28120                .insert(Scope::Dfatrafficking.as_ref().to_string());
28121        }
28122
28123        #[allow(clippy::single_element_loop)]
28124        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
28125            url = params.uri_replacement(url, param_name, find_this, false);
28126        }
28127        {
28128            let to_remove = ["id", "profileId"];
28129            params.remove_params(&to_remove);
28130        }
28131
28132        let url = params.parse_with_url(&url);
28133
28134        loop {
28135            let token = match self
28136                .hub
28137                .auth
28138                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28139                .await
28140            {
28141                Ok(token) => token,
28142                Err(e) => match dlg.token(e) {
28143                    Ok(token) => token,
28144                    Err(e) => {
28145                        dlg.finished(false);
28146                        return Err(common::Error::MissingToken(e));
28147                    }
28148                },
28149            };
28150            let mut req_result = {
28151                let client = &self.hub.client;
28152                dlg.pre_request();
28153                let mut req_builder = hyper::Request::builder()
28154                    .method(hyper::Method::GET)
28155                    .uri(url.as_str())
28156                    .header(USER_AGENT, self.hub._user_agent.clone());
28157
28158                if let Some(token) = token.as_ref() {
28159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28160                }
28161
28162                let request = req_builder
28163                    .header(CONTENT_LENGTH, 0_u64)
28164                    .body(common::to_body::<String>(None));
28165
28166                client.request(request.unwrap()).await
28167            };
28168
28169            match req_result {
28170                Err(err) => {
28171                    if let common::Retry::After(d) = dlg.http_error(&err) {
28172                        sleep(d).await;
28173                        continue;
28174                    }
28175                    dlg.finished(false);
28176                    return Err(common::Error::HttpError(err));
28177                }
28178                Ok(res) => {
28179                    let (mut parts, body) = res.into_parts();
28180                    let mut body = common::Body::new(body);
28181                    if !parts.status.is_success() {
28182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28183                        let error = serde_json::from_str(&common::to_string(&bytes));
28184                        let response = common::to_response(parts, bytes.into());
28185
28186                        if let common::Retry::After(d) =
28187                            dlg.http_failure(&response, error.as_ref().ok())
28188                        {
28189                            sleep(d).await;
28190                            continue;
28191                        }
28192
28193                        dlg.finished(false);
28194
28195                        return Err(match error {
28196                            Ok(value) => common::Error::BadRequest(value),
28197                            _ => common::Error::Failure(response),
28198                        });
28199                    }
28200                    let response = {
28201                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28202                        let encoded = common::to_string(&bytes);
28203                        match serde_json::from_str(&encoded) {
28204                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28205                            Err(error) => {
28206                                dlg.response_json_decode_error(&encoded, &error);
28207                                return Err(common::Error::JsonDecodeError(
28208                                    encoded.to_string(),
28209                                    error,
28210                                ));
28211                            }
28212                        }
28213                    };
28214
28215                    dlg.finished(true);
28216                    return Ok(response);
28217                }
28218            }
28219        }
28220    }
28221
28222    /// User profile ID associated with this request.
28223    ///
28224    /// Sets the *profile id* path property to the given value.
28225    ///
28226    /// Even though the property as already been set when instantiating this call,
28227    /// we provide this method for API completeness.
28228    pub fn profile_id(mut self, new_value: i64) -> CampaignGetCall<'a, C> {
28229        self._profile_id = new_value;
28230        self
28231    }
28232    /// Campaign ID.
28233    ///
28234    /// Sets the *id* path property to the given value.
28235    ///
28236    /// Even though the property as already been set when instantiating this call,
28237    /// we provide this method for API completeness.
28238    pub fn id(mut self, new_value: i64) -> CampaignGetCall<'a, C> {
28239        self._id = new_value;
28240        self
28241    }
28242    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28243    /// while executing the actual API request.
28244    ///
28245    /// ````text
28246    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28247    /// ````
28248    ///
28249    /// Sets the *delegate* property to the given value.
28250    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CampaignGetCall<'a, C> {
28251        self._delegate = Some(new_value);
28252        self
28253    }
28254
28255    /// Set any additional parameter of the query string used in the request.
28256    /// It should be used to set parameters which are not yet available through their own
28257    /// setters.
28258    ///
28259    /// Please note that this method must not be used to set any of the known parameters
28260    /// which have their own setter method. If done anyway, the request will fail.
28261    ///
28262    /// # Additional Parameters
28263    ///
28264    /// * *alt* (query-string) - Data format for the response.
28265    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28266    /// * *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.
28267    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28268    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28269    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28270    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28271    pub fn param<T>(mut self, name: T, value: T) -> CampaignGetCall<'a, C>
28272    where
28273        T: AsRef<str>,
28274    {
28275        self._additional_params
28276            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28277        self
28278    }
28279
28280    /// Identifies the authorization scope for the method you are building.
28281    ///
28282    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28283    /// [`Scope::Dfatrafficking`].
28284    ///
28285    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28286    /// tokens for more than one scope.
28287    ///
28288    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28289    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28290    /// sufficient, a read-write scope will do as well.
28291    pub fn add_scope<St>(mut self, scope: St) -> CampaignGetCall<'a, C>
28292    where
28293        St: AsRef<str>,
28294    {
28295        self._scopes.insert(String::from(scope.as_ref()));
28296        self
28297    }
28298    /// Identifies the authorization scope(s) for the method you are building.
28299    ///
28300    /// See [`Self::add_scope()`] for details.
28301    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignGetCall<'a, C>
28302    where
28303        I: IntoIterator<Item = St>,
28304        St: AsRef<str>,
28305    {
28306        self._scopes
28307            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28308        self
28309    }
28310
28311    /// Removes all scopes, and no default scope will be used either.
28312    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28313    /// for details).
28314    pub fn clear_scopes(mut self) -> CampaignGetCall<'a, C> {
28315        self._scopes.clear();
28316        self
28317    }
28318}
28319
28320/// Inserts a new campaign.
28321///
28322/// A builder for the *insert* method supported by a *campaign* resource.
28323/// It is not used directly, but through a [`CampaignMethods`] instance.
28324///
28325/// # Example
28326///
28327/// Instantiate a resource method builder
28328///
28329/// ```test_harness,no_run
28330/// # extern crate hyper;
28331/// # extern crate hyper_rustls;
28332/// # extern crate google_dfareporting3d2 as dfareporting3d2;
28333/// use dfareporting3d2::api::Campaign;
28334/// # async fn dox() {
28335/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28336///
28337/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28338/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28339/// #     secret,
28340/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28341/// # ).build().await.unwrap();
28342///
28343/// # let client = hyper_util::client::legacy::Client::builder(
28344/// #     hyper_util::rt::TokioExecutor::new()
28345/// # )
28346/// # .build(
28347/// #     hyper_rustls::HttpsConnectorBuilder::new()
28348/// #         .with_native_roots()
28349/// #         .unwrap()
28350/// #         .https_or_http()
28351/// #         .enable_http1()
28352/// #         .build()
28353/// # );
28354/// # let mut hub = Dfareporting::new(client, auth);
28355/// // As the method needs a request, you would usually fill it with the desired information
28356/// // into the respective structure. Some of the parts shown here might not be applicable !
28357/// // Values shown here are possibly random and not representative !
28358/// let mut req = Campaign::default();
28359///
28360/// // You can configure optional parameters by calling the respective setters at will, and
28361/// // execute the final call using `doit()`.
28362/// // Values shown here are possibly random and not representative !
28363/// let result = hub.campaigns().insert(req, -74)
28364///              .doit().await;
28365/// # }
28366/// ```
28367pub struct CampaignInsertCall<'a, C>
28368where
28369    C: 'a,
28370{
28371    hub: &'a Dfareporting<C>,
28372    _request: Campaign,
28373    _profile_id: i64,
28374    _delegate: Option<&'a mut dyn common::Delegate>,
28375    _additional_params: HashMap<String, String>,
28376    _scopes: BTreeSet<String>,
28377}
28378
28379impl<'a, C> common::CallBuilder for CampaignInsertCall<'a, C> {}
28380
28381impl<'a, C> CampaignInsertCall<'a, C>
28382where
28383    C: common::Connector,
28384{
28385    /// Perform the operation you have build so far.
28386    pub async fn doit(mut self) -> common::Result<(common::Response, Campaign)> {
28387        use std::borrow::Cow;
28388        use std::io::{Read, Seek};
28389
28390        use common::{url::Params, ToParts};
28391        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28392
28393        let mut dd = common::DefaultDelegate;
28394        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28395        dlg.begin(common::MethodInfo {
28396            id: "dfareporting.campaigns.insert",
28397            http_method: hyper::Method::POST,
28398        });
28399
28400        for &field in ["alt", "profileId"].iter() {
28401            if self._additional_params.contains_key(field) {
28402                dlg.finished(false);
28403                return Err(common::Error::FieldClash(field));
28404            }
28405        }
28406
28407        let mut params = Params::with_capacity(4 + self._additional_params.len());
28408        params.push("profileId", self._profile_id.to_string());
28409
28410        params.extend(self._additional_params.iter());
28411
28412        params.push("alt", "json");
28413        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns";
28414        if self._scopes.is_empty() {
28415            self._scopes
28416                .insert(Scope::Dfatrafficking.as_ref().to_string());
28417        }
28418
28419        #[allow(clippy::single_element_loop)]
28420        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
28421            url = params.uri_replacement(url, param_name, find_this, false);
28422        }
28423        {
28424            let to_remove = ["profileId"];
28425            params.remove_params(&to_remove);
28426        }
28427
28428        let url = params.parse_with_url(&url);
28429
28430        let mut json_mime_type = mime::APPLICATION_JSON;
28431        let mut request_value_reader = {
28432            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28433            common::remove_json_null_values(&mut value);
28434            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28435            serde_json::to_writer(&mut dst, &value).unwrap();
28436            dst
28437        };
28438        let request_size = request_value_reader
28439            .seek(std::io::SeekFrom::End(0))
28440            .unwrap();
28441        request_value_reader
28442            .seek(std::io::SeekFrom::Start(0))
28443            .unwrap();
28444
28445        loop {
28446            let token = match self
28447                .hub
28448                .auth
28449                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28450                .await
28451            {
28452                Ok(token) => token,
28453                Err(e) => match dlg.token(e) {
28454                    Ok(token) => token,
28455                    Err(e) => {
28456                        dlg.finished(false);
28457                        return Err(common::Error::MissingToken(e));
28458                    }
28459                },
28460            };
28461            request_value_reader
28462                .seek(std::io::SeekFrom::Start(0))
28463                .unwrap();
28464            let mut req_result = {
28465                let client = &self.hub.client;
28466                dlg.pre_request();
28467                let mut req_builder = hyper::Request::builder()
28468                    .method(hyper::Method::POST)
28469                    .uri(url.as_str())
28470                    .header(USER_AGENT, self.hub._user_agent.clone());
28471
28472                if let Some(token) = token.as_ref() {
28473                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28474                }
28475
28476                let request = req_builder
28477                    .header(CONTENT_TYPE, json_mime_type.to_string())
28478                    .header(CONTENT_LENGTH, request_size as u64)
28479                    .body(common::to_body(
28480                        request_value_reader.get_ref().clone().into(),
28481                    ));
28482
28483                client.request(request.unwrap()).await
28484            };
28485
28486            match req_result {
28487                Err(err) => {
28488                    if let common::Retry::After(d) = dlg.http_error(&err) {
28489                        sleep(d).await;
28490                        continue;
28491                    }
28492                    dlg.finished(false);
28493                    return Err(common::Error::HttpError(err));
28494                }
28495                Ok(res) => {
28496                    let (mut parts, body) = res.into_parts();
28497                    let mut body = common::Body::new(body);
28498                    if !parts.status.is_success() {
28499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28500                        let error = serde_json::from_str(&common::to_string(&bytes));
28501                        let response = common::to_response(parts, bytes.into());
28502
28503                        if let common::Retry::After(d) =
28504                            dlg.http_failure(&response, error.as_ref().ok())
28505                        {
28506                            sleep(d).await;
28507                            continue;
28508                        }
28509
28510                        dlg.finished(false);
28511
28512                        return Err(match error {
28513                            Ok(value) => common::Error::BadRequest(value),
28514                            _ => common::Error::Failure(response),
28515                        });
28516                    }
28517                    let response = {
28518                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28519                        let encoded = common::to_string(&bytes);
28520                        match serde_json::from_str(&encoded) {
28521                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28522                            Err(error) => {
28523                                dlg.response_json_decode_error(&encoded, &error);
28524                                return Err(common::Error::JsonDecodeError(
28525                                    encoded.to_string(),
28526                                    error,
28527                                ));
28528                            }
28529                        }
28530                    };
28531
28532                    dlg.finished(true);
28533                    return Ok(response);
28534                }
28535            }
28536        }
28537    }
28538
28539    ///
28540    /// Sets the *request* property to the given value.
28541    ///
28542    /// Even though the property as already been set when instantiating this call,
28543    /// we provide this method for API completeness.
28544    pub fn request(mut self, new_value: Campaign) -> CampaignInsertCall<'a, C> {
28545        self._request = new_value;
28546        self
28547    }
28548    /// User profile ID associated with this request.
28549    ///
28550    /// Sets the *profile id* path property to the given value.
28551    ///
28552    /// Even though the property as already been set when instantiating this call,
28553    /// we provide this method for API completeness.
28554    pub fn profile_id(mut self, new_value: i64) -> CampaignInsertCall<'a, C> {
28555        self._profile_id = new_value;
28556        self
28557    }
28558    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28559    /// while executing the actual API request.
28560    ///
28561    /// ````text
28562    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28563    /// ````
28564    ///
28565    /// Sets the *delegate* property to the given value.
28566    pub fn delegate(
28567        mut self,
28568        new_value: &'a mut dyn common::Delegate,
28569    ) -> CampaignInsertCall<'a, C> {
28570        self._delegate = Some(new_value);
28571        self
28572    }
28573
28574    /// Set any additional parameter of the query string used in the request.
28575    /// It should be used to set parameters which are not yet available through their own
28576    /// setters.
28577    ///
28578    /// Please note that this method must not be used to set any of the known parameters
28579    /// which have their own setter method. If done anyway, the request will fail.
28580    ///
28581    /// # Additional Parameters
28582    ///
28583    /// * *alt* (query-string) - Data format for the response.
28584    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28585    /// * *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.
28586    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28587    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28588    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
28589    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
28590    pub fn param<T>(mut self, name: T, value: T) -> CampaignInsertCall<'a, C>
28591    where
28592        T: AsRef<str>,
28593    {
28594        self._additional_params
28595            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28596        self
28597    }
28598
28599    /// Identifies the authorization scope for the method you are building.
28600    ///
28601    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28602    /// [`Scope::Dfatrafficking`].
28603    ///
28604    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28605    /// tokens for more than one scope.
28606    ///
28607    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28608    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28609    /// sufficient, a read-write scope will do as well.
28610    pub fn add_scope<St>(mut self, scope: St) -> CampaignInsertCall<'a, C>
28611    where
28612        St: AsRef<str>,
28613    {
28614        self._scopes.insert(String::from(scope.as_ref()));
28615        self
28616    }
28617    /// Identifies the authorization scope(s) for the method you are building.
28618    ///
28619    /// See [`Self::add_scope()`] for details.
28620    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignInsertCall<'a, C>
28621    where
28622        I: IntoIterator<Item = St>,
28623        St: AsRef<str>,
28624    {
28625        self._scopes
28626            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28627        self
28628    }
28629
28630    /// Removes all scopes, and no default scope will be used either.
28631    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28632    /// for details).
28633    pub fn clear_scopes(mut self) -> CampaignInsertCall<'a, C> {
28634        self._scopes.clear();
28635        self
28636    }
28637}
28638
28639/// Retrieves a list of campaigns, possibly filtered. This method supports paging.
28640///
28641/// A builder for the *list* method supported by a *campaign* resource.
28642/// It is not used directly, but through a [`CampaignMethods`] instance.
28643///
28644/// # Example
28645///
28646/// Instantiate a resource method builder
28647///
28648/// ```test_harness,no_run
28649/// # extern crate hyper;
28650/// # extern crate hyper_rustls;
28651/// # extern crate google_dfareporting3d2 as dfareporting3d2;
28652/// # async fn dox() {
28653/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28654///
28655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
28657/// #     secret,
28658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28659/// # ).build().await.unwrap();
28660///
28661/// # let client = hyper_util::client::legacy::Client::builder(
28662/// #     hyper_util::rt::TokioExecutor::new()
28663/// # )
28664/// # .build(
28665/// #     hyper_rustls::HttpsConnectorBuilder::new()
28666/// #         .with_native_roots()
28667/// #         .unwrap()
28668/// #         .https_or_http()
28669/// #         .enable_http1()
28670/// #         .build()
28671/// # );
28672/// # let mut hub = Dfareporting::new(client, auth);
28673/// // You can configure optional parameters by calling the respective setters at will, and
28674/// // execute the final call using `doit()`.
28675/// // Values shown here are possibly random and not representative !
28676/// let result = hub.campaigns().list(-77)
28677///              .subaccount_id(-84)
28678///              .sort_order("eirmod")
28679///              .sort_field("Lorem")
28680///              .search_string("accusam")
28681///              .page_token("amet")
28682///              .overridden_event_tag_id(-31)
28683///              .max_results(-69)
28684///              .add_ids(-81)
28685///              .add_excluded_ids(-73)
28686///              .at_least_one_optimization_activity(true)
28687///              .archived(true)
28688///              .add_advertiser_ids(-22)
28689///              .add_advertiser_group_ids(-77)
28690///              .doit().await;
28691/// # }
28692/// ```
28693pub struct CampaignListCall<'a, C>
28694where
28695    C: 'a,
28696{
28697    hub: &'a Dfareporting<C>,
28698    _profile_id: i64,
28699    _subaccount_id: Option<i64>,
28700    _sort_order: Option<String>,
28701    _sort_field: Option<String>,
28702    _search_string: Option<String>,
28703    _page_token: Option<String>,
28704    _overridden_event_tag_id: Option<i64>,
28705    _max_results: Option<i32>,
28706    _ids: Vec<i64>,
28707    _excluded_ids: Vec<i64>,
28708    _at_least_one_optimization_activity: Option<bool>,
28709    _archived: Option<bool>,
28710    _advertiser_ids: Vec<i64>,
28711    _advertiser_group_ids: Vec<i64>,
28712    _delegate: Option<&'a mut dyn common::Delegate>,
28713    _additional_params: HashMap<String, String>,
28714    _scopes: BTreeSet<String>,
28715}
28716
28717impl<'a, C> common::CallBuilder for CampaignListCall<'a, C> {}
28718
28719impl<'a, C> CampaignListCall<'a, C>
28720where
28721    C: common::Connector,
28722{
28723    /// Perform the operation you have build so far.
28724    pub async fn doit(mut self) -> common::Result<(common::Response, CampaignsListResponse)> {
28725        use std::borrow::Cow;
28726        use std::io::{Read, Seek};
28727
28728        use common::{url::Params, ToParts};
28729        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28730
28731        let mut dd = common::DefaultDelegate;
28732        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28733        dlg.begin(common::MethodInfo {
28734            id: "dfareporting.campaigns.list",
28735            http_method: hyper::Method::GET,
28736        });
28737
28738        for &field in [
28739            "alt",
28740            "profileId",
28741            "subaccountId",
28742            "sortOrder",
28743            "sortField",
28744            "searchString",
28745            "pageToken",
28746            "overriddenEventTagId",
28747            "maxResults",
28748            "ids",
28749            "excludedIds",
28750            "atLeastOneOptimizationActivity",
28751            "archived",
28752            "advertiserIds",
28753            "advertiserGroupIds",
28754        ]
28755        .iter()
28756        {
28757            if self._additional_params.contains_key(field) {
28758                dlg.finished(false);
28759                return Err(common::Error::FieldClash(field));
28760            }
28761        }
28762
28763        let mut params = Params::with_capacity(16 + self._additional_params.len());
28764        params.push("profileId", self._profile_id.to_string());
28765        if let Some(value) = self._subaccount_id.as_ref() {
28766            params.push("subaccountId", value.to_string());
28767        }
28768        if let Some(value) = self._sort_order.as_ref() {
28769            params.push("sortOrder", value);
28770        }
28771        if let Some(value) = self._sort_field.as_ref() {
28772            params.push("sortField", value);
28773        }
28774        if let Some(value) = self._search_string.as_ref() {
28775            params.push("searchString", value);
28776        }
28777        if let Some(value) = self._page_token.as_ref() {
28778            params.push("pageToken", value);
28779        }
28780        if let Some(value) = self._overridden_event_tag_id.as_ref() {
28781            params.push("overriddenEventTagId", value.to_string());
28782        }
28783        if let Some(value) = self._max_results.as_ref() {
28784            params.push("maxResults", value.to_string());
28785        }
28786        if !self._ids.is_empty() {
28787            for f in self._ids.iter() {
28788                params.push("ids", f.to_string());
28789            }
28790        }
28791        if !self._excluded_ids.is_empty() {
28792            for f in self._excluded_ids.iter() {
28793                params.push("excludedIds", f.to_string());
28794            }
28795        }
28796        if let Some(value) = self._at_least_one_optimization_activity.as_ref() {
28797            params.push("atLeastOneOptimizationActivity", value.to_string());
28798        }
28799        if let Some(value) = self._archived.as_ref() {
28800            params.push("archived", value.to_string());
28801        }
28802        if !self._advertiser_ids.is_empty() {
28803            for f in self._advertiser_ids.iter() {
28804                params.push("advertiserIds", f.to_string());
28805            }
28806        }
28807        if !self._advertiser_group_ids.is_empty() {
28808            for f in self._advertiser_group_ids.iter() {
28809                params.push("advertiserGroupIds", f.to_string());
28810            }
28811        }
28812
28813        params.extend(self._additional_params.iter());
28814
28815        params.push("alt", "json");
28816        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns";
28817        if self._scopes.is_empty() {
28818            self._scopes
28819                .insert(Scope::Dfatrafficking.as_ref().to_string());
28820        }
28821
28822        #[allow(clippy::single_element_loop)]
28823        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
28824            url = params.uri_replacement(url, param_name, find_this, false);
28825        }
28826        {
28827            let to_remove = ["profileId"];
28828            params.remove_params(&to_remove);
28829        }
28830
28831        let url = params.parse_with_url(&url);
28832
28833        loop {
28834            let token = match self
28835                .hub
28836                .auth
28837                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28838                .await
28839            {
28840                Ok(token) => token,
28841                Err(e) => match dlg.token(e) {
28842                    Ok(token) => token,
28843                    Err(e) => {
28844                        dlg.finished(false);
28845                        return Err(common::Error::MissingToken(e));
28846                    }
28847                },
28848            };
28849            let mut req_result = {
28850                let client = &self.hub.client;
28851                dlg.pre_request();
28852                let mut req_builder = hyper::Request::builder()
28853                    .method(hyper::Method::GET)
28854                    .uri(url.as_str())
28855                    .header(USER_AGENT, self.hub._user_agent.clone());
28856
28857                if let Some(token) = token.as_ref() {
28858                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28859                }
28860
28861                let request = req_builder
28862                    .header(CONTENT_LENGTH, 0_u64)
28863                    .body(common::to_body::<String>(None));
28864
28865                client.request(request.unwrap()).await
28866            };
28867
28868            match req_result {
28869                Err(err) => {
28870                    if let common::Retry::After(d) = dlg.http_error(&err) {
28871                        sleep(d).await;
28872                        continue;
28873                    }
28874                    dlg.finished(false);
28875                    return Err(common::Error::HttpError(err));
28876                }
28877                Ok(res) => {
28878                    let (mut parts, body) = res.into_parts();
28879                    let mut body = common::Body::new(body);
28880                    if !parts.status.is_success() {
28881                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28882                        let error = serde_json::from_str(&common::to_string(&bytes));
28883                        let response = common::to_response(parts, bytes.into());
28884
28885                        if let common::Retry::After(d) =
28886                            dlg.http_failure(&response, error.as_ref().ok())
28887                        {
28888                            sleep(d).await;
28889                            continue;
28890                        }
28891
28892                        dlg.finished(false);
28893
28894                        return Err(match error {
28895                            Ok(value) => common::Error::BadRequest(value),
28896                            _ => common::Error::Failure(response),
28897                        });
28898                    }
28899                    let response = {
28900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28901                        let encoded = common::to_string(&bytes);
28902                        match serde_json::from_str(&encoded) {
28903                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28904                            Err(error) => {
28905                                dlg.response_json_decode_error(&encoded, &error);
28906                                return Err(common::Error::JsonDecodeError(
28907                                    encoded.to_string(),
28908                                    error,
28909                                ));
28910                            }
28911                        }
28912                    };
28913
28914                    dlg.finished(true);
28915                    return Ok(response);
28916                }
28917            }
28918        }
28919    }
28920
28921    /// User profile ID associated with this request.
28922    ///
28923    /// Sets the *profile id* path property to the given value.
28924    ///
28925    /// Even though the property as already been set when instantiating this call,
28926    /// we provide this method for API completeness.
28927    pub fn profile_id(mut self, new_value: i64) -> CampaignListCall<'a, C> {
28928        self._profile_id = new_value;
28929        self
28930    }
28931    /// Select only campaigns that belong to this subaccount.
28932    ///
28933    /// Sets the *subaccount id* query property to the given value.
28934    pub fn subaccount_id(mut self, new_value: i64) -> CampaignListCall<'a, C> {
28935        self._subaccount_id = Some(new_value);
28936        self
28937    }
28938    /// Order of sorted results.
28939    ///
28940    /// Sets the *sort order* query property to the given value.
28941    pub fn sort_order(mut self, new_value: &str) -> CampaignListCall<'a, C> {
28942        self._sort_order = Some(new_value.to_string());
28943        self
28944    }
28945    /// Field by which to sort the list.
28946    ///
28947    /// Sets the *sort field* query property to the given value.
28948    pub fn sort_field(mut self, new_value: &str) -> CampaignListCall<'a, C> {
28949        self._sort_field = Some(new_value.to_string());
28950        self
28951    }
28952    /// Allows searching for campaigns by name or ID. Wildcards (*) are allowed. For example, "campaign*2015" will return campaigns with names like "campaign June 2015", "campaign April 2015", or simply "campaign 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "campaign" will match campaigns with name "my campaign", "campaign 2015", or simply "campaign".
28953    ///
28954    /// Sets the *search string* query property to the given value.
28955    pub fn search_string(mut self, new_value: &str) -> CampaignListCall<'a, C> {
28956        self._search_string = Some(new_value.to_string());
28957        self
28958    }
28959    /// Value of the nextPageToken from the previous result page.
28960    ///
28961    /// Sets the *page token* query property to the given value.
28962    pub fn page_token(mut self, new_value: &str) -> CampaignListCall<'a, C> {
28963        self._page_token = Some(new_value.to_string());
28964        self
28965    }
28966    /// Select only campaigns that have overridden this event tag ID.
28967    ///
28968    /// Sets the *overridden event tag id* query property to the given value.
28969    pub fn overridden_event_tag_id(mut self, new_value: i64) -> CampaignListCall<'a, C> {
28970        self._overridden_event_tag_id = Some(new_value);
28971        self
28972    }
28973    /// Maximum number of results to return.
28974    ///
28975    /// Sets the *max results* query property to the given value.
28976    pub fn max_results(mut self, new_value: i32) -> CampaignListCall<'a, C> {
28977        self._max_results = Some(new_value);
28978        self
28979    }
28980    /// Select only campaigns with these IDs.
28981    ///
28982    /// Append the given value to the *ids* query property.
28983    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
28984    pub fn add_ids(mut self, new_value: i64) -> CampaignListCall<'a, C> {
28985        self._ids.push(new_value);
28986        self
28987    }
28988    /// Exclude campaigns with these IDs.
28989    ///
28990    /// Append the given value to the *excluded ids* query property.
28991    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
28992    pub fn add_excluded_ids(mut self, new_value: i64) -> CampaignListCall<'a, C> {
28993        self._excluded_ids.push(new_value);
28994        self
28995    }
28996    /// Select only campaigns that have at least one optimization activity.
28997    ///
28998    /// Sets the *at least one optimization activity* query property to the given value.
28999    pub fn at_least_one_optimization_activity(
29000        mut self,
29001        new_value: bool,
29002    ) -> CampaignListCall<'a, C> {
29003        self._at_least_one_optimization_activity = Some(new_value);
29004        self
29005    }
29006    /// Select only archived campaigns. Don't set this field to select both archived and non-archived campaigns.
29007    ///
29008    /// Sets the *archived* query property to the given value.
29009    pub fn archived(mut self, new_value: bool) -> CampaignListCall<'a, C> {
29010        self._archived = Some(new_value);
29011        self
29012    }
29013    /// Select only campaigns that belong to these advertisers.
29014    ///
29015    /// Append the given value to the *advertiser ids* query property.
29016    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
29017    pub fn add_advertiser_ids(mut self, new_value: i64) -> CampaignListCall<'a, C> {
29018        self._advertiser_ids.push(new_value);
29019        self
29020    }
29021    /// Select only campaigns whose advertisers belong to these advertiser groups.
29022    ///
29023    /// Append the given value to the *advertiser group ids* query property.
29024    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
29025    pub fn add_advertiser_group_ids(mut self, new_value: i64) -> CampaignListCall<'a, C> {
29026        self._advertiser_group_ids.push(new_value);
29027        self
29028    }
29029    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29030    /// while executing the actual API request.
29031    ///
29032    /// ````text
29033    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29034    /// ````
29035    ///
29036    /// Sets the *delegate* property to the given value.
29037    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CampaignListCall<'a, C> {
29038        self._delegate = Some(new_value);
29039        self
29040    }
29041
29042    /// Set any additional parameter of the query string used in the request.
29043    /// It should be used to set parameters which are not yet available through their own
29044    /// setters.
29045    ///
29046    /// Please note that this method must not be used to set any of the known parameters
29047    /// which have their own setter method. If done anyway, the request will fail.
29048    ///
29049    /// # Additional Parameters
29050    ///
29051    /// * *alt* (query-string) - Data format for the response.
29052    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29053    /// * *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.
29054    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29055    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29056    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29057    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29058    pub fn param<T>(mut self, name: T, value: T) -> CampaignListCall<'a, C>
29059    where
29060        T: AsRef<str>,
29061    {
29062        self._additional_params
29063            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29064        self
29065    }
29066
29067    /// Identifies the authorization scope for the method you are building.
29068    ///
29069    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29070    /// [`Scope::Dfatrafficking`].
29071    ///
29072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29073    /// tokens for more than one scope.
29074    ///
29075    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29076    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29077    /// sufficient, a read-write scope will do as well.
29078    pub fn add_scope<St>(mut self, scope: St) -> CampaignListCall<'a, C>
29079    where
29080        St: AsRef<str>,
29081    {
29082        self._scopes.insert(String::from(scope.as_ref()));
29083        self
29084    }
29085    /// Identifies the authorization scope(s) for the method you are building.
29086    ///
29087    /// See [`Self::add_scope()`] for details.
29088    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignListCall<'a, C>
29089    where
29090        I: IntoIterator<Item = St>,
29091        St: AsRef<str>,
29092    {
29093        self._scopes
29094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29095        self
29096    }
29097
29098    /// Removes all scopes, and no default scope will be used either.
29099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29100    /// for details).
29101    pub fn clear_scopes(mut self) -> CampaignListCall<'a, C> {
29102        self._scopes.clear();
29103        self
29104    }
29105}
29106
29107/// Updates an existing campaign. This method supports patch semantics.
29108///
29109/// A builder for the *patch* method supported by a *campaign* resource.
29110/// It is not used directly, but through a [`CampaignMethods`] instance.
29111///
29112/// # Example
29113///
29114/// Instantiate a resource method builder
29115///
29116/// ```test_harness,no_run
29117/// # extern crate hyper;
29118/// # extern crate hyper_rustls;
29119/// # extern crate google_dfareporting3d2 as dfareporting3d2;
29120/// use dfareporting3d2::api::Campaign;
29121/// # async fn dox() {
29122/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29123///
29124/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29126/// #     secret,
29127/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29128/// # ).build().await.unwrap();
29129///
29130/// # let client = hyper_util::client::legacy::Client::builder(
29131/// #     hyper_util::rt::TokioExecutor::new()
29132/// # )
29133/// # .build(
29134/// #     hyper_rustls::HttpsConnectorBuilder::new()
29135/// #         .with_native_roots()
29136/// #         .unwrap()
29137/// #         .https_or_http()
29138/// #         .enable_http1()
29139/// #         .build()
29140/// # );
29141/// # let mut hub = Dfareporting::new(client, auth);
29142/// // As the method needs a request, you would usually fill it with the desired information
29143/// // into the respective structure. Some of the parts shown here might not be applicable !
29144/// // Values shown here are possibly random and not representative !
29145/// let mut req = Campaign::default();
29146///
29147/// // You can configure optional parameters by calling the respective setters at will, and
29148/// // execute the final call using `doit()`.
29149/// // Values shown here are possibly random and not representative !
29150/// let result = hub.campaigns().patch(req, -4, -22)
29151///              .doit().await;
29152/// # }
29153/// ```
29154pub struct CampaignPatchCall<'a, C>
29155where
29156    C: 'a,
29157{
29158    hub: &'a Dfareporting<C>,
29159    _request: Campaign,
29160    _profile_id: i64,
29161    _id: i64,
29162    _delegate: Option<&'a mut dyn common::Delegate>,
29163    _additional_params: HashMap<String, String>,
29164    _scopes: BTreeSet<String>,
29165}
29166
29167impl<'a, C> common::CallBuilder for CampaignPatchCall<'a, C> {}
29168
29169impl<'a, C> CampaignPatchCall<'a, C>
29170where
29171    C: common::Connector,
29172{
29173    /// Perform the operation you have build so far.
29174    pub async fn doit(mut self) -> common::Result<(common::Response, Campaign)> {
29175        use std::borrow::Cow;
29176        use std::io::{Read, Seek};
29177
29178        use common::{url::Params, ToParts};
29179        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29180
29181        let mut dd = common::DefaultDelegate;
29182        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29183        dlg.begin(common::MethodInfo {
29184            id: "dfareporting.campaigns.patch",
29185            http_method: hyper::Method::PATCH,
29186        });
29187
29188        for &field in ["alt", "profileId", "id"].iter() {
29189            if self._additional_params.contains_key(field) {
29190                dlg.finished(false);
29191                return Err(common::Error::FieldClash(field));
29192            }
29193        }
29194
29195        let mut params = Params::with_capacity(5 + self._additional_params.len());
29196        params.push("profileId", self._profile_id.to_string());
29197        params.push("id", self._id.to_string());
29198
29199        params.extend(self._additional_params.iter());
29200
29201        params.push("alt", "json");
29202        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns";
29203        if self._scopes.is_empty() {
29204            self._scopes
29205                .insert(Scope::Dfatrafficking.as_ref().to_string());
29206        }
29207
29208        #[allow(clippy::single_element_loop)]
29209        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
29210            url = params.uri_replacement(url, param_name, find_this, false);
29211        }
29212        {
29213            let to_remove = ["profileId"];
29214            params.remove_params(&to_remove);
29215        }
29216
29217        let url = params.parse_with_url(&url);
29218
29219        let mut json_mime_type = mime::APPLICATION_JSON;
29220        let mut request_value_reader = {
29221            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29222            common::remove_json_null_values(&mut value);
29223            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29224            serde_json::to_writer(&mut dst, &value).unwrap();
29225            dst
29226        };
29227        let request_size = request_value_reader
29228            .seek(std::io::SeekFrom::End(0))
29229            .unwrap();
29230        request_value_reader
29231            .seek(std::io::SeekFrom::Start(0))
29232            .unwrap();
29233
29234        loop {
29235            let token = match self
29236                .hub
29237                .auth
29238                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29239                .await
29240            {
29241                Ok(token) => token,
29242                Err(e) => match dlg.token(e) {
29243                    Ok(token) => token,
29244                    Err(e) => {
29245                        dlg.finished(false);
29246                        return Err(common::Error::MissingToken(e));
29247                    }
29248                },
29249            };
29250            request_value_reader
29251                .seek(std::io::SeekFrom::Start(0))
29252                .unwrap();
29253            let mut req_result = {
29254                let client = &self.hub.client;
29255                dlg.pre_request();
29256                let mut req_builder = hyper::Request::builder()
29257                    .method(hyper::Method::PATCH)
29258                    .uri(url.as_str())
29259                    .header(USER_AGENT, self.hub._user_agent.clone());
29260
29261                if let Some(token) = token.as_ref() {
29262                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29263                }
29264
29265                let request = req_builder
29266                    .header(CONTENT_TYPE, json_mime_type.to_string())
29267                    .header(CONTENT_LENGTH, request_size as u64)
29268                    .body(common::to_body(
29269                        request_value_reader.get_ref().clone().into(),
29270                    ));
29271
29272                client.request(request.unwrap()).await
29273            };
29274
29275            match req_result {
29276                Err(err) => {
29277                    if let common::Retry::After(d) = dlg.http_error(&err) {
29278                        sleep(d).await;
29279                        continue;
29280                    }
29281                    dlg.finished(false);
29282                    return Err(common::Error::HttpError(err));
29283                }
29284                Ok(res) => {
29285                    let (mut parts, body) = res.into_parts();
29286                    let mut body = common::Body::new(body);
29287                    if !parts.status.is_success() {
29288                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29289                        let error = serde_json::from_str(&common::to_string(&bytes));
29290                        let response = common::to_response(parts, bytes.into());
29291
29292                        if let common::Retry::After(d) =
29293                            dlg.http_failure(&response, error.as_ref().ok())
29294                        {
29295                            sleep(d).await;
29296                            continue;
29297                        }
29298
29299                        dlg.finished(false);
29300
29301                        return Err(match error {
29302                            Ok(value) => common::Error::BadRequest(value),
29303                            _ => common::Error::Failure(response),
29304                        });
29305                    }
29306                    let response = {
29307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29308                        let encoded = common::to_string(&bytes);
29309                        match serde_json::from_str(&encoded) {
29310                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29311                            Err(error) => {
29312                                dlg.response_json_decode_error(&encoded, &error);
29313                                return Err(common::Error::JsonDecodeError(
29314                                    encoded.to_string(),
29315                                    error,
29316                                ));
29317                            }
29318                        }
29319                    };
29320
29321                    dlg.finished(true);
29322                    return Ok(response);
29323                }
29324            }
29325        }
29326    }
29327
29328    ///
29329    /// Sets the *request* property to the given value.
29330    ///
29331    /// Even though the property as already been set when instantiating this call,
29332    /// we provide this method for API completeness.
29333    pub fn request(mut self, new_value: Campaign) -> CampaignPatchCall<'a, C> {
29334        self._request = new_value;
29335        self
29336    }
29337    /// User profile ID associated with this request.
29338    ///
29339    /// Sets the *profile id* path property to the given value.
29340    ///
29341    /// Even though the property as already been set when instantiating this call,
29342    /// we provide this method for API completeness.
29343    pub fn profile_id(mut self, new_value: i64) -> CampaignPatchCall<'a, C> {
29344        self._profile_id = new_value;
29345        self
29346    }
29347    /// Campaign ID.
29348    ///
29349    /// Sets the *id* query property to the given value.
29350    ///
29351    /// Even though the property as already been set when instantiating this call,
29352    /// we provide this method for API completeness.
29353    pub fn id(mut self, new_value: i64) -> CampaignPatchCall<'a, C> {
29354        self._id = new_value;
29355        self
29356    }
29357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29358    /// while executing the actual API request.
29359    ///
29360    /// ````text
29361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29362    /// ````
29363    ///
29364    /// Sets the *delegate* property to the given value.
29365    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CampaignPatchCall<'a, C> {
29366        self._delegate = Some(new_value);
29367        self
29368    }
29369
29370    /// Set any additional parameter of the query string used in the request.
29371    /// It should be used to set parameters which are not yet available through their own
29372    /// setters.
29373    ///
29374    /// Please note that this method must not be used to set any of the known parameters
29375    /// which have their own setter method. If done anyway, the request will fail.
29376    ///
29377    /// # Additional Parameters
29378    ///
29379    /// * *alt* (query-string) - Data format for the response.
29380    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29381    /// * *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.
29382    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29383    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29384    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29385    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29386    pub fn param<T>(mut self, name: T, value: T) -> CampaignPatchCall<'a, C>
29387    where
29388        T: AsRef<str>,
29389    {
29390        self._additional_params
29391            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29392        self
29393    }
29394
29395    /// Identifies the authorization scope for the method you are building.
29396    ///
29397    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29398    /// [`Scope::Dfatrafficking`].
29399    ///
29400    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29401    /// tokens for more than one scope.
29402    ///
29403    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29404    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29405    /// sufficient, a read-write scope will do as well.
29406    pub fn add_scope<St>(mut self, scope: St) -> CampaignPatchCall<'a, C>
29407    where
29408        St: AsRef<str>,
29409    {
29410        self._scopes.insert(String::from(scope.as_ref()));
29411        self
29412    }
29413    /// Identifies the authorization scope(s) for the method you are building.
29414    ///
29415    /// See [`Self::add_scope()`] for details.
29416    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignPatchCall<'a, C>
29417    where
29418        I: IntoIterator<Item = St>,
29419        St: AsRef<str>,
29420    {
29421        self._scopes
29422            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29423        self
29424    }
29425
29426    /// Removes all scopes, and no default scope will be used either.
29427    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29428    /// for details).
29429    pub fn clear_scopes(mut self) -> CampaignPatchCall<'a, C> {
29430        self._scopes.clear();
29431        self
29432    }
29433}
29434
29435/// Updates an existing campaign.
29436///
29437/// A builder for the *update* method supported by a *campaign* resource.
29438/// It is not used directly, but through a [`CampaignMethods`] instance.
29439///
29440/// # Example
29441///
29442/// Instantiate a resource method builder
29443///
29444/// ```test_harness,no_run
29445/// # extern crate hyper;
29446/// # extern crate hyper_rustls;
29447/// # extern crate google_dfareporting3d2 as dfareporting3d2;
29448/// use dfareporting3d2::api::Campaign;
29449/// # async fn dox() {
29450/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29451///
29452/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29453/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29454/// #     secret,
29455/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29456/// # ).build().await.unwrap();
29457///
29458/// # let client = hyper_util::client::legacy::Client::builder(
29459/// #     hyper_util::rt::TokioExecutor::new()
29460/// # )
29461/// # .build(
29462/// #     hyper_rustls::HttpsConnectorBuilder::new()
29463/// #         .with_native_roots()
29464/// #         .unwrap()
29465/// #         .https_or_http()
29466/// #         .enable_http1()
29467/// #         .build()
29468/// # );
29469/// # let mut hub = Dfareporting::new(client, auth);
29470/// // As the method needs a request, you would usually fill it with the desired information
29471/// // into the respective structure. Some of the parts shown here might not be applicable !
29472/// // Values shown here are possibly random and not representative !
29473/// let mut req = Campaign::default();
29474///
29475/// // You can configure optional parameters by calling the respective setters at will, and
29476/// // execute the final call using `doit()`.
29477/// // Values shown here are possibly random and not representative !
29478/// let result = hub.campaigns().update(req, -48)
29479///              .doit().await;
29480/// # }
29481/// ```
29482pub struct CampaignUpdateCall<'a, C>
29483where
29484    C: 'a,
29485{
29486    hub: &'a Dfareporting<C>,
29487    _request: Campaign,
29488    _profile_id: i64,
29489    _delegate: Option<&'a mut dyn common::Delegate>,
29490    _additional_params: HashMap<String, String>,
29491    _scopes: BTreeSet<String>,
29492}
29493
29494impl<'a, C> common::CallBuilder for CampaignUpdateCall<'a, C> {}
29495
29496impl<'a, C> CampaignUpdateCall<'a, C>
29497where
29498    C: common::Connector,
29499{
29500    /// Perform the operation you have build so far.
29501    pub async fn doit(mut self) -> common::Result<(common::Response, Campaign)> {
29502        use std::borrow::Cow;
29503        use std::io::{Read, Seek};
29504
29505        use common::{url::Params, ToParts};
29506        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29507
29508        let mut dd = common::DefaultDelegate;
29509        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29510        dlg.begin(common::MethodInfo {
29511            id: "dfareporting.campaigns.update",
29512            http_method: hyper::Method::PUT,
29513        });
29514
29515        for &field in ["alt", "profileId"].iter() {
29516            if self._additional_params.contains_key(field) {
29517                dlg.finished(false);
29518                return Err(common::Error::FieldClash(field));
29519            }
29520        }
29521
29522        let mut params = Params::with_capacity(4 + self._additional_params.len());
29523        params.push("profileId", self._profile_id.to_string());
29524
29525        params.extend(self._additional_params.iter());
29526
29527        params.push("alt", "json");
29528        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns";
29529        if self._scopes.is_empty() {
29530            self._scopes
29531                .insert(Scope::Dfatrafficking.as_ref().to_string());
29532        }
29533
29534        #[allow(clippy::single_element_loop)]
29535        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
29536            url = params.uri_replacement(url, param_name, find_this, false);
29537        }
29538        {
29539            let to_remove = ["profileId"];
29540            params.remove_params(&to_remove);
29541        }
29542
29543        let url = params.parse_with_url(&url);
29544
29545        let mut json_mime_type = mime::APPLICATION_JSON;
29546        let mut request_value_reader = {
29547            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29548            common::remove_json_null_values(&mut value);
29549            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29550            serde_json::to_writer(&mut dst, &value).unwrap();
29551            dst
29552        };
29553        let request_size = request_value_reader
29554            .seek(std::io::SeekFrom::End(0))
29555            .unwrap();
29556        request_value_reader
29557            .seek(std::io::SeekFrom::Start(0))
29558            .unwrap();
29559
29560        loop {
29561            let token = match self
29562                .hub
29563                .auth
29564                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29565                .await
29566            {
29567                Ok(token) => token,
29568                Err(e) => match dlg.token(e) {
29569                    Ok(token) => token,
29570                    Err(e) => {
29571                        dlg.finished(false);
29572                        return Err(common::Error::MissingToken(e));
29573                    }
29574                },
29575            };
29576            request_value_reader
29577                .seek(std::io::SeekFrom::Start(0))
29578                .unwrap();
29579            let mut req_result = {
29580                let client = &self.hub.client;
29581                dlg.pre_request();
29582                let mut req_builder = hyper::Request::builder()
29583                    .method(hyper::Method::PUT)
29584                    .uri(url.as_str())
29585                    .header(USER_AGENT, self.hub._user_agent.clone());
29586
29587                if let Some(token) = token.as_ref() {
29588                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29589                }
29590
29591                let request = req_builder
29592                    .header(CONTENT_TYPE, json_mime_type.to_string())
29593                    .header(CONTENT_LENGTH, request_size as u64)
29594                    .body(common::to_body(
29595                        request_value_reader.get_ref().clone().into(),
29596                    ));
29597
29598                client.request(request.unwrap()).await
29599            };
29600
29601            match req_result {
29602                Err(err) => {
29603                    if let common::Retry::After(d) = dlg.http_error(&err) {
29604                        sleep(d).await;
29605                        continue;
29606                    }
29607                    dlg.finished(false);
29608                    return Err(common::Error::HttpError(err));
29609                }
29610                Ok(res) => {
29611                    let (mut parts, body) = res.into_parts();
29612                    let mut body = common::Body::new(body);
29613                    if !parts.status.is_success() {
29614                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29615                        let error = serde_json::from_str(&common::to_string(&bytes));
29616                        let response = common::to_response(parts, bytes.into());
29617
29618                        if let common::Retry::After(d) =
29619                            dlg.http_failure(&response, error.as_ref().ok())
29620                        {
29621                            sleep(d).await;
29622                            continue;
29623                        }
29624
29625                        dlg.finished(false);
29626
29627                        return Err(match error {
29628                            Ok(value) => common::Error::BadRequest(value),
29629                            _ => common::Error::Failure(response),
29630                        });
29631                    }
29632                    let response = {
29633                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29634                        let encoded = common::to_string(&bytes);
29635                        match serde_json::from_str(&encoded) {
29636                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29637                            Err(error) => {
29638                                dlg.response_json_decode_error(&encoded, &error);
29639                                return Err(common::Error::JsonDecodeError(
29640                                    encoded.to_string(),
29641                                    error,
29642                                ));
29643                            }
29644                        }
29645                    };
29646
29647                    dlg.finished(true);
29648                    return Ok(response);
29649                }
29650            }
29651        }
29652    }
29653
29654    ///
29655    /// Sets the *request* property to the given value.
29656    ///
29657    /// Even though the property as already been set when instantiating this call,
29658    /// we provide this method for API completeness.
29659    pub fn request(mut self, new_value: Campaign) -> CampaignUpdateCall<'a, C> {
29660        self._request = new_value;
29661        self
29662    }
29663    /// User profile ID associated with this request.
29664    ///
29665    /// Sets the *profile id* path property to the given value.
29666    ///
29667    /// Even though the property as already been set when instantiating this call,
29668    /// we provide this method for API completeness.
29669    pub fn profile_id(mut self, new_value: i64) -> CampaignUpdateCall<'a, C> {
29670        self._profile_id = new_value;
29671        self
29672    }
29673    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29674    /// while executing the actual API request.
29675    ///
29676    /// ````text
29677    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29678    /// ````
29679    ///
29680    /// Sets the *delegate* property to the given value.
29681    pub fn delegate(
29682        mut self,
29683        new_value: &'a mut dyn common::Delegate,
29684    ) -> CampaignUpdateCall<'a, C> {
29685        self._delegate = Some(new_value);
29686        self
29687    }
29688
29689    /// Set any additional parameter of the query string used in the request.
29690    /// It should be used to set parameters which are not yet available through their own
29691    /// setters.
29692    ///
29693    /// Please note that this method must not be used to set any of the known parameters
29694    /// which have their own setter method. If done anyway, the request will fail.
29695    ///
29696    /// # Additional Parameters
29697    ///
29698    /// * *alt* (query-string) - Data format for the response.
29699    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29700    /// * *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.
29701    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29702    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29703    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29704    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29705    pub fn param<T>(mut self, name: T, value: T) -> CampaignUpdateCall<'a, C>
29706    where
29707        T: AsRef<str>,
29708    {
29709        self._additional_params
29710            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29711        self
29712    }
29713
29714    /// Identifies the authorization scope for the method you are building.
29715    ///
29716    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29717    /// [`Scope::Dfatrafficking`].
29718    ///
29719    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29720    /// tokens for more than one scope.
29721    ///
29722    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29723    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29724    /// sufficient, a read-write scope will do as well.
29725    pub fn add_scope<St>(mut self, scope: St) -> CampaignUpdateCall<'a, C>
29726    where
29727        St: AsRef<str>,
29728    {
29729        self._scopes.insert(String::from(scope.as_ref()));
29730        self
29731    }
29732    /// Identifies the authorization scope(s) for the method you are building.
29733    ///
29734    /// See [`Self::add_scope()`] for details.
29735    pub fn add_scopes<I, St>(mut self, scopes: I) -> CampaignUpdateCall<'a, C>
29736    where
29737        I: IntoIterator<Item = St>,
29738        St: AsRef<str>,
29739    {
29740        self._scopes
29741            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29742        self
29743    }
29744
29745    /// Removes all scopes, and no default scope will be used either.
29746    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29747    /// for details).
29748    pub fn clear_scopes(mut self) -> CampaignUpdateCall<'a, C> {
29749        self._scopes.clear();
29750        self
29751    }
29752}
29753
29754/// Gets one change log by ID.
29755///
29756/// A builder for the *get* method supported by a *changeLog* resource.
29757/// It is not used directly, but through a [`ChangeLogMethods`] instance.
29758///
29759/// # Example
29760///
29761/// Instantiate a resource method builder
29762///
29763/// ```test_harness,no_run
29764/// # extern crate hyper;
29765/// # extern crate hyper_rustls;
29766/// # extern crate google_dfareporting3d2 as dfareporting3d2;
29767/// # async fn dox() {
29768/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29769///
29770/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29771/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
29772/// #     secret,
29773/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29774/// # ).build().await.unwrap();
29775///
29776/// # let client = hyper_util::client::legacy::Client::builder(
29777/// #     hyper_util::rt::TokioExecutor::new()
29778/// # )
29779/// # .build(
29780/// #     hyper_rustls::HttpsConnectorBuilder::new()
29781/// #         .with_native_roots()
29782/// #         .unwrap()
29783/// #         .https_or_http()
29784/// #         .enable_http1()
29785/// #         .build()
29786/// # );
29787/// # let mut hub = Dfareporting::new(client, auth);
29788/// // You can configure optional parameters by calling the respective setters at will, and
29789/// // execute the final call using `doit()`.
29790/// // Values shown here are possibly random and not representative !
29791/// let result = hub.change_logs().get(-81, -10)
29792///              .doit().await;
29793/// # }
29794/// ```
29795pub struct ChangeLogGetCall<'a, C>
29796where
29797    C: 'a,
29798{
29799    hub: &'a Dfareporting<C>,
29800    _profile_id: i64,
29801    _id: i64,
29802    _delegate: Option<&'a mut dyn common::Delegate>,
29803    _additional_params: HashMap<String, String>,
29804    _scopes: BTreeSet<String>,
29805}
29806
29807impl<'a, C> common::CallBuilder for ChangeLogGetCall<'a, C> {}
29808
29809impl<'a, C> ChangeLogGetCall<'a, C>
29810where
29811    C: common::Connector,
29812{
29813    /// Perform the operation you have build so far.
29814    pub async fn doit(mut self) -> common::Result<(common::Response, ChangeLog)> {
29815        use std::borrow::Cow;
29816        use std::io::{Read, Seek};
29817
29818        use common::{url::Params, ToParts};
29819        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29820
29821        let mut dd = common::DefaultDelegate;
29822        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29823        dlg.begin(common::MethodInfo {
29824            id: "dfareporting.changeLogs.get",
29825            http_method: hyper::Method::GET,
29826        });
29827
29828        for &field in ["alt", "profileId", "id"].iter() {
29829            if self._additional_params.contains_key(field) {
29830                dlg.finished(false);
29831                return Err(common::Error::FieldClash(field));
29832            }
29833        }
29834
29835        let mut params = Params::with_capacity(4 + self._additional_params.len());
29836        params.push("profileId", self._profile_id.to_string());
29837        params.push("id", self._id.to_string());
29838
29839        params.extend(self._additional_params.iter());
29840
29841        params.push("alt", "json");
29842        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/changeLogs/{id}";
29843        if self._scopes.is_empty() {
29844            self._scopes
29845                .insert(Scope::Dfatrafficking.as_ref().to_string());
29846        }
29847
29848        #[allow(clippy::single_element_loop)]
29849        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
29850            url = params.uri_replacement(url, param_name, find_this, false);
29851        }
29852        {
29853            let to_remove = ["id", "profileId"];
29854            params.remove_params(&to_remove);
29855        }
29856
29857        let url = params.parse_with_url(&url);
29858
29859        loop {
29860            let token = match self
29861                .hub
29862                .auth
29863                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29864                .await
29865            {
29866                Ok(token) => token,
29867                Err(e) => match dlg.token(e) {
29868                    Ok(token) => token,
29869                    Err(e) => {
29870                        dlg.finished(false);
29871                        return Err(common::Error::MissingToken(e));
29872                    }
29873                },
29874            };
29875            let mut req_result = {
29876                let client = &self.hub.client;
29877                dlg.pre_request();
29878                let mut req_builder = hyper::Request::builder()
29879                    .method(hyper::Method::GET)
29880                    .uri(url.as_str())
29881                    .header(USER_AGENT, self.hub._user_agent.clone());
29882
29883                if let Some(token) = token.as_ref() {
29884                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29885                }
29886
29887                let request = req_builder
29888                    .header(CONTENT_LENGTH, 0_u64)
29889                    .body(common::to_body::<String>(None));
29890
29891                client.request(request.unwrap()).await
29892            };
29893
29894            match req_result {
29895                Err(err) => {
29896                    if let common::Retry::After(d) = dlg.http_error(&err) {
29897                        sleep(d).await;
29898                        continue;
29899                    }
29900                    dlg.finished(false);
29901                    return Err(common::Error::HttpError(err));
29902                }
29903                Ok(res) => {
29904                    let (mut parts, body) = res.into_parts();
29905                    let mut body = common::Body::new(body);
29906                    if !parts.status.is_success() {
29907                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29908                        let error = serde_json::from_str(&common::to_string(&bytes));
29909                        let response = common::to_response(parts, bytes.into());
29910
29911                        if let common::Retry::After(d) =
29912                            dlg.http_failure(&response, error.as_ref().ok())
29913                        {
29914                            sleep(d).await;
29915                            continue;
29916                        }
29917
29918                        dlg.finished(false);
29919
29920                        return Err(match error {
29921                            Ok(value) => common::Error::BadRequest(value),
29922                            _ => common::Error::Failure(response),
29923                        });
29924                    }
29925                    let response = {
29926                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29927                        let encoded = common::to_string(&bytes);
29928                        match serde_json::from_str(&encoded) {
29929                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29930                            Err(error) => {
29931                                dlg.response_json_decode_error(&encoded, &error);
29932                                return Err(common::Error::JsonDecodeError(
29933                                    encoded.to_string(),
29934                                    error,
29935                                ));
29936                            }
29937                        }
29938                    };
29939
29940                    dlg.finished(true);
29941                    return Ok(response);
29942                }
29943            }
29944        }
29945    }
29946
29947    /// User profile ID associated with this request.
29948    ///
29949    /// Sets the *profile id* path property to the given value.
29950    ///
29951    /// Even though the property as already been set when instantiating this call,
29952    /// we provide this method for API completeness.
29953    pub fn profile_id(mut self, new_value: i64) -> ChangeLogGetCall<'a, C> {
29954        self._profile_id = new_value;
29955        self
29956    }
29957    /// Change log ID.
29958    ///
29959    /// Sets the *id* path property to the given value.
29960    ///
29961    /// Even though the property as already been set when instantiating this call,
29962    /// we provide this method for API completeness.
29963    pub fn id(mut self, new_value: i64) -> ChangeLogGetCall<'a, C> {
29964        self._id = new_value;
29965        self
29966    }
29967    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29968    /// while executing the actual API request.
29969    ///
29970    /// ````text
29971    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29972    /// ````
29973    ///
29974    /// Sets the *delegate* property to the given value.
29975    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeLogGetCall<'a, C> {
29976        self._delegate = Some(new_value);
29977        self
29978    }
29979
29980    /// Set any additional parameter of the query string used in the request.
29981    /// It should be used to set parameters which are not yet available through their own
29982    /// setters.
29983    ///
29984    /// Please note that this method must not be used to set any of the known parameters
29985    /// which have their own setter method. If done anyway, the request will fail.
29986    ///
29987    /// # Additional Parameters
29988    ///
29989    /// * *alt* (query-string) - Data format for the response.
29990    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29991    /// * *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.
29992    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29993    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29994    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
29995    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
29996    pub fn param<T>(mut self, name: T, value: T) -> ChangeLogGetCall<'a, C>
29997    where
29998        T: AsRef<str>,
29999    {
30000        self._additional_params
30001            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30002        self
30003    }
30004
30005    /// Identifies the authorization scope for the method you are building.
30006    ///
30007    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30008    /// [`Scope::Dfatrafficking`].
30009    ///
30010    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30011    /// tokens for more than one scope.
30012    ///
30013    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30014    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30015    /// sufficient, a read-write scope will do as well.
30016    pub fn add_scope<St>(mut self, scope: St) -> ChangeLogGetCall<'a, C>
30017    where
30018        St: AsRef<str>,
30019    {
30020        self._scopes.insert(String::from(scope.as_ref()));
30021        self
30022    }
30023    /// Identifies the authorization scope(s) for the method you are building.
30024    ///
30025    /// See [`Self::add_scope()`] for details.
30026    pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeLogGetCall<'a, C>
30027    where
30028        I: IntoIterator<Item = St>,
30029        St: AsRef<str>,
30030    {
30031        self._scopes
30032            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30033        self
30034    }
30035
30036    /// Removes all scopes, and no default scope will be used either.
30037    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30038    /// for details).
30039    pub fn clear_scopes(mut self) -> ChangeLogGetCall<'a, C> {
30040        self._scopes.clear();
30041        self
30042    }
30043}
30044
30045/// Retrieves a list of change logs. This method supports paging.
30046///
30047/// A builder for the *list* method supported by a *changeLog* resource.
30048/// It is not used directly, but through a [`ChangeLogMethods`] instance.
30049///
30050/// # Example
30051///
30052/// Instantiate a resource method builder
30053///
30054/// ```test_harness,no_run
30055/// # extern crate hyper;
30056/// # extern crate hyper_rustls;
30057/// # extern crate google_dfareporting3d2 as dfareporting3d2;
30058/// # async fn dox() {
30059/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30060///
30061/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30062/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30063/// #     secret,
30064/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30065/// # ).build().await.unwrap();
30066///
30067/// # let client = hyper_util::client::legacy::Client::builder(
30068/// #     hyper_util::rt::TokioExecutor::new()
30069/// # )
30070/// # .build(
30071/// #     hyper_rustls::HttpsConnectorBuilder::new()
30072/// #         .with_native_roots()
30073/// #         .unwrap()
30074/// #         .https_or_http()
30075/// #         .enable_http1()
30076/// #         .build()
30077/// # );
30078/// # let mut hub = Dfareporting::new(client, auth);
30079/// // You can configure optional parameters by calling the respective setters at will, and
30080/// // execute the final call using `doit()`.
30081/// // Values shown here are possibly random and not representative !
30082/// let result = hub.change_logs().list(-41)
30083///              .add_user_profile_ids(-22)
30084///              .search_string("gubergren")
30085///              .page_token("justo")
30086///              .object_type("sea")
30087///              .add_object_ids(-96)
30088///              .min_change_time("sit")
30089///              .max_results(-32)
30090///              .max_change_time("eos")
30091///              .add_ids(-77)
30092///              .action("dolores")
30093///              .doit().await;
30094/// # }
30095/// ```
30096pub struct ChangeLogListCall<'a, C>
30097where
30098    C: 'a,
30099{
30100    hub: &'a Dfareporting<C>,
30101    _profile_id: i64,
30102    _user_profile_ids: Vec<i64>,
30103    _search_string: Option<String>,
30104    _page_token: Option<String>,
30105    _object_type: Option<String>,
30106    _object_ids: Vec<i64>,
30107    _min_change_time: Option<String>,
30108    _max_results: Option<i32>,
30109    _max_change_time: Option<String>,
30110    _ids: Vec<i64>,
30111    _action: Option<String>,
30112    _delegate: Option<&'a mut dyn common::Delegate>,
30113    _additional_params: HashMap<String, String>,
30114    _scopes: BTreeSet<String>,
30115}
30116
30117impl<'a, C> common::CallBuilder for ChangeLogListCall<'a, C> {}
30118
30119impl<'a, C> ChangeLogListCall<'a, C>
30120where
30121    C: common::Connector,
30122{
30123    /// Perform the operation you have build so far.
30124    pub async fn doit(mut self) -> common::Result<(common::Response, ChangeLogsListResponse)> {
30125        use std::borrow::Cow;
30126        use std::io::{Read, Seek};
30127
30128        use common::{url::Params, ToParts};
30129        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30130
30131        let mut dd = common::DefaultDelegate;
30132        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30133        dlg.begin(common::MethodInfo {
30134            id: "dfareporting.changeLogs.list",
30135            http_method: hyper::Method::GET,
30136        });
30137
30138        for &field in [
30139            "alt",
30140            "profileId",
30141            "userProfileIds",
30142            "searchString",
30143            "pageToken",
30144            "objectType",
30145            "objectIds",
30146            "minChangeTime",
30147            "maxResults",
30148            "maxChangeTime",
30149            "ids",
30150            "action",
30151        ]
30152        .iter()
30153        {
30154            if self._additional_params.contains_key(field) {
30155                dlg.finished(false);
30156                return Err(common::Error::FieldClash(field));
30157            }
30158        }
30159
30160        let mut params = Params::with_capacity(13 + self._additional_params.len());
30161        params.push("profileId", self._profile_id.to_string());
30162        if !self._user_profile_ids.is_empty() {
30163            for f in self._user_profile_ids.iter() {
30164                params.push("userProfileIds", f.to_string());
30165            }
30166        }
30167        if let Some(value) = self._search_string.as_ref() {
30168            params.push("searchString", value);
30169        }
30170        if let Some(value) = self._page_token.as_ref() {
30171            params.push("pageToken", value);
30172        }
30173        if let Some(value) = self._object_type.as_ref() {
30174            params.push("objectType", value);
30175        }
30176        if !self._object_ids.is_empty() {
30177            for f in self._object_ids.iter() {
30178                params.push("objectIds", f.to_string());
30179            }
30180        }
30181        if let Some(value) = self._min_change_time.as_ref() {
30182            params.push("minChangeTime", value);
30183        }
30184        if let Some(value) = self._max_results.as_ref() {
30185            params.push("maxResults", value.to_string());
30186        }
30187        if let Some(value) = self._max_change_time.as_ref() {
30188            params.push("maxChangeTime", value);
30189        }
30190        if !self._ids.is_empty() {
30191            for f in self._ids.iter() {
30192                params.push("ids", f.to_string());
30193            }
30194        }
30195        if let Some(value) = self._action.as_ref() {
30196            params.push("action", value);
30197        }
30198
30199        params.extend(self._additional_params.iter());
30200
30201        params.push("alt", "json");
30202        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/changeLogs";
30203        if self._scopes.is_empty() {
30204            self._scopes
30205                .insert(Scope::Dfatrafficking.as_ref().to_string());
30206        }
30207
30208        #[allow(clippy::single_element_loop)]
30209        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
30210            url = params.uri_replacement(url, param_name, find_this, false);
30211        }
30212        {
30213            let to_remove = ["profileId"];
30214            params.remove_params(&to_remove);
30215        }
30216
30217        let url = params.parse_with_url(&url);
30218
30219        loop {
30220            let token = match self
30221                .hub
30222                .auth
30223                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30224                .await
30225            {
30226                Ok(token) => token,
30227                Err(e) => match dlg.token(e) {
30228                    Ok(token) => token,
30229                    Err(e) => {
30230                        dlg.finished(false);
30231                        return Err(common::Error::MissingToken(e));
30232                    }
30233                },
30234            };
30235            let mut req_result = {
30236                let client = &self.hub.client;
30237                dlg.pre_request();
30238                let mut req_builder = hyper::Request::builder()
30239                    .method(hyper::Method::GET)
30240                    .uri(url.as_str())
30241                    .header(USER_AGENT, self.hub._user_agent.clone());
30242
30243                if let Some(token) = token.as_ref() {
30244                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30245                }
30246
30247                let request = req_builder
30248                    .header(CONTENT_LENGTH, 0_u64)
30249                    .body(common::to_body::<String>(None));
30250
30251                client.request(request.unwrap()).await
30252            };
30253
30254            match req_result {
30255                Err(err) => {
30256                    if let common::Retry::After(d) = dlg.http_error(&err) {
30257                        sleep(d).await;
30258                        continue;
30259                    }
30260                    dlg.finished(false);
30261                    return Err(common::Error::HttpError(err));
30262                }
30263                Ok(res) => {
30264                    let (mut parts, body) = res.into_parts();
30265                    let mut body = common::Body::new(body);
30266                    if !parts.status.is_success() {
30267                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30268                        let error = serde_json::from_str(&common::to_string(&bytes));
30269                        let response = common::to_response(parts, bytes.into());
30270
30271                        if let common::Retry::After(d) =
30272                            dlg.http_failure(&response, error.as_ref().ok())
30273                        {
30274                            sleep(d).await;
30275                            continue;
30276                        }
30277
30278                        dlg.finished(false);
30279
30280                        return Err(match error {
30281                            Ok(value) => common::Error::BadRequest(value),
30282                            _ => common::Error::Failure(response),
30283                        });
30284                    }
30285                    let response = {
30286                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30287                        let encoded = common::to_string(&bytes);
30288                        match serde_json::from_str(&encoded) {
30289                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30290                            Err(error) => {
30291                                dlg.response_json_decode_error(&encoded, &error);
30292                                return Err(common::Error::JsonDecodeError(
30293                                    encoded.to_string(),
30294                                    error,
30295                                ));
30296                            }
30297                        }
30298                    };
30299
30300                    dlg.finished(true);
30301                    return Ok(response);
30302                }
30303            }
30304        }
30305    }
30306
30307    /// User profile ID associated with this request.
30308    ///
30309    /// Sets the *profile id* path property to the given value.
30310    ///
30311    /// Even though the property as already been set when instantiating this call,
30312    /// we provide this method for API completeness.
30313    pub fn profile_id(mut self, new_value: i64) -> ChangeLogListCall<'a, C> {
30314        self._profile_id = new_value;
30315        self
30316    }
30317    /// Select only change logs with these user profile IDs.
30318    ///
30319    /// Append the given value to the *user profile ids* query property.
30320    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30321    pub fn add_user_profile_ids(mut self, new_value: i64) -> ChangeLogListCall<'a, C> {
30322        self._user_profile_ids.push(new_value);
30323        self
30324    }
30325    /// Select only change logs whose object ID, user name, old or new values match the search string.
30326    ///
30327    /// Sets the *search string* query property to the given value.
30328    pub fn search_string(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30329        self._search_string = Some(new_value.to_string());
30330        self
30331    }
30332    /// Value of the nextPageToken from the previous result page.
30333    ///
30334    /// Sets the *page token* query property to the given value.
30335    pub fn page_token(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30336        self._page_token = Some(new_value.to_string());
30337        self
30338    }
30339    /// Select only change logs with the specified object type.
30340    ///
30341    /// Sets the *object type* query property to the given value.
30342    pub fn object_type(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30343        self._object_type = Some(new_value.to_string());
30344        self
30345    }
30346    /// Select only change logs with these object IDs.
30347    ///
30348    /// Append the given value to the *object ids* query property.
30349    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30350    pub fn add_object_ids(mut self, new_value: i64) -> ChangeLogListCall<'a, C> {
30351        self._object_ids.push(new_value);
30352        self
30353    }
30354    /// Select only change logs whose change time is before the specified minChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset.
30355    ///
30356    /// Sets the *min change time* query property to the given value.
30357    pub fn min_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30358        self._min_change_time = Some(new_value.to_string());
30359        self
30360    }
30361    /// Maximum number of results to return.
30362    ///
30363    /// Sets the *max results* query property to the given value.
30364    pub fn max_results(mut self, new_value: i32) -> ChangeLogListCall<'a, C> {
30365        self._max_results = Some(new_value);
30366        self
30367    }
30368    /// Select only change logs whose change time is before the specified maxChangeTime.The time should be formatted as an RFC3339 date/time string. For example, for 10:54 PM on July 18th, 2015, in the America/New York time zone, the format is "2015-07-18T22:54:00-04:00". In other words, the year, month, day, the letter T, the hour (24-hour clock system), minute, second, and then the time zone offset.
30369    ///
30370    /// Sets the *max change time* query property to the given value.
30371    pub fn max_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30372        self._max_change_time = Some(new_value.to_string());
30373        self
30374    }
30375    /// Select only change logs with these IDs.
30376    ///
30377    /// Append the given value to the *ids* query property.
30378    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30379    pub fn add_ids(mut self, new_value: i64) -> ChangeLogListCall<'a, C> {
30380        self._ids.push(new_value);
30381        self
30382    }
30383    /// Select only change logs with the specified action.
30384    ///
30385    /// Sets the *action* query property to the given value.
30386    pub fn action(mut self, new_value: &str) -> ChangeLogListCall<'a, C> {
30387        self._action = Some(new_value.to_string());
30388        self
30389    }
30390    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30391    /// while executing the actual API request.
30392    ///
30393    /// ````text
30394    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30395    /// ````
30396    ///
30397    /// Sets the *delegate* property to the given value.
30398    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChangeLogListCall<'a, C> {
30399        self._delegate = Some(new_value);
30400        self
30401    }
30402
30403    /// Set any additional parameter of the query string used in the request.
30404    /// It should be used to set parameters which are not yet available through their own
30405    /// setters.
30406    ///
30407    /// Please note that this method must not be used to set any of the known parameters
30408    /// which have their own setter method. If done anyway, the request will fail.
30409    ///
30410    /// # Additional Parameters
30411    ///
30412    /// * *alt* (query-string) - Data format for the response.
30413    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30414    /// * *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.
30415    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30416    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30417    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30418    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30419    pub fn param<T>(mut self, name: T, value: T) -> ChangeLogListCall<'a, C>
30420    where
30421        T: AsRef<str>,
30422    {
30423        self._additional_params
30424            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30425        self
30426    }
30427
30428    /// Identifies the authorization scope for the method you are building.
30429    ///
30430    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30431    /// [`Scope::Dfatrafficking`].
30432    ///
30433    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30434    /// tokens for more than one scope.
30435    ///
30436    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30437    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30438    /// sufficient, a read-write scope will do as well.
30439    pub fn add_scope<St>(mut self, scope: St) -> ChangeLogListCall<'a, C>
30440    where
30441        St: AsRef<str>,
30442    {
30443        self._scopes.insert(String::from(scope.as_ref()));
30444        self
30445    }
30446    /// Identifies the authorization scope(s) for the method you are building.
30447    ///
30448    /// See [`Self::add_scope()`] for details.
30449    pub fn add_scopes<I, St>(mut self, scopes: I) -> ChangeLogListCall<'a, C>
30450    where
30451        I: IntoIterator<Item = St>,
30452        St: AsRef<str>,
30453    {
30454        self._scopes
30455            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30456        self
30457    }
30458
30459    /// Removes all scopes, and no default scope will be used either.
30460    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30461    /// for details).
30462    pub fn clear_scopes(mut self) -> ChangeLogListCall<'a, C> {
30463        self._scopes.clear();
30464        self
30465    }
30466}
30467
30468/// Retrieves a list of cities, possibly filtered.
30469///
30470/// A builder for the *list* method supported by a *city* resource.
30471/// It is not used directly, but through a [`CityMethods`] instance.
30472///
30473/// # Example
30474///
30475/// Instantiate a resource method builder
30476///
30477/// ```test_harness,no_run
30478/// # extern crate hyper;
30479/// # extern crate hyper_rustls;
30480/// # extern crate google_dfareporting3d2 as dfareporting3d2;
30481/// # async fn dox() {
30482/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30483///
30484/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30485/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30486/// #     secret,
30487/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30488/// # ).build().await.unwrap();
30489///
30490/// # let client = hyper_util::client::legacy::Client::builder(
30491/// #     hyper_util::rt::TokioExecutor::new()
30492/// # )
30493/// # .build(
30494/// #     hyper_rustls::HttpsConnectorBuilder::new()
30495/// #         .with_native_roots()
30496/// #         .unwrap()
30497/// #         .https_or_http()
30498/// #         .enable_http1()
30499/// #         .build()
30500/// # );
30501/// # let mut hub = Dfareporting::new(client, auth);
30502/// // You can configure optional parameters by calling the respective setters at will, and
30503/// // execute the final call using `doit()`.
30504/// // Values shown here are possibly random and not representative !
30505/// let result = hub.cities().list(-46)
30506///              .add_region_dart_ids(-62)
30507///              .name_prefix("dolor")
30508///              .add_dart_ids(-32)
30509///              .add_country_dart_ids(-61)
30510///              .doit().await;
30511/// # }
30512/// ```
30513pub struct CityListCall<'a, C>
30514where
30515    C: 'a,
30516{
30517    hub: &'a Dfareporting<C>,
30518    _profile_id: i64,
30519    _region_dart_ids: Vec<i64>,
30520    _name_prefix: Option<String>,
30521    _dart_ids: Vec<i64>,
30522    _country_dart_ids: Vec<i64>,
30523    _delegate: Option<&'a mut dyn common::Delegate>,
30524    _additional_params: HashMap<String, String>,
30525    _scopes: BTreeSet<String>,
30526}
30527
30528impl<'a, C> common::CallBuilder for CityListCall<'a, C> {}
30529
30530impl<'a, C> CityListCall<'a, C>
30531where
30532    C: common::Connector,
30533{
30534    /// Perform the operation you have build so far.
30535    pub async fn doit(mut self) -> common::Result<(common::Response, CitiesListResponse)> {
30536        use std::borrow::Cow;
30537        use std::io::{Read, Seek};
30538
30539        use common::{url::Params, ToParts};
30540        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30541
30542        let mut dd = common::DefaultDelegate;
30543        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30544        dlg.begin(common::MethodInfo {
30545            id: "dfareporting.cities.list",
30546            http_method: hyper::Method::GET,
30547        });
30548
30549        for &field in [
30550            "alt",
30551            "profileId",
30552            "regionDartIds",
30553            "namePrefix",
30554            "dartIds",
30555            "countryDartIds",
30556        ]
30557        .iter()
30558        {
30559            if self._additional_params.contains_key(field) {
30560                dlg.finished(false);
30561                return Err(common::Error::FieldClash(field));
30562            }
30563        }
30564
30565        let mut params = Params::with_capacity(7 + self._additional_params.len());
30566        params.push("profileId", self._profile_id.to_string());
30567        if !self._region_dart_ids.is_empty() {
30568            for f in self._region_dart_ids.iter() {
30569                params.push("regionDartIds", f.to_string());
30570            }
30571        }
30572        if let Some(value) = self._name_prefix.as_ref() {
30573            params.push("namePrefix", value);
30574        }
30575        if !self._dart_ids.is_empty() {
30576            for f in self._dart_ids.iter() {
30577                params.push("dartIds", f.to_string());
30578            }
30579        }
30580        if !self._country_dart_ids.is_empty() {
30581            for f in self._country_dart_ids.iter() {
30582                params.push("countryDartIds", f.to_string());
30583            }
30584        }
30585
30586        params.extend(self._additional_params.iter());
30587
30588        params.push("alt", "json");
30589        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/cities";
30590        if self._scopes.is_empty() {
30591            self._scopes
30592                .insert(Scope::Dfatrafficking.as_ref().to_string());
30593        }
30594
30595        #[allow(clippy::single_element_loop)]
30596        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
30597            url = params.uri_replacement(url, param_name, find_this, false);
30598        }
30599        {
30600            let to_remove = ["profileId"];
30601            params.remove_params(&to_remove);
30602        }
30603
30604        let url = params.parse_with_url(&url);
30605
30606        loop {
30607            let token = match self
30608                .hub
30609                .auth
30610                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30611                .await
30612            {
30613                Ok(token) => token,
30614                Err(e) => match dlg.token(e) {
30615                    Ok(token) => token,
30616                    Err(e) => {
30617                        dlg.finished(false);
30618                        return Err(common::Error::MissingToken(e));
30619                    }
30620                },
30621            };
30622            let mut req_result = {
30623                let client = &self.hub.client;
30624                dlg.pre_request();
30625                let mut req_builder = hyper::Request::builder()
30626                    .method(hyper::Method::GET)
30627                    .uri(url.as_str())
30628                    .header(USER_AGENT, self.hub._user_agent.clone());
30629
30630                if let Some(token) = token.as_ref() {
30631                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30632                }
30633
30634                let request = req_builder
30635                    .header(CONTENT_LENGTH, 0_u64)
30636                    .body(common::to_body::<String>(None));
30637
30638                client.request(request.unwrap()).await
30639            };
30640
30641            match req_result {
30642                Err(err) => {
30643                    if let common::Retry::After(d) = dlg.http_error(&err) {
30644                        sleep(d).await;
30645                        continue;
30646                    }
30647                    dlg.finished(false);
30648                    return Err(common::Error::HttpError(err));
30649                }
30650                Ok(res) => {
30651                    let (mut parts, body) = res.into_parts();
30652                    let mut body = common::Body::new(body);
30653                    if !parts.status.is_success() {
30654                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30655                        let error = serde_json::from_str(&common::to_string(&bytes));
30656                        let response = common::to_response(parts, bytes.into());
30657
30658                        if let common::Retry::After(d) =
30659                            dlg.http_failure(&response, error.as_ref().ok())
30660                        {
30661                            sleep(d).await;
30662                            continue;
30663                        }
30664
30665                        dlg.finished(false);
30666
30667                        return Err(match error {
30668                            Ok(value) => common::Error::BadRequest(value),
30669                            _ => common::Error::Failure(response),
30670                        });
30671                    }
30672                    let response = {
30673                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30674                        let encoded = common::to_string(&bytes);
30675                        match serde_json::from_str(&encoded) {
30676                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30677                            Err(error) => {
30678                                dlg.response_json_decode_error(&encoded, &error);
30679                                return Err(common::Error::JsonDecodeError(
30680                                    encoded.to_string(),
30681                                    error,
30682                                ));
30683                            }
30684                        }
30685                    };
30686
30687                    dlg.finished(true);
30688                    return Ok(response);
30689                }
30690            }
30691        }
30692    }
30693
30694    /// User profile ID associated with this request.
30695    ///
30696    /// Sets the *profile id* path property to the given value.
30697    ///
30698    /// Even though the property as already been set when instantiating this call,
30699    /// we provide this method for API completeness.
30700    pub fn profile_id(mut self, new_value: i64) -> CityListCall<'a, C> {
30701        self._profile_id = new_value;
30702        self
30703    }
30704    /// Select only cities from these regions.
30705    ///
30706    /// Append the given value to the *region dart ids* query property.
30707    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30708    pub fn add_region_dart_ids(mut self, new_value: i64) -> CityListCall<'a, C> {
30709        self._region_dart_ids.push(new_value);
30710        self
30711    }
30712    /// Select only cities with names starting with this prefix.
30713    ///
30714    /// Sets the *name prefix* query property to the given value.
30715    pub fn name_prefix(mut self, new_value: &str) -> CityListCall<'a, C> {
30716        self._name_prefix = Some(new_value.to_string());
30717        self
30718    }
30719    /// Select only cities with these DART IDs.
30720    ///
30721    /// Append the given value to the *dart ids* query property.
30722    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30723    pub fn add_dart_ids(mut self, new_value: i64) -> CityListCall<'a, C> {
30724        self._dart_ids.push(new_value);
30725        self
30726    }
30727    /// Select only cities from these countries.
30728    ///
30729    /// Append the given value to the *country dart ids* query property.
30730    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
30731    pub fn add_country_dart_ids(mut self, new_value: i64) -> CityListCall<'a, C> {
30732        self._country_dart_ids.push(new_value);
30733        self
30734    }
30735    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30736    /// while executing the actual API request.
30737    ///
30738    /// ````text
30739    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
30740    /// ````
30741    ///
30742    /// Sets the *delegate* property to the given value.
30743    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CityListCall<'a, C> {
30744        self._delegate = Some(new_value);
30745        self
30746    }
30747
30748    /// Set any additional parameter of the query string used in the request.
30749    /// It should be used to set parameters which are not yet available through their own
30750    /// setters.
30751    ///
30752    /// Please note that this method must not be used to set any of the known parameters
30753    /// which have their own setter method. If done anyway, the request will fail.
30754    ///
30755    /// # Additional Parameters
30756    ///
30757    /// * *alt* (query-string) - Data format for the response.
30758    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30759    /// * *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.
30760    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30761    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30762    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
30763    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
30764    pub fn param<T>(mut self, name: T, value: T) -> CityListCall<'a, C>
30765    where
30766        T: AsRef<str>,
30767    {
30768        self._additional_params
30769            .insert(name.as_ref().to_string(), value.as_ref().to_string());
30770        self
30771    }
30772
30773    /// Identifies the authorization scope for the method you are building.
30774    ///
30775    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30776    /// [`Scope::Dfatrafficking`].
30777    ///
30778    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30779    /// tokens for more than one scope.
30780    ///
30781    /// Usually there is more than one suitable scope to authorize an operation, some of which may
30782    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30783    /// sufficient, a read-write scope will do as well.
30784    pub fn add_scope<St>(mut self, scope: St) -> CityListCall<'a, C>
30785    where
30786        St: AsRef<str>,
30787    {
30788        self._scopes.insert(String::from(scope.as_ref()));
30789        self
30790    }
30791    /// Identifies the authorization scope(s) for the method you are building.
30792    ///
30793    /// See [`Self::add_scope()`] for details.
30794    pub fn add_scopes<I, St>(mut self, scopes: I) -> CityListCall<'a, C>
30795    where
30796        I: IntoIterator<Item = St>,
30797        St: AsRef<str>,
30798    {
30799        self._scopes
30800            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30801        self
30802    }
30803
30804    /// Removes all scopes, and no default scope will be used either.
30805    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30806    /// for details).
30807    pub fn clear_scopes(mut self) -> CityListCall<'a, C> {
30808        self._scopes.clear();
30809        self
30810    }
30811}
30812
30813/// Gets one connection type by ID.
30814///
30815/// A builder for the *get* method supported by a *connectionType* resource.
30816/// It is not used directly, but through a [`ConnectionTypeMethods`] instance.
30817///
30818/// # Example
30819///
30820/// Instantiate a resource method builder
30821///
30822/// ```test_harness,no_run
30823/// # extern crate hyper;
30824/// # extern crate hyper_rustls;
30825/// # extern crate google_dfareporting3d2 as dfareporting3d2;
30826/// # async fn dox() {
30827/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30828///
30829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
30831/// #     secret,
30832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30833/// # ).build().await.unwrap();
30834///
30835/// # let client = hyper_util::client::legacy::Client::builder(
30836/// #     hyper_util::rt::TokioExecutor::new()
30837/// # )
30838/// # .build(
30839/// #     hyper_rustls::HttpsConnectorBuilder::new()
30840/// #         .with_native_roots()
30841/// #         .unwrap()
30842/// #         .https_or_http()
30843/// #         .enable_http1()
30844/// #         .build()
30845/// # );
30846/// # let mut hub = Dfareporting::new(client, auth);
30847/// // You can configure optional parameters by calling the respective setters at will, and
30848/// // execute the final call using `doit()`.
30849/// // Values shown here are possibly random and not representative !
30850/// let result = hub.connection_types().get(-2, -50)
30851///              .doit().await;
30852/// # }
30853/// ```
30854pub struct ConnectionTypeGetCall<'a, C>
30855where
30856    C: 'a,
30857{
30858    hub: &'a Dfareporting<C>,
30859    _profile_id: i64,
30860    _id: i64,
30861    _delegate: Option<&'a mut dyn common::Delegate>,
30862    _additional_params: HashMap<String, String>,
30863    _scopes: BTreeSet<String>,
30864}
30865
30866impl<'a, C> common::CallBuilder for ConnectionTypeGetCall<'a, C> {}
30867
30868impl<'a, C> ConnectionTypeGetCall<'a, C>
30869where
30870    C: common::Connector,
30871{
30872    /// Perform the operation you have build so far.
30873    pub async fn doit(mut self) -> common::Result<(common::Response, ConnectionType)> {
30874        use std::borrow::Cow;
30875        use std::io::{Read, Seek};
30876
30877        use common::{url::Params, ToParts};
30878        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30879
30880        let mut dd = common::DefaultDelegate;
30881        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30882        dlg.begin(common::MethodInfo {
30883            id: "dfareporting.connectionTypes.get",
30884            http_method: hyper::Method::GET,
30885        });
30886
30887        for &field in ["alt", "profileId", "id"].iter() {
30888            if self._additional_params.contains_key(field) {
30889                dlg.finished(false);
30890                return Err(common::Error::FieldClash(field));
30891            }
30892        }
30893
30894        let mut params = Params::with_capacity(4 + self._additional_params.len());
30895        params.push("profileId", self._profile_id.to_string());
30896        params.push("id", self._id.to_string());
30897
30898        params.extend(self._additional_params.iter());
30899
30900        params.push("alt", "json");
30901        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/connectionTypes/{id}";
30902        if self._scopes.is_empty() {
30903            self._scopes
30904                .insert(Scope::Dfatrafficking.as_ref().to_string());
30905        }
30906
30907        #[allow(clippy::single_element_loop)]
30908        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
30909            url = params.uri_replacement(url, param_name, find_this, false);
30910        }
30911        {
30912            let to_remove = ["id", "profileId"];
30913            params.remove_params(&to_remove);
30914        }
30915
30916        let url = params.parse_with_url(&url);
30917
30918        loop {
30919            let token = match self
30920                .hub
30921                .auth
30922                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30923                .await
30924            {
30925                Ok(token) => token,
30926                Err(e) => match dlg.token(e) {
30927                    Ok(token) => token,
30928                    Err(e) => {
30929                        dlg.finished(false);
30930                        return Err(common::Error::MissingToken(e));
30931                    }
30932                },
30933            };
30934            let mut req_result = {
30935                let client = &self.hub.client;
30936                dlg.pre_request();
30937                let mut req_builder = hyper::Request::builder()
30938                    .method(hyper::Method::GET)
30939                    .uri(url.as_str())
30940                    .header(USER_AGENT, self.hub._user_agent.clone());
30941
30942                if let Some(token) = token.as_ref() {
30943                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30944                }
30945
30946                let request = req_builder
30947                    .header(CONTENT_LENGTH, 0_u64)
30948                    .body(common::to_body::<String>(None));
30949
30950                client.request(request.unwrap()).await
30951            };
30952
30953            match req_result {
30954                Err(err) => {
30955                    if let common::Retry::After(d) = dlg.http_error(&err) {
30956                        sleep(d).await;
30957                        continue;
30958                    }
30959                    dlg.finished(false);
30960                    return Err(common::Error::HttpError(err));
30961                }
30962                Ok(res) => {
30963                    let (mut parts, body) = res.into_parts();
30964                    let mut body = common::Body::new(body);
30965                    if !parts.status.is_success() {
30966                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30967                        let error = serde_json::from_str(&common::to_string(&bytes));
30968                        let response = common::to_response(parts, bytes.into());
30969
30970                        if let common::Retry::After(d) =
30971                            dlg.http_failure(&response, error.as_ref().ok())
30972                        {
30973                            sleep(d).await;
30974                            continue;
30975                        }
30976
30977                        dlg.finished(false);
30978
30979                        return Err(match error {
30980                            Ok(value) => common::Error::BadRequest(value),
30981                            _ => common::Error::Failure(response),
30982                        });
30983                    }
30984                    let response = {
30985                        let bytes = common::to_bytes(body).await.unwrap_or_default();
30986                        let encoded = common::to_string(&bytes);
30987                        match serde_json::from_str(&encoded) {
30988                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30989                            Err(error) => {
30990                                dlg.response_json_decode_error(&encoded, &error);
30991                                return Err(common::Error::JsonDecodeError(
30992                                    encoded.to_string(),
30993                                    error,
30994                                ));
30995                            }
30996                        }
30997                    };
30998
30999                    dlg.finished(true);
31000                    return Ok(response);
31001                }
31002            }
31003        }
31004    }
31005
31006    /// User profile ID associated with this request.
31007    ///
31008    /// Sets the *profile id* path property to the given value.
31009    ///
31010    /// Even though the property as already been set when instantiating this call,
31011    /// we provide this method for API completeness.
31012    pub fn profile_id(mut self, new_value: i64) -> ConnectionTypeGetCall<'a, C> {
31013        self._profile_id = new_value;
31014        self
31015    }
31016    /// Connection type ID.
31017    ///
31018    /// Sets the *id* path property to the given value.
31019    ///
31020    /// Even though the property as already been set when instantiating this call,
31021    /// we provide this method for API completeness.
31022    pub fn id(mut self, new_value: i64) -> ConnectionTypeGetCall<'a, C> {
31023        self._id = new_value;
31024        self
31025    }
31026    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31027    /// while executing the actual API request.
31028    ///
31029    /// ````text
31030    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31031    /// ````
31032    ///
31033    /// Sets the *delegate* property to the given value.
31034    pub fn delegate(
31035        mut self,
31036        new_value: &'a mut dyn common::Delegate,
31037    ) -> ConnectionTypeGetCall<'a, C> {
31038        self._delegate = Some(new_value);
31039        self
31040    }
31041
31042    /// Set any additional parameter of the query string used in the request.
31043    /// It should be used to set parameters which are not yet available through their own
31044    /// setters.
31045    ///
31046    /// Please note that this method must not be used to set any of the known parameters
31047    /// which have their own setter method. If done anyway, the request will fail.
31048    ///
31049    /// # Additional Parameters
31050    ///
31051    /// * *alt* (query-string) - Data format for the response.
31052    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31053    /// * *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.
31054    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31055    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31056    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31057    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31058    pub fn param<T>(mut self, name: T, value: T) -> ConnectionTypeGetCall<'a, C>
31059    where
31060        T: AsRef<str>,
31061    {
31062        self._additional_params
31063            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31064        self
31065    }
31066
31067    /// Identifies the authorization scope for the method you are building.
31068    ///
31069    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31070    /// [`Scope::Dfatrafficking`].
31071    ///
31072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31073    /// tokens for more than one scope.
31074    ///
31075    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31076    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31077    /// sufficient, a read-write scope will do as well.
31078    pub fn add_scope<St>(mut self, scope: St) -> ConnectionTypeGetCall<'a, C>
31079    where
31080        St: AsRef<str>,
31081    {
31082        self._scopes.insert(String::from(scope.as_ref()));
31083        self
31084    }
31085    /// Identifies the authorization scope(s) for the method you are building.
31086    ///
31087    /// See [`Self::add_scope()`] for details.
31088    pub fn add_scopes<I, St>(mut self, scopes: I) -> ConnectionTypeGetCall<'a, C>
31089    where
31090        I: IntoIterator<Item = St>,
31091        St: AsRef<str>,
31092    {
31093        self._scopes
31094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31095        self
31096    }
31097
31098    /// Removes all scopes, and no default scope will be used either.
31099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31100    /// for details).
31101    pub fn clear_scopes(mut self) -> ConnectionTypeGetCall<'a, C> {
31102        self._scopes.clear();
31103        self
31104    }
31105}
31106
31107/// Retrieves a list of connection types.
31108///
31109/// A builder for the *list* method supported by a *connectionType* resource.
31110/// It is not used directly, but through a [`ConnectionTypeMethods`] instance.
31111///
31112/// # Example
31113///
31114/// Instantiate a resource method builder
31115///
31116/// ```test_harness,no_run
31117/// # extern crate hyper;
31118/// # extern crate hyper_rustls;
31119/// # extern crate google_dfareporting3d2 as dfareporting3d2;
31120/// # async fn dox() {
31121/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31122///
31123/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31125/// #     secret,
31126/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31127/// # ).build().await.unwrap();
31128///
31129/// # let client = hyper_util::client::legacy::Client::builder(
31130/// #     hyper_util::rt::TokioExecutor::new()
31131/// # )
31132/// # .build(
31133/// #     hyper_rustls::HttpsConnectorBuilder::new()
31134/// #         .with_native_roots()
31135/// #         .unwrap()
31136/// #         .https_or_http()
31137/// #         .enable_http1()
31138/// #         .build()
31139/// # );
31140/// # let mut hub = Dfareporting::new(client, auth);
31141/// // You can configure optional parameters by calling the respective setters at will, and
31142/// // execute the final call using `doit()`.
31143/// // Values shown here are possibly random and not representative !
31144/// let result = hub.connection_types().list(-56)
31145///              .doit().await;
31146/// # }
31147/// ```
31148pub struct ConnectionTypeListCall<'a, C>
31149where
31150    C: 'a,
31151{
31152    hub: &'a Dfareporting<C>,
31153    _profile_id: i64,
31154    _delegate: Option<&'a mut dyn common::Delegate>,
31155    _additional_params: HashMap<String, String>,
31156    _scopes: BTreeSet<String>,
31157}
31158
31159impl<'a, C> common::CallBuilder for ConnectionTypeListCall<'a, C> {}
31160
31161impl<'a, C> ConnectionTypeListCall<'a, C>
31162where
31163    C: common::Connector,
31164{
31165    /// Perform the operation you have build so far.
31166    pub async fn doit(mut self) -> common::Result<(common::Response, ConnectionTypesListResponse)> {
31167        use std::borrow::Cow;
31168        use std::io::{Read, Seek};
31169
31170        use common::{url::Params, ToParts};
31171        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31172
31173        let mut dd = common::DefaultDelegate;
31174        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31175        dlg.begin(common::MethodInfo {
31176            id: "dfareporting.connectionTypes.list",
31177            http_method: hyper::Method::GET,
31178        });
31179
31180        for &field in ["alt", "profileId"].iter() {
31181            if self._additional_params.contains_key(field) {
31182                dlg.finished(false);
31183                return Err(common::Error::FieldClash(field));
31184            }
31185        }
31186
31187        let mut params = Params::with_capacity(3 + self._additional_params.len());
31188        params.push("profileId", self._profile_id.to_string());
31189
31190        params.extend(self._additional_params.iter());
31191
31192        params.push("alt", "json");
31193        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/connectionTypes";
31194        if self._scopes.is_empty() {
31195            self._scopes
31196                .insert(Scope::Dfatrafficking.as_ref().to_string());
31197        }
31198
31199        #[allow(clippy::single_element_loop)]
31200        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
31201            url = params.uri_replacement(url, param_name, find_this, false);
31202        }
31203        {
31204            let to_remove = ["profileId"];
31205            params.remove_params(&to_remove);
31206        }
31207
31208        let url = params.parse_with_url(&url);
31209
31210        loop {
31211            let token = match self
31212                .hub
31213                .auth
31214                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31215                .await
31216            {
31217                Ok(token) => token,
31218                Err(e) => match dlg.token(e) {
31219                    Ok(token) => token,
31220                    Err(e) => {
31221                        dlg.finished(false);
31222                        return Err(common::Error::MissingToken(e));
31223                    }
31224                },
31225            };
31226            let mut req_result = {
31227                let client = &self.hub.client;
31228                dlg.pre_request();
31229                let mut req_builder = hyper::Request::builder()
31230                    .method(hyper::Method::GET)
31231                    .uri(url.as_str())
31232                    .header(USER_AGENT, self.hub._user_agent.clone());
31233
31234                if let Some(token) = token.as_ref() {
31235                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31236                }
31237
31238                let request = req_builder
31239                    .header(CONTENT_LENGTH, 0_u64)
31240                    .body(common::to_body::<String>(None));
31241
31242                client.request(request.unwrap()).await
31243            };
31244
31245            match req_result {
31246                Err(err) => {
31247                    if let common::Retry::After(d) = dlg.http_error(&err) {
31248                        sleep(d).await;
31249                        continue;
31250                    }
31251                    dlg.finished(false);
31252                    return Err(common::Error::HttpError(err));
31253                }
31254                Ok(res) => {
31255                    let (mut parts, body) = res.into_parts();
31256                    let mut body = common::Body::new(body);
31257                    if !parts.status.is_success() {
31258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31259                        let error = serde_json::from_str(&common::to_string(&bytes));
31260                        let response = common::to_response(parts, bytes.into());
31261
31262                        if let common::Retry::After(d) =
31263                            dlg.http_failure(&response, error.as_ref().ok())
31264                        {
31265                            sleep(d).await;
31266                            continue;
31267                        }
31268
31269                        dlg.finished(false);
31270
31271                        return Err(match error {
31272                            Ok(value) => common::Error::BadRequest(value),
31273                            _ => common::Error::Failure(response),
31274                        });
31275                    }
31276                    let response = {
31277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31278                        let encoded = common::to_string(&bytes);
31279                        match serde_json::from_str(&encoded) {
31280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31281                            Err(error) => {
31282                                dlg.response_json_decode_error(&encoded, &error);
31283                                return Err(common::Error::JsonDecodeError(
31284                                    encoded.to_string(),
31285                                    error,
31286                                ));
31287                            }
31288                        }
31289                    };
31290
31291                    dlg.finished(true);
31292                    return Ok(response);
31293                }
31294            }
31295        }
31296    }
31297
31298    /// User profile ID associated with this request.
31299    ///
31300    /// Sets the *profile id* path property to the given value.
31301    ///
31302    /// Even though the property as already been set when instantiating this call,
31303    /// we provide this method for API completeness.
31304    pub fn profile_id(mut self, new_value: i64) -> ConnectionTypeListCall<'a, C> {
31305        self._profile_id = new_value;
31306        self
31307    }
31308    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31309    /// while executing the actual API request.
31310    ///
31311    /// ````text
31312    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31313    /// ````
31314    ///
31315    /// Sets the *delegate* property to the given value.
31316    pub fn delegate(
31317        mut self,
31318        new_value: &'a mut dyn common::Delegate,
31319    ) -> ConnectionTypeListCall<'a, C> {
31320        self._delegate = Some(new_value);
31321        self
31322    }
31323
31324    /// Set any additional parameter of the query string used in the request.
31325    /// It should be used to set parameters which are not yet available through their own
31326    /// setters.
31327    ///
31328    /// Please note that this method must not be used to set any of the known parameters
31329    /// which have their own setter method. If done anyway, the request will fail.
31330    ///
31331    /// # Additional Parameters
31332    ///
31333    /// * *alt* (query-string) - Data format for the response.
31334    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31335    /// * *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.
31336    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31337    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31338    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31339    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31340    pub fn param<T>(mut self, name: T, value: T) -> ConnectionTypeListCall<'a, C>
31341    where
31342        T: AsRef<str>,
31343    {
31344        self._additional_params
31345            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31346        self
31347    }
31348
31349    /// Identifies the authorization scope for the method you are building.
31350    ///
31351    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31352    /// [`Scope::Dfatrafficking`].
31353    ///
31354    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31355    /// tokens for more than one scope.
31356    ///
31357    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31358    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31359    /// sufficient, a read-write scope will do as well.
31360    pub fn add_scope<St>(mut self, scope: St) -> ConnectionTypeListCall<'a, C>
31361    where
31362        St: AsRef<str>,
31363    {
31364        self._scopes.insert(String::from(scope.as_ref()));
31365        self
31366    }
31367    /// Identifies the authorization scope(s) for the method you are building.
31368    ///
31369    /// See [`Self::add_scope()`] for details.
31370    pub fn add_scopes<I, St>(mut self, scopes: I) -> ConnectionTypeListCall<'a, C>
31371    where
31372        I: IntoIterator<Item = St>,
31373        St: AsRef<str>,
31374    {
31375        self._scopes
31376            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31377        self
31378    }
31379
31380    /// Removes all scopes, and no default scope will be used either.
31381    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31382    /// for details).
31383    pub fn clear_scopes(mut self) -> ConnectionTypeListCall<'a, C> {
31384        self._scopes.clear();
31385        self
31386    }
31387}
31388
31389/// Deletes an existing content category.
31390///
31391/// A builder for the *delete* method supported by a *contentCategory* resource.
31392/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
31393///
31394/// # Example
31395///
31396/// Instantiate a resource method builder
31397///
31398/// ```test_harness,no_run
31399/// # extern crate hyper;
31400/// # extern crate hyper_rustls;
31401/// # extern crate google_dfareporting3d2 as dfareporting3d2;
31402/// # async fn dox() {
31403/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31404///
31405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31407/// #     secret,
31408/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31409/// # ).build().await.unwrap();
31410///
31411/// # let client = hyper_util::client::legacy::Client::builder(
31412/// #     hyper_util::rt::TokioExecutor::new()
31413/// # )
31414/// # .build(
31415/// #     hyper_rustls::HttpsConnectorBuilder::new()
31416/// #         .with_native_roots()
31417/// #         .unwrap()
31418/// #         .https_or_http()
31419/// #         .enable_http1()
31420/// #         .build()
31421/// # );
31422/// # let mut hub = Dfareporting::new(client, auth);
31423/// // You can configure optional parameters by calling the respective setters at will, and
31424/// // execute the final call using `doit()`.
31425/// // Values shown here are possibly random and not representative !
31426/// let result = hub.content_categories().delete(-73, -62)
31427///              .doit().await;
31428/// # }
31429/// ```
31430pub struct ContentCategoryDeleteCall<'a, C>
31431where
31432    C: 'a,
31433{
31434    hub: &'a Dfareporting<C>,
31435    _profile_id: i64,
31436    _id: i64,
31437    _delegate: Option<&'a mut dyn common::Delegate>,
31438    _additional_params: HashMap<String, String>,
31439    _scopes: BTreeSet<String>,
31440}
31441
31442impl<'a, C> common::CallBuilder for ContentCategoryDeleteCall<'a, C> {}
31443
31444impl<'a, C> ContentCategoryDeleteCall<'a, C>
31445where
31446    C: common::Connector,
31447{
31448    /// Perform the operation you have build so far.
31449    pub async fn doit(mut self) -> common::Result<common::Response> {
31450        use std::borrow::Cow;
31451        use std::io::{Read, Seek};
31452
31453        use common::{url::Params, ToParts};
31454        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31455
31456        let mut dd = common::DefaultDelegate;
31457        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31458        dlg.begin(common::MethodInfo {
31459            id: "dfareporting.contentCategories.delete",
31460            http_method: hyper::Method::DELETE,
31461        });
31462
31463        for &field in ["profileId", "id"].iter() {
31464            if self._additional_params.contains_key(field) {
31465                dlg.finished(false);
31466                return Err(common::Error::FieldClash(field));
31467            }
31468        }
31469
31470        let mut params = Params::with_capacity(3 + self._additional_params.len());
31471        params.push("profileId", self._profile_id.to_string());
31472        params.push("id", self._id.to_string());
31473
31474        params.extend(self._additional_params.iter());
31475
31476        let mut url =
31477            self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories/{id}";
31478        if self._scopes.is_empty() {
31479            self._scopes
31480                .insert(Scope::Dfatrafficking.as_ref().to_string());
31481        }
31482
31483        #[allow(clippy::single_element_loop)]
31484        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
31485            url = params.uri_replacement(url, param_name, find_this, false);
31486        }
31487        {
31488            let to_remove = ["id", "profileId"];
31489            params.remove_params(&to_remove);
31490        }
31491
31492        let url = params.parse_with_url(&url);
31493
31494        loop {
31495            let token = match self
31496                .hub
31497                .auth
31498                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31499                .await
31500            {
31501                Ok(token) => token,
31502                Err(e) => match dlg.token(e) {
31503                    Ok(token) => token,
31504                    Err(e) => {
31505                        dlg.finished(false);
31506                        return Err(common::Error::MissingToken(e));
31507                    }
31508                },
31509            };
31510            let mut req_result = {
31511                let client = &self.hub.client;
31512                dlg.pre_request();
31513                let mut req_builder = hyper::Request::builder()
31514                    .method(hyper::Method::DELETE)
31515                    .uri(url.as_str())
31516                    .header(USER_AGENT, self.hub._user_agent.clone());
31517
31518                if let Some(token) = token.as_ref() {
31519                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31520                }
31521
31522                let request = req_builder
31523                    .header(CONTENT_LENGTH, 0_u64)
31524                    .body(common::to_body::<String>(None));
31525
31526                client.request(request.unwrap()).await
31527            };
31528
31529            match req_result {
31530                Err(err) => {
31531                    if let common::Retry::After(d) = dlg.http_error(&err) {
31532                        sleep(d).await;
31533                        continue;
31534                    }
31535                    dlg.finished(false);
31536                    return Err(common::Error::HttpError(err));
31537                }
31538                Ok(res) => {
31539                    let (mut parts, body) = res.into_parts();
31540                    let mut body = common::Body::new(body);
31541                    if !parts.status.is_success() {
31542                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31543                        let error = serde_json::from_str(&common::to_string(&bytes));
31544                        let response = common::to_response(parts, bytes.into());
31545
31546                        if let common::Retry::After(d) =
31547                            dlg.http_failure(&response, error.as_ref().ok())
31548                        {
31549                            sleep(d).await;
31550                            continue;
31551                        }
31552
31553                        dlg.finished(false);
31554
31555                        return Err(match error {
31556                            Ok(value) => common::Error::BadRequest(value),
31557                            _ => common::Error::Failure(response),
31558                        });
31559                    }
31560                    let response = common::Response::from_parts(parts, body);
31561
31562                    dlg.finished(true);
31563                    return Ok(response);
31564                }
31565            }
31566        }
31567    }
31568
31569    /// User profile ID associated with this request.
31570    ///
31571    /// Sets the *profile id* path property to the given value.
31572    ///
31573    /// Even though the property as already been set when instantiating this call,
31574    /// we provide this method for API completeness.
31575    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryDeleteCall<'a, C> {
31576        self._profile_id = new_value;
31577        self
31578    }
31579    /// Content category ID.
31580    ///
31581    /// Sets the *id* path property to the given value.
31582    ///
31583    /// Even though the property as already been set when instantiating this call,
31584    /// we provide this method for API completeness.
31585    pub fn id(mut self, new_value: i64) -> ContentCategoryDeleteCall<'a, C> {
31586        self._id = new_value;
31587        self
31588    }
31589    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31590    /// while executing the actual API request.
31591    ///
31592    /// ````text
31593    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31594    /// ````
31595    ///
31596    /// Sets the *delegate* property to the given value.
31597    pub fn delegate(
31598        mut self,
31599        new_value: &'a mut dyn common::Delegate,
31600    ) -> ContentCategoryDeleteCall<'a, C> {
31601        self._delegate = Some(new_value);
31602        self
31603    }
31604
31605    /// Set any additional parameter of the query string used in the request.
31606    /// It should be used to set parameters which are not yet available through their own
31607    /// setters.
31608    ///
31609    /// Please note that this method must not be used to set any of the known parameters
31610    /// which have their own setter method. If done anyway, the request will fail.
31611    ///
31612    /// # Additional Parameters
31613    ///
31614    /// * *alt* (query-string) - Data format for the response.
31615    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31616    /// * *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.
31617    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31618    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31619    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31620    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31621    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryDeleteCall<'a, C>
31622    where
31623        T: AsRef<str>,
31624    {
31625        self._additional_params
31626            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31627        self
31628    }
31629
31630    /// Identifies the authorization scope for the method you are building.
31631    ///
31632    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31633    /// [`Scope::Dfatrafficking`].
31634    ///
31635    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31636    /// tokens for more than one scope.
31637    ///
31638    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31639    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31640    /// sufficient, a read-write scope will do as well.
31641    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryDeleteCall<'a, C>
31642    where
31643        St: AsRef<str>,
31644    {
31645        self._scopes.insert(String::from(scope.as_ref()));
31646        self
31647    }
31648    /// Identifies the authorization scope(s) for the method you are building.
31649    ///
31650    /// See [`Self::add_scope()`] for details.
31651    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryDeleteCall<'a, C>
31652    where
31653        I: IntoIterator<Item = St>,
31654        St: AsRef<str>,
31655    {
31656        self._scopes
31657            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31658        self
31659    }
31660
31661    /// Removes all scopes, and no default scope will be used either.
31662    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31663    /// for details).
31664    pub fn clear_scopes(mut self) -> ContentCategoryDeleteCall<'a, C> {
31665        self._scopes.clear();
31666        self
31667    }
31668}
31669
31670/// Gets one content category by ID.
31671///
31672/// A builder for the *get* method supported by a *contentCategory* resource.
31673/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
31674///
31675/// # Example
31676///
31677/// Instantiate a resource method builder
31678///
31679/// ```test_harness,no_run
31680/// # extern crate hyper;
31681/// # extern crate hyper_rustls;
31682/// # extern crate google_dfareporting3d2 as dfareporting3d2;
31683/// # async fn dox() {
31684/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31685///
31686/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31688/// #     secret,
31689/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31690/// # ).build().await.unwrap();
31691///
31692/// # let client = hyper_util::client::legacy::Client::builder(
31693/// #     hyper_util::rt::TokioExecutor::new()
31694/// # )
31695/// # .build(
31696/// #     hyper_rustls::HttpsConnectorBuilder::new()
31697/// #         .with_native_roots()
31698/// #         .unwrap()
31699/// #         .https_or_http()
31700/// #         .enable_http1()
31701/// #         .build()
31702/// # );
31703/// # let mut hub = Dfareporting::new(client, auth);
31704/// // You can configure optional parameters by calling the respective setters at will, and
31705/// // execute the final call using `doit()`.
31706/// // Values shown here are possibly random and not representative !
31707/// let result = hub.content_categories().get(-45, -27)
31708///              .doit().await;
31709/// # }
31710/// ```
31711pub struct ContentCategoryGetCall<'a, C>
31712where
31713    C: 'a,
31714{
31715    hub: &'a Dfareporting<C>,
31716    _profile_id: i64,
31717    _id: i64,
31718    _delegate: Option<&'a mut dyn common::Delegate>,
31719    _additional_params: HashMap<String, String>,
31720    _scopes: BTreeSet<String>,
31721}
31722
31723impl<'a, C> common::CallBuilder for ContentCategoryGetCall<'a, C> {}
31724
31725impl<'a, C> ContentCategoryGetCall<'a, C>
31726where
31727    C: common::Connector,
31728{
31729    /// Perform the operation you have build so far.
31730    pub async fn doit(mut self) -> common::Result<(common::Response, ContentCategory)> {
31731        use std::borrow::Cow;
31732        use std::io::{Read, Seek};
31733
31734        use common::{url::Params, ToParts};
31735        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31736
31737        let mut dd = common::DefaultDelegate;
31738        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31739        dlg.begin(common::MethodInfo {
31740            id: "dfareporting.contentCategories.get",
31741            http_method: hyper::Method::GET,
31742        });
31743
31744        for &field in ["alt", "profileId", "id"].iter() {
31745            if self._additional_params.contains_key(field) {
31746                dlg.finished(false);
31747                return Err(common::Error::FieldClash(field));
31748            }
31749        }
31750
31751        let mut params = Params::with_capacity(4 + self._additional_params.len());
31752        params.push("profileId", self._profile_id.to_string());
31753        params.push("id", self._id.to_string());
31754
31755        params.extend(self._additional_params.iter());
31756
31757        params.push("alt", "json");
31758        let mut url =
31759            self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories/{id}";
31760        if self._scopes.is_empty() {
31761            self._scopes
31762                .insert(Scope::Dfatrafficking.as_ref().to_string());
31763        }
31764
31765        #[allow(clippy::single_element_loop)]
31766        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
31767            url = params.uri_replacement(url, param_name, find_this, false);
31768        }
31769        {
31770            let to_remove = ["id", "profileId"];
31771            params.remove_params(&to_remove);
31772        }
31773
31774        let url = params.parse_with_url(&url);
31775
31776        loop {
31777            let token = match self
31778                .hub
31779                .auth
31780                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31781                .await
31782            {
31783                Ok(token) => token,
31784                Err(e) => match dlg.token(e) {
31785                    Ok(token) => token,
31786                    Err(e) => {
31787                        dlg.finished(false);
31788                        return Err(common::Error::MissingToken(e));
31789                    }
31790                },
31791            };
31792            let mut req_result = {
31793                let client = &self.hub.client;
31794                dlg.pre_request();
31795                let mut req_builder = hyper::Request::builder()
31796                    .method(hyper::Method::GET)
31797                    .uri(url.as_str())
31798                    .header(USER_AGENT, self.hub._user_agent.clone());
31799
31800                if let Some(token) = token.as_ref() {
31801                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31802                }
31803
31804                let request = req_builder
31805                    .header(CONTENT_LENGTH, 0_u64)
31806                    .body(common::to_body::<String>(None));
31807
31808                client.request(request.unwrap()).await
31809            };
31810
31811            match req_result {
31812                Err(err) => {
31813                    if let common::Retry::After(d) = dlg.http_error(&err) {
31814                        sleep(d).await;
31815                        continue;
31816                    }
31817                    dlg.finished(false);
31818                    return Err(common::Error::HttpError(err));
31819                }
31820                Ok(res) => {
31821                    let (mut parts, body) = res.into_parts();
31822                    let mut body = common::Body::new(body);
31823                    if !parts.status.is_success() {
31824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31825                        let error = serde_json::from_str(&common::to_string(&bytes));
31826                        let response = common::to_response(parts, bytes.into());
31827
31828                        if let common::Retry::After(d) =
31829                            dlg.http_failure(&response, error.as_ref().ok())
31830                        {
31831                            sleep(d).await;
31832                            continue;
31833                        }
31834
31835                        dlg.finished(false);
31836
31837                        return Err(match error {
31838                            Ok(value) => common::Error::BadRequest(value),
31839                            _ => common::Error::Failure(response),
31840                        });
31841                    }
31842                    let response = {
31843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
31844                        let encoded = common::to_string(&bytes);
31845                        match serde_json::from_str(&encoded) {
31846                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31847                            Err(error) => {
31848                                dlg.response_json_decode_error(&encoded, &error);
31849                                return Err(common::Error::JsonDecodeError(
31850                                    encoded.to_string(),
31851                                    error,
31852                                ));
31853                            }
31854                        }
31855                    };
31856
31857                    dlg.finished(true);
31858                    return Ok(response);
31859                }
31860            }
31861        }
31862    }
31863
31864    /// User profile ID associated with this request.
31865    ///
31866    /// Sets the *profile id* path property to the given value.
31867    ///
31868    /// Even though the property as already been set when instantiating this call,
31869    /// we provide this method for API completeness.
31870    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryGetCall<'a, C> {
31871        self._profile_id = new_value;
31872        self
31873    }
31874    /// Content category ID.
31875    ///
31876    /// Sets the *id* path property to the given value.
31877    ///
31878    /// Even though the property as already been set when instantiating this call,
31879    /// we provide this method for API completeness.
31880    pub fn id(mut self, new_value: i64) -> ContentCategoryGetCall<'a, C> {
31881        self._id = new_value;
31882        self
31883    }
31884    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31885    /// while executing the actual API request.
31886    ///
31887    /// ````text
31888    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
31889    /// ````
31890    ///
31891    /// Sets the *delegate* property to the given value.
31892    pub fn delegate(
31893        mut self,
31894        new_value: &'a mut dyn common::Delegate,
31895    ) -> ContentCategoryGetCall<'a, C> {
31896        self._delegate = Some(new_value);
31897        self
31898    }
31899
31900    /// Set any additional parameter of the query string used in the request.
31901    /// It should be used to set parameters which are not yet available through their own
31902    /// setters.
31903    ///
31904    /// Please note that this method must not be used to set any of the known parameters
31905    /// which have their own setter method. If done anyway, the request will fail.
31906    ///
31907    /// # Additional Parameters
31908    ///
31909    /// * *alt* (query-string) - Data format for the response.
31910    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31911    /// * *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.
31912    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31913    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31914    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
31915    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
31916    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryGetCall<'a, C>
31917    where
31918        T: AsRef<str>,
31919    {
31920        self._additional_params
31921            .insert(name.as_ref().to_string(), value.as_ref().to_string());
31922        self
31923    }
31924
31925    /// Identifies the authorization scope for the method you are building.
31926    ///
31927    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31928    /// [`Scope::Dfatrafficking`].
31929    ///
31930    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31931    /// tokens for more than one scope.
31932    ///
31933    /// Usually there is more than one suitable scope to authorize an operation, some of which may
31934    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31935    /// sufficient, a read-write scope will do as well.
31936    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryGetCall<'a, C>
31937    where
31938        St: AsRef<str>,
31939    {
31940        self._scopes.insert(String::from(scope.as_ref()));
31941        self
31942    }
31943    /// Identifies the authorization scope(s) for the method you are building.
31944    ///
31945    /// See [`Self::add_scope()`] for details.
31946    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryGetCall<'a, C>
31947    where
31948        I: IntoIterator<Item = St>,
31949        St: AsRef<str>,
31950    {
31951        self._scopes
31952            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31953        self
31954    }
31955
31956    /// Removes all scopes, and no default scope will be used either.
31957    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31958    /// for details).
31959    pub fn clear_scopes(mut self) -> ContentCategoryGetCall<'a, C> {
31960        self._scopes.clear();
31961        self
31962    }
31963}
31964
31965/// Inserts a new content category.
31966///
31967/// A builder for the *insert* method supported by a *contentCategory* resource.
31968/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
31969///
31970/// # Example
31971///
31972/// Instantiate a resource method builder
31973///
31974/// ```test_harness,no_run
31975/// # extern crate hyper;
31976/// # extern crate hyper_rustls;
31977/// # extern crate google_dfareporting3d2 as dfareporting3d2;
31978/// use dfareporting3d2::api::ContentCategory;
31979/// # async fn dox() {
31980/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31981///
31982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
31984/// #     secret,
31985/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31986/// # ).build().await.unwrap();
31987///
31988/// # let client = hyper_util::client::legacy::Client::builder(
31989/// #     hyper_util::rt::TokioExecutor::new()
31990/// # )
31991/// # .build(
31992/// #     hyper_rustls::HttpsConnectorBuilder::new()
31993/// #         .with_native_roots()
31994/// #         .unwrap()
31995/// #         .https_or_http()
31996/// #         .enable_http1()
31997/// #         .build()
31998/// # );
31999/// # let mut hub = Dfareporting::new(client, auth);
32000/// // As the method needs a request, you would usually fill it with the desired information
32001/// // into the respective structure. Some of the parts shown here might not be applicable !
32002/// // Values shown here are possibly random and not representative !
32003/// let mut req = ContentCategory::default();
32004///
32005/// // You can configure optional parameters by calling the respective setters at will, and
32006/// // execute the final call using `doit()`.
32007/// // Values shown here are possibly random and not representative !
32008/// let result = hub.content_categories().insert(req, -53)
32009///              .doit().await;
32010/// # }
32011/// ```
32012pub struct ContentCategoryInsertCall<'a, C>
32013where
32014    C: 'a,
32015{
32016    hub: &'a Dfareporting<C>,
32017    _request: ContentCategory,
32018    _profile_id: i64,
32019    _delegate: Option<&'a mut dyn common::Delegate>,
32020    _additional_params: HashMap<String, String>,
32021    _scopes: BTreeSet<String>,
32022}
32023
32024impl<'a, C> common::CallBuilder for ContentCategoryInsertCall<'a, C> {}
32025
32026impl<'a, C> ContentCategoryInsertCall<'a, C>
32027where
32028    C: common::Connector,
32029{
32030    /// Perform the operation you have build so far.
32031    pub async fn doit(mut self) -> common::Result<(common::Response, ContentCategory)> {
32032        use std::borrow::Cow;
32033        use std::io::{Read, Seek};
32034
32035        use common::{url::Params, ToParts};
32036        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32037
32038        let mut dd = common::DefaultDelegate;
32039        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32040        dlg.begin(common::MethodInfo {
32041            id: "dfareporting.contentCategories.insert",
32042            http_method: hyper::Method::POST,
32043        });
32044
32045        for &field in ["alt", "profileId"].iter() {
32046            if self._additional_params.contains_key(field) {
32047                dlg.finished(false);
32048                return Err(common::Error::FieldClash(field));
32049            }
32050        }
32051
32052        let mut params = Params::with_capacity(4 + self._additional_params.len());
32053        params.push("profileId", self._profile_id.to_string());
32054
32055        params.extend(self._additional_params.iter());
32056
32057        params.push("alt", "json");
32058        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories";
32059        if self._scopes.is_empty() {
32060            self._scopes
32061                .insert(Scope::Dfatrafficking.as_ref().to_string());
32062        }
32063
32064        #[allow(clippy::single_element_loop)]
32065        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
32066            url = params.uri_replacement(url, param_name, find_this, false);
32067        }
32068        {
32069            let to_remove = ["profileId"];
32070            params.remove_params(&to_remove);
32071        }
32072
32073        let url = params.parse_with_url(&url);
32074
32075        let mut json_mime_type = mime::APPLICATION_JSON;
32076        let mut request_value_reader = {
32077            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32078            common::remove_json_null_values(&mut value);
32079            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32080            serde_json::to_writer(&mut dst, &value).unwrap();
32081            dst
32082        };
32083        let request_size = request_value_reader
32084            .seek(std::io::SeekFrom::End(0))
32085            .unwrap();
32086        request_value_reader
32087            .seek(std::io::SeekFrom::Start(0))
32088            .unwrap();
32089
32090        loop {
32091            let token = match self
32092                .hub
32093                .auth
32094                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32095                .await
32096            {
32097                Ok(token) => token,
32098                Err(e) => match dlg.token(e) {
32099                    Ok(token) => token,
32100                    Err(e) => {
32101                        dlg.finished(false);
32102                        return Err(common::Error::MissingToken(e));
32103                    }
32104                },
32105            };
32106            request_value_reader
32107                .seek(std::io::SeekFrom::Start(0))
32108                .unwrap();
32109            let mut req_result = {
32110                let client = &self.hub.client;
32111                dlg.pre_request();
32112                let mut req_builder = hyper::Request::builder()
32113                    .method(hyper::Method::POST)
32114                    .uri(url.as_str())
32115                    .header(USER_AGENT, self.hub._user_agent.clone());
32116
32117                if let Some(token) = token.as_ref() {
32118                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32119                }
32120
32121                let request = req_builder
32122                    .header(CONTENT_TYPE, json_mime_type.to_string())
32123                    .header(CONTENT_LENGTH, request_size as u64)
32124                    .body(common::to_body(
32125                        request_value_reader.get_ref().clone().into(),
32126                    ));
32127
32128                client.request(request.unwrap()).await
32129            };
32130
32131            match req_result {
32132                Err(err) => {
32133                    if let common::Retry::After(d) = dlg.http_error(&err) {
32134                        sleep(d).await;
32135                        continue;
32136                    }
32137                    dlg.finished(false);
32138                    return Err(common::Error::HttpError(err));
32139                }
32140                Ok(res) => {
32141                    let (mut parts, body) = res.into_parts();
32142                    let mut body = common::Body::new(body);
32143                    if !parts.status.is_success() {
32144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32145                        let error = serde_json::from_str(&common::to_string(&bytes));
32146                        let response = common::to_response(parts, bytes.into());
32147
32148                        if let common::Retry::After(d) =
32149                            dlg.http_failure(&response, error.as_ref().ok())
32150                        {
32151                            sleep(d).await;
32152                            continue;
32153                        }
32154
32155                        dlg.finished(false);
32156
32157                        return Err(match error {
32158                            Ok(value) => common::Error::BadRequest(value),
32159                            _ => common::Error::Failure(response),
32160                        });
32161                    }
32162                    let response = {
32163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32164                        let encoded = common::to_string(&bytes);
32165                        match serde_json::from_str(&encoded) {
32166                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32167                            Err(error) => {
32168                                dlg.response_json_decode_error(&encoded, &error);
32169                                return Err(common::Error::JsonDecodeError(
32170                                    encoded.to_string(),
32171                                    error,
32172                                ));
32173                            }
32174                        }
32175                    };
32176
32177                    dlg.finished(true);
32178                    return Ok(response);
32179                }
32180            }
32181        }
32182    }
32183
32184    ///
32185    /// Sets the *request* property to the given value.
32186    ///
32187    /// Even though the property as already been set when instantiating this call,
32188    /// we provide this method for API completeness.
32189    pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryInsertCall<'a, C> {
32190        self._request = new_value;
32191        self
32192    }
32193    /// User profile ID associated with this request.
32194    ///
32195    /// Sets the *profile id* path property to the given value.
32196    ///
32197    /// Even though the property as already been set when instantiating this call,
32198    /// we provide this method for API completeness.
32199    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryInsertCall<'a, C> {
32200        self._profile_id = new_value;
32201        self
32202    }
32203    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32204    /// while executing the actual API request.
32205    ///
32206    /// ````text
32207    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32208    /// ````
32209    ///
32210    /// Sets the *delegate* property to the given value.
32211    pub fn delegate(
32212        mut self,
32213        new_value: &'a mut dyn common::Delegate,
32214    ) -> ContentCategoryInsertCall<'a, C> {
32215        self._delegate = Some(new_value);
32216        self
32217    }
32218
32219    /// Set any additional parameter of the query string used in the request.
32220    /// It should be used to set parameters which are not yet available through their own
32221    /// setters.
32222    ///
32223    /// Please note that this method must not be used to set any of the known parameters
32224    /// which have their own setter method. If done anyway, the request will fail.
32225    ///
32226    /// # Additional Parameters
32227    ///
32228    /// * *alt* (query-string) - Data format for the response.
32229    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32230    /// * *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.
32231    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32232    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32233    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32234    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32235    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryInsertCall<'a, C>
32236    where
32237        T: AsRef<str>,
32238    {
32239        self._additional_params
32240            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32241        self
32242    }
32243
32244    /// Identifies the authorization scope for the method you are building.
32245    ///
32246    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32247    /// [`Scope::Dfatrafficking`].
32248    ///
32249    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32250    /// tokens for more than one scope.
32251    ///
32252    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32253    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32254    /// sufficient, a read-write scope will do as well.
32255    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryInsertCall<'a, C>
32256    where
32257        St: AsRef<str>,
32258    {
32259        self._scopes.insert(String::from(scope.as_ref()));
32260        self
32261    }
32262    /// Identifies the authorization scope(s) for the method you are building.
32263    ///
32264    /// See [`Self::add_scope()`] for details.
32265    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryInsertCall<'a, C>
32266    where
32267        I: IntoIterator<Item = St>,
32268        St: AsRef<str>,
32269    {
32270        self._scopes
32271            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32272        self
32273    }
32274
32275    /// Removes all scopes, and no default scope will be used either.
32276    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32277    /// for details).
32278    pub fn clear_scopes(mut self) -> ContentCategoryInsertCall<'a, C> {
32279        self._scopes.clear();
32280        self
32281    }
32282}
32283
32284/// Retrieves a list of content categories, possibly filtered. This method supports paging.
32285///
32286/// A builder for the *list* method supported by a *contentCategory* resource.
32287/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
32288///
32289/// # Example
32290///
32291/// Instantiate a resource method builder
32292///
32293/// ```test_harness,no_run
32294/// # extern crate hyper;
32295/// # extern crate hyper_rustls;
32296/// # extern crate google_dfareporting3d2 as dfareporting3d2;
32297/// # async fn dox() {
32298/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32299///
32300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32302/// #     secret,
32303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32304/// # ).build().await.unwrap();
32305///
32306/// # let client = hyper_util::client::legacy::Client::builder(
32307/// #     hyper_util::rt::TokioExecutor::new()
32308/// # )
32309/// # .build(
32310/// #     hyper_rustls::HttpsConnectorBuilder::new()
32311/// #         .with_native_roots()
32312/// #         .unwrap()
32313/// #         .https_or_http()
32314/// #         .enable_http1()
32315/// #         .build()
32316/// # );
32317/// # let mut hub = Dfareporting::new(client, auth);
32318/// // You can configure optional parameters by calling the respective setters at will, and
32319/// // execute the final call using `doit()`.
32320/// // Values shown here are possibly random and not representative !
32321/// let result = hub.content_categories().list(-20)
32322///              .sort_order("sit")
32323///              .sort_field("magna")
32324///              .search_string("et")
32325///              .page_token("rebum.")
32326///              .max_results(-4)
32327///              .add_ids(-6)
32328///              .doit().await;
32329/// # }
32330/// ```
32331pub struct ContentCategoryListCall<'a, C>
32332where
32333    C: 'a,
32334{
32335    hub: &'a Dfareporting<C>,
32336    _profile_id: i64,
32337    _sort_order: Option<String>,
32338    _sort_field: Option<String>,
32339    _search_string: Option<String>,
32340    _page_token: Option<String>,
32341    _max_results: Option<i32>,
32342    _ids: Vec<i64>,
32343    _delegate: Option<&'a mut dyn common::Delegate>,
32344    _additional_params: HashMap<String, String>,
32345    _scopes: BTreeSet<String>,
32346}
32347
32348impl<'a, C> common::CallBuilder for ContentCategoryListCall<'a, C> {}
32349
32350impl<'a, C> ContentCategoryListCall<'a, C>
32351where
32352    C: common::Connector,
32353{
32354    /// Perform the operation you have build so far.
32355    pub async fn doit(
32356        mut self,
32357    ) -> common::Result<(common::Response, ContentCategoriesListResponse)> {
32358        use std::borrow::Cow;
32359        use std::io::{Read, Seek};
32360
32361        use common::{url::Params, ToParts};
32362        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32363
32364        let mut dd = common::DefaultDelegate;
32365        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32366        dlg.begin(common::MethodInfo {
32367            id: "dfareporting.contentCategories.list",
32368            http_method: hyper::Method::GET,
32369        });
32370
32371        for &field in [
32372            "alt",
32373            "profileId",
32374            "sortOrder",
32375            "sortField",
32376            "searchString",
32377            "pageToken",
32378            "maxResults",
32379            "ids",
32380        ]
32381        .iter()
32382        {
32383            if self._additional_params.contains_key(field) {
32384                dlg.finished(false);
32385                return Err(common::Error::FieldClash(field));
32386            }
32387        }
32388
32389        let mut params = Params::with_capacity(9 + self._additional_params.len());
32390        params.push("profileId", self._profile_id.to_string());
32391        if let Some(value) = self._sort_order.as_ref() {
32392            params.push("sortOrder", value);
32393        }
32394        if let Some(value) = self._sort_field.as_ref() {
32395            params.push("sortField", value);
32396        }
32397        if let Some(value) = self._search_string.as_ref() {
32398            params.push("searchString", value);
32399        }
32400        if let Some(value) = self._page_token.as_ref() {
32401            params.push("pageToken", value);
32402        }
32403        if let Some(value) = self._max_results.as_ref() {
32404            params.push("maxResults", value.to_string());
32405        }
32406        if !self._ids.is_empty() {
32407            for f in self._ids.iter() {
32408                params.push("ids", f.to_string());
32409            }
32410        }
32411
32412        params.extend(self._additional_params.iter());
32413
32414        params.push("alt", "json");
32415        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories";
32416        if self._scopes.is_empty() {
32417            self._scopes
32418                .insert(Scope::Dfatrafficking.as_ref().to_string());
32419        }
32420
32421        #[allow(clippy::single_element_loop)]
32422        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
32423            url = params.uri_replacement(url, param_name, find_this, false);
32424        }
32425        {
32426            let to_remove = ["profileId"];
32427            params.remove_params(&to_remove);
32428        }
32429
32430        let url = params.parse_with_url(&url);
32431
32432        loop {
32433            let token = match self
32434                .hub
32435                .auth
32436                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32437                .await
32438            {
32439                Ok(token) => token,
32440                Err(e) => match dlg.token(e) {
32441                    Ok(token) => token,
32442                    Err(e) => {
32443                        dlg.finished(false);
32444                        return Err(common::Error::MissingToken(e));
32445                    }
32446                },
32447            };
32448            let mut req_result = {
32449                let client = &self.hub.client;
32450                dlg.pre_request();
32451                let mut req_builder = hyper::Request::builder()
32452                    .method(hyper::Method::GET)
32453                    .uri(url.as_str())
32454                    .header(USER_AGENT, self.hub._user_agent.clone());
32455
32456                if let Some(token) = token.as_ref() {
32457                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32458                }
32459
32460                let request = req_builder
32461                    .header(CONTENT_LENGTH, 0_u64)
32462                    .body(common::to_body::<String>(None));
32463
32464                client.request(request.unwrap()).await
32465            };
32466
32467            match req_result {
32468                Err(err) => {
32469                    if let common::Retry::After(d) = dlg.http_error(&err) {
32470                        sleep(d).await;
32471                        continue;
32472                    }
32473                    dlg.finished(false);
32474                    return Err(common::Error::HttpError(err));
32475                }
32476                Ok(res) => {
32477                    let (mut parts, body) = res.into_parts();
32478                    let mut body = common::Body::new(body);
32479                    if !parts.status.is_success() {
32480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32481                        let error = serde_json::from_str(&common::to_string(&bytes));
32482                        let response = common::to_response(parts, bytes.into());
32483
32484                        if let common::Retry::After(d) =
32485                            dlg.http_failure(&response, error.as_ref().ok())
32486                        {
32487                            sleep(d).await;
32488                            continue;
32489                        }
32490
32491                        dlg.finished(false);
32492
32493                        return Err(match error {
32494                            Ok(value) => common::Error::BadRequest(value),
32495                            _ => common::Error::Failure(response),
32496                        });
32497                    }
32498                    let response = {
32499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32500                        let encoded = common::to_string(&bytes);
32501                        match serde_json::from_str(&encoded) {
32502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32503                            Err(error) => {
32504                                dlg.response_json_decode_error(&encoded, &error);
32505                                return Err(common::Error::JsonDecodeError(
32506                                    encoded.to_string(),
32507                                    error,
32508                                ));
32509                            }
32510                        }
32511                    };
32512
32513                    dlg.finished(true);
32514                    return Ok(response);
32515                }
32516            }
32517        }
32518    }
32519
32520    /// User profile ID associated with this request.
32521    ///
32522    /// Sets the *profile id* path property to the given value.
32523    ///
32524    /// Even though the property as already been set when instantiating this call,
32525    /// we provide this method for API completeness.
32526    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryListCall<'a, C> {
32527        self._profile_id = new_value;
32528        self
32529    }
32530    /// Order of sorted results.
32531    ///
32532    /// Sets the *sort order* query property to the given value.
32533    pub fn sort_order(mut self, new_value: &str) -> ContentCategoryListCall<'a, C> {
32534        self._sort_order = Some(new_value.to_string());
32535        self
32536    }
32537    /// Field by which to sort the list.
32538    ///
32539    /// Sets the *sort field* query property to the given value.
32540    pub fn sort_field(mut self, new_value: &str) -> ContentCategoryListCall<'a, C> {
32541        self._sort_field = Some(new_value.to_string());
32542        self
32543    }
32544    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "contentcategory*2015" will return objects with names like "contentcategory June 2015", "contentcategory April 2015", or simply "contentcategory 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "contentcategory" will match objects with name "my contentcategory", "contentcategory 2015", or simply "contentcategory".
32545    ///
32546    /// Sets the *search string* query property to the given value.
32547    pub fn search_string(mut self, new_value: &str) -> ContentCategoryListCall<'a, C> {
32548        self._search_string = Some(new_value.to_string());
32549        self
32550    }
32551    /// Value of the nextPageToken from the previous result page.
32552    ///
32553    /// Sets the *page token* query property to the given value.
32554    pub fn page_token(mut self, new_value: &str) -> ContentCategoryListCall<'a, C> {
32555        self._page_token = Some(new_value.to_string());
32556        self
32557    }
32558    /// Maximum number of results to return.
32559    ///
32560    /// Sets the *max results* query property to the given value.
32561    pub fn max_results(mut self, new_value: i32) -> ContentCategoryListCall<'a, C> {
32562        self._max_results = Some(new_value);
32563        self
32564    }
32565    /// Select only content categories with these IDs.
32566    ///
32567    /// Append the given value to the *ids* query property.
32568    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
32569    pub fn add_ids(mut self, new_value: i64) -> ContentCategoryListCall<'a, C> {
32570        self._ids.push(new_value);
32571        self
32572    }
32573    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32574    /// while executing the actual API request.
32575    ///
32576    /// ````text
32577    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32578    /// ````
32579    ///
32580    /// Sets the *delegate* property to the given value.
32581    pub fn delegate(
32582        mut self,
32583        new_value: &'a mut dyn common::Delegate,
32584    ) -> ContentCategoryListCall<'a, C> {
32585        self._delegate = Some(new_value);
32586        self
32587    }
32588
32589    /// Set any additional parameter of the query string used in the request.
32590    /// It should be used to set parameters which are not yet available through their own
32591    /// setters.
32592    ///
32593    /// Please note that this method must not be used to set any of the known parameters
32594    /// which have their own setter method. If done anyway, the request will fail.
32595    ///
32596    /// # Additional Parameters
32597    ///
32598    /// * *alt* (query-string) - Data format for the response.
32599    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32600    /// * *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.
32601    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32602    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32603    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32604    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32605    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryListCall<'a, C>
32606    where
32607        T: AsRef<str>,
32608    {
32609        self._additional_params
32610            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32611        self
32612    }
32613
32614    /// Identifies the authorization scope for the method you are building.
32615    ///
32616    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32617    /// [`Scope::Dfatrafficking`].
32618    ///
32619    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32620    /// tokens for more than one scope.
32621    ///
32622    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32623    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32624    /// sufficient, a read-write scope will do as well.
32625    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryListCall<'a, C>
32626    where
32627        St: AsRef<str>,
32628    {
32629        self._scopes.insert(String::from(scope.as_ref()));
32630        self
32631    }
32632    /// Identifies the authorization scope(s) for the method you are building.
32633    ///
32634    /// See [`Self::add_scope()`] for details.
32635    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryListCall<'a, C>
32636    where
32637        I: IntoIterator<Item = St>,
32638        St: AsRef<str>,
32639    {
32640        self._scopes
32641            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32642        self
32643    }
32644
32645    /// Removes all scopes, and no default scope will be used either.
32646    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32647    /// for details).
32648    pub fn clear_scopes(mut self) -> ContentCategoryListCall<'a, C> {
32649        self._scopes.clear();
32650        self
32651    }
32652}
32653
32654/// Updates an existing content category. This method supports patch semantics.
32655///
32656/// A builder for the *patch* method supported by a *contentCategory* resource.
32657/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
32658///
32659/// # Example
32660///
32661/// Instantiate a resource method builder
32662///
32663/// ```test_harness,no_run
32664/// # extern crate hyper;
32665/// # extern crate hyper_rustls;
32666/// # extern crate google_dfareporting3d2 as dfareporting3d2;
32667/// use dfareporting3d2::api::ContentCategory;
32668/// # async fn dox() {
32669/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32670///
32671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32672/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
32673/// #     secret,
32674/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32675/// # ).build().await.unwrap();
32676///
32677/// # let client = hyper_util::client::legacy::Client::builder(
32678/// #     hyper_util::rt::TokioExecutor::new()
32679/// # )
32680/// # .build(
32681/// #     hyper_rustls::HttpsConnectorBuilder::new()
32682/// #         .with_native_roots()
32683/// #         .unwrap()
32684/// #         .https_or_http()
32685/// #         .enable_http1()
32686/// #         .build()
32687/// # );
32688/// # let mut hub = Dfareporting::new(client, auth);
32689/// // As the method needs a request, you would usually fill it with the desired information
32690/// // into the respective structure. Some of the parts shown here might not be applicable !
32691/// // Values shown here are possibly random and not representative !
32692/// let mut req = ContentCategory::default();
32693///
32694/// // You can configure optional parameters by calling the respective setters at will, and
32695/// // execute the final call using `doit()`.
32696/// // Values shown here are possibly random and not representative !
32697/// let result = hub.content_categories().patch(req, -71, -52)
32698///              .doit().await;
32699/// # }
32700/// ```
32701pub struct ContentCategoryPatchCall<'a, C>
32702where
32703    C: 'a,
32704{
32705    hub: &'a Dfareporting<C>,
32706    _request: ContentCategory,
32707    _profile_id: i64,
32708    _id: i64,
32709    _delegate: Option<&'a mut dyn common::Delegate>,
32710    _additional_params: HashMap<String, String>,
32711    _scopes: BTreeSet<String>,
32712}
32713
32714impl<'a, C> common::CallBuilder for ContentCategoryPatchCall<'a, C> {}
32715
32716impl<'a, C> ContentCategoryPatchCall<'a, C>
32717where
32718    C: common::Connector,
32719{
32720    /// Perform the operation you have build so far.
32721    pub async fn doit(mut self) -> common::Result<(common::Response, ContentCategory)> {
32722        use std::borrow::Cow;
32723        use std::io::{Read, Seek};
32724
32725        use common::{url::Params, ToParts};
32726        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32727
32728        let mut dd = common::DefaultDelegate;
32729        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32730        dlg.begin(common::MethodInfo {
32731            id: "dfareporting.contentCategories.patch",
32732            http_method: hyper::Method::PATCH,
32733        });
32734
32735        for &field in ["alt", "profileId", "id"].iter() {
32736            if self._additional_params.contains_key(field) {
32737                dlg.finished(false);
32738                return Err(common::Error::FieldClash(field));
32739            }
32740        }
32741
32742        let mut params = Params::with_capacity(5 + self._additional_params.len());
32743        params.push("profileId", self._profile_id.to_string());
32744        params.push("id", self._id.to_string());
32745
32746        params.extend(self._additional_params.iter());
32747
32748        params.push("alt", "json");
32749        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories";
32750        if self._scopes.is_empty() {
32751            self._scopes
32752                .insert(Scope::Dfatrafficking.as_ref().to_string());
32753        }
32754
32755        #[allow(clippy::single_element_loop)]
32756        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
32757            url = params.uri_replacement(url, param_name, find_this, false);
32758        }
32759        {
32760            let to_remove = ["profileId"];
32761            params.remove_params(&to_remove);
32762        }
32763
32764        let url = params.parse_with_url(&url);
32765
32766        let mut json_mime_type = mime::APPLICATION_JSON;
32767        let mut request_value_reader = {
32768            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
32769            common::remove_json_null_values(&mut value);
32770            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
32771            serde_json::to_writer(&mut dst, &value).unwrap();
32772            dst
32773        };
32774        let request_size = request_value_reader
32775            .seek(std::io::SeekFrom::End(0))
32776            .unwrap();
32777        request_value_reader
32778            .seek(std::io::SeekFrom::Start(0))
32779            .unwrap();
32780
32781        loop {
32782            let token = match self
32783                .hub
32784                .auth
32785                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32786                .await
32787            {
32788                Ok(token) => token,
32789                Err(e) => match dlg.token(e) {
32790                    Ok(token) => token,
32791                    Err(e) => {
32792                        dlg.finished(false);
32793                        return Err(common::Error::MissingToken(e));
32794                    }
32795                },
32796            };
32797            request_value_reader
32798                .seek(std::io::SeekFrom::Start(0))
32799                .unwrap();
32800            let mut req_result = {
32801                let client = &self.hub.client;
32802                dlg.pre_request();
32803                let mut req_builder = hyper::Request::builder()
32804                    .method(hyper::Method::PATCH)
32805                    .uri(url.as_str())
32806                    .header(USER_AGENT, self.hub._user_agent.clone());
32807
32808                if let Some(token) = token.as_ref() {
32809                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32810                }
32811
32812                let request = req_builder
32813                    .header(CONTENT_TYPE, json_mime_type.to_string())
32814                    .header(CONTENT_LENGTH, request_size as u64)
32815                    .body(common::to_body(
32816                        request_value_reader.get_ref().clone().into(),
32817                    ));
32818
32819                client.request(request.unwrap()).await
32820            };
32821
32822            match req_result {
32823                Err(err) => {
32824                    if let common::Retry::After(d) = dlg.http_error(&err) {
32825                        sleep(d).await;
32826                        continue;
32827                    }
32828                    dlg.finished(false);
32829                    return Err(common::Error::HttpError(err));
32830                }
32831                Ok(res) => {
32832                    let (mut parts, body) = res.into_parts();
32833                    let mut body = common::Body::new(body);
32834                    if !parts.status.is_success() {
32835                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32836                        let error = serde_json::from_str(&common::to_string(&bytes));
32837                        let response = common::to_response(parts, bytes.into());
32838
32839                        if let common::Retry::After(d) =
32840                            dlg.http_failure(&response, error.as_ref().ok())
32841                        {
32842                            sleep(d).await;
32843                            continue;
32844                        }
32845
32846                        dlg.finished(false);
32847
32848                        return Err(match error {
32849                            Ok(value) => common::Error::BadRequest(value),
32850                            _ => common::Error::Failure(response),
32851                        });
32852                    }
32853                    let response = {
32854                        let bytes = common::to_bytes(body).await.unwrap_or_default();
32855                        let encoded = common::to_string(&bytes);
32856                        match serde_json::from_str(&encoded) {
32857                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32858                            Err(error) => {
32859                                dlg.response_json_decode_error(&encoded, &error);
32860                                return Err(common::Error::JsonDecodeError(
32861                                    encoded.to_string(),
32862                                    error,
32863                                ));
32864                            }
32865                        }
32866                    };
32867
32868                    dlg.finished(true);
32869                    return Ok(response);
32870                }
32871            }
32872        }
32873    }
32874
32875    ///
32876    /// Sets the *request* property to the given value.
32877    ///
32878    /// Even though the property as already been set when instantiating this call,
32879    /// we provide this method for API completeness.
32880    pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryPatchCall<'a, C> {
32881        self._request = new_value;
32882        self
32883    }
32884    /// User profile ID associated with this request.
32885    ///
32886    /// Sets the *profile id* path property to the given value.
32887    ///
32888    /// Even though the property as already been set when instantiating this call,
32889    /// we provide this method for API completeness.
32890    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryPatchCall<'a, C> {
32891        self._profile_id = new_value;
32892        self
32893    }
32894    /// Content category ID.
32895    ///
32896    /// Sets the *id* query property to the given value.
32897    ///
32898    /// Even though the property as already been set when instantiating this call,
32899    /// we provide this method for API completeness.
32900    pub fn id(mut self, new_value: i64) -> ContentCategoryPatchCall<'a, C> {
32901        self._id = new_value;
32902        self
32903    }
32904    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32905    /// while executing the actual API request.
32906    ///
32907    /// ````text
32908    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
32909    /// ````
32910    ///
32911    /// Sets the *delegate* property to the given value.
32912    pub fn delegate(
32913        mut self,
32914        new_value: &'a mut dyn common::Delegate,
32915    ) -> ContentCategoryPatchCall<'a, C> {
32916        self._delegate = Some(new_value);
32917        self
32918    }
32919
32920    /// Set any additional parameter of the query string used in the request.
32921    /// It should be used to set parameters which are not yet available through their own
32922    /// setters.
32923    ///
32924    /// Please note that this method must not be used to set any of the known parameters
32925    /// which have their own setter method. If done anyway, the request will fail.
32926    ///
32927    /// # Additional Parameters
32928    ///
32929    /// * *alt* (query-string) - Data format for the response.
32930    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32931    /// * *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.
32932    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32933    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32934    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
32935    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
32936    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryPatchCall<'a, C>
32937    where
32938        T: AsRef<str>,
32939    {
32940        self._additional_params
32941            .insert(name.as_ref().to_string(), value.as_ref().to_string());
32942        self
32943    }
32944
32945    /// Identifies the authorization scope for the method you are building.
32946    ///
32947    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32948    /// [`Scope::Dfatrafficking`].
32949    ///
32950    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32951    /// tokens for more than one scope.
32952    ///
32953    /// Usually there is more than one suitable scope to authorize an operation, some of which may
32954    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32955    /// sufficient, a read-write scope will do as well.
32956    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryPatchCall<'a, C>
32957    where
32958        St: AsRef<str>,
32959    {
32960        self._scopes.insert(String::from(scope.as_ref()));
32961        self
32962    }
32963    /// Identifies the authorization scope(s) for the method you are building.
32964    ///
32965    /// See [`Self::add_scope()`] for details.
32966    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryPatchCall<'a, C>
32967    where
32968        I: IntoIterator<Item = St>,
32969        St: AsRef<str>,
32970    {
32971        self._scopes
32972            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32973        self
32974    }
32975
32976    /// Removes all scopes, and no default scope will be used either.
32977    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32978    /// for details).
32979    pub fn clear_scopes(mut self) -> ContentCategoryPatchCall<'a, C> {
32980        self._scopes.clear();
32981        self
32982    }
32983}
32984
32985/// Updates an existing content category.
32986///
32987/// A builder for the *update* method supported by a *contentCategory* resource.
32988/// It is not used directly, but through a [`ContentCategoryMethods`] instance.
32989///
32990/// # Example
32991///
32992/// Instantiate a resource method builder
32993///
32994/// ```test_harness,no_run
32995/// # extern crate hyper;
32996/// # extern crate hyper_rustls;
32997/// # extern crate google_dfareporting3d2 as dfareporting3d2;
32998/// use dfareporting3d2::api::ContentCategory;
32999/// # async fn dox() {
33000/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33001///
33002/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33003/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33004/// #     secret,
33005/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33006/// # ).build().await.unwrap();
33007///
33008/// # let client = hyper_util::client::legacy::Client::builder(
33009/// #     hyper_util::rt::TokioExecutor::new()
33010/// # )
33011/// # .build(
33012/// #     hyper_rustls::HttpsConnectorBuilder::new()
33013/// #         .with_native_roots()
33014/// #         .unwrap()
33015/// #         .https_or_http()
33016/// #         .enable_http1()
33017/// #         .build()
33018/// # );
33019/// # let mut hub = Dfareporting::new(client, auth);
33020/// // As the method needs a request, you would usually fill it with the desired information
33021/// // into the respective structure. Some of the parts shown here might not be applicable !
33022/// // Values shown here are possibly random and not representative !
33023/// let mut req = ContentCategory::default();
33024///
33025/// // You can configure optional parameters by calling the respective setters at will, and
33026/// // execute the final call using `doit()`.
33027/// // Values shown here are possibly random and not representative !
33028/// let result = hub.content_categories().update(req, -11)
33029///              .doit().await;
33030/// # }
33031/// ```
33032pub struct ContentCategoryUpdateCall<'a, C>
33033where
33034    C: 'a,
33035{
33036    hub: &'a Dfareporting<C>,
33037    _request: ContentCategory,
33038    _profile_id: i64,
33039    _delegate: Option<&'a mut dyn common::Delegate>,
33040    _additional_params: HashMap<String, String>,
33041    _scopes: BTreeSet<String>,
33042}
33043
33044impl<'a, C> common::CallBuilder for ContentCategoryUpdateCall<'a, C> {}
33045
33046impl<'a, C> ContentCategoryUpdateCall<'a, C>
33047where
33048    C: common::Connector,
33049{
33050    /// Perform the operation you have build so far.
33051    pub async fn doit(mut self) -> common::Result<(common::Response, ContentCategory)> {
33052        use std::borrow::Cow;
33053        use std::io::{Read, Seek};
33054
33055        use common::{url::Params, ToParts};
33056        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33057
33058        let mut dd = common::DefaultDelegate;
33059        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33060        dlg.begin(common::MethodInfo {
33061            id: "dfareporting.contentCategories.update",
33062            http_method: hyper::Method::PUT,
33063        });
33064
33065        for &field in ["alt", "profileId"].iter() {
33066            if self._additional_params.contains_key(field) {
33067                dlg.finished(false);
33068                return Err(common::Error::FieldClash(field));
33069            }
33070        }
33071
33072        let mut params = Params::with_capacity(4 + self._additional_params.len());
33073        params.push("profileId", self._profile_id.to_string());
33074
33075        params.extend(self._additional_params.iter());
33076
33077        params.push("alt", "json");
33078        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories";
33079        if self._scopes.is_empty() {
33080            self._scopes
33081                .insert(Scope::Dfatrafficking.as_ref().to_string());
33082        }
33083
33084        #[allow(clippy::single_element_loop)]
33085        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
33086            url = params.uri_replacement(url, param_name, find_this, false);
33087        }
33088        {
33089            let to_remove = ["profileId"];
33090            params.remove_params(&to_remove);
33091        }
33092
33093        let url = params.parse_with_url(&url);
33094
33095        let mut json_mime_type = mime::APPLICATION_JSON;
33096        let mut request_value_reader = {
33097            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33098            common::remove_json_null_values(&mut value);
33099            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33100            serde_json::to_writer(&mut dst, &value).unwrap();
33101            dst
33102        };
33103        let request_size = request_value_reader
33104            .seek(std::io::SeekFrom::End(0))
33105            .unwrap();
33106        request_value_reader
33107            .seek(std::io::SeekFrom::Start(0))
33108            .unwrap();
33109
33110        loop {
33111            let token = match self
33112                .hub
33113                .auth
33114                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33115                .await
33116            {
33117                Ok(token) => token,
33118                Err(e) => match dlg.token(e) {
33119                    Ok(token) => token,
33120                    Err(e) => {
33121                        dlg.finished(false);
33122                        return Err(common::Error::MissingToken(e));
33123                    }
33124                },
33125            };
33126            request_value_reader
33127                .seek(std::io::SeekFrom::Start(0))
33128                .unwrap();
33129            let mut req_result = {
33130                let client = &self.hub.client;
33131                dlg.pre_request();
33132                let mut req_builder = hyper::Request::builder()
33133                    .method(hyper::Method::PUT)
33134                    .uri(url.as_str())
33135                    .header(USER_AGENT, self.hub._user_agent.clone());
33136
33137                if let Some(token) = token.as_ref() {
33138                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33139                }
33140
33141                let request = req_builder
33142                    .header(CONTENT_TYPE, json_mime_type.to_string())
33143                    .header(CONTENT_LENGTH, request_size as u64)
33144                    .body(common::to_body(
33145                        request_value_reader.get_ref().clone().into(),
33146                    ));
33147
33148                client.request(request.unwrap()).await
33149            };
33150
33151            match req_result {
33152                Err(err) => {
33153                    if let common::Retry::After(d) = dlg.http_error(&err) {
33154                        sleep(d).await;
33155                        continue;
33156                    }
33157                    dlg.finished(false);
33158                    return Err(common::Error::HttpError(err));
33159                }
33160                Ok(res) => {
33161                    let (mut parts, body) = res.into_parts();
33162                    let mut body = common::Body::new(body);
33163                    if !parts.status.is_success() {
33164                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33165                        let error = serde_json::from_str(&common::to_string(&bytes));
33166                        let response = common::to_response(parts, bytes.into());
33167
33168                        if let common::Retry::After(d) =
33169                            dlg.http_failure(&response, error.as_ref().ok())
33170                        {
33171                            sleep(d).await;
33172                            continue;
33173                        }
33174
33175                        dlg.finished(false);
33176
33177                        return Err(match error {
33178                            Ok(value) => common::Error::BadRequest(value),
33179                            _ => common::Error::Failure(response),
33180                        });
33181                    }
33182                    let response = {
33183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33184                        let encoded = common::to_string(&bytes);
33185                        match serde_json::from_str(&encoded) {
33186                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33187                            Err(error) => {
33188                                dlg.response_json_decode_error(&encoded, &error);
33189                                return Err(common::Error::JsonDecodeError(
33190                                    encoded.to_string(),
33191                                    error,
33192                                ));
33193                            }
33194                        }
33195                    };
33196
33197                    dlg.finished(true);
33198                    return Ok(response);
33199                }
33200            }
33201        }
33202    }
33203
33204    ///
33205    /// Sets the *request* property to the given value.
33206    ///
33207    /// Even though the property as already been set when instantiating this call,
33208    /// we provide this method for API completeness.
33209    pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryUpdateCall<'a, C> {
33210        self._request = new_value;
33211        self
33212    }
33213    /// User profile ID associated with this request.
33214    ///
33215    /// Sets the *profile id* path property to the given value.
33216    ///
33217    /// Even though the property as already been set when instantiating this call,
33218    /// we provide this method for API completeness.
33219    pub fn profile_id(mut self, new_value: i64) -> ContentCategoryUpdateCall<'a, C> {
33220        self._profile_id = new_value;
33221        self
33222    }
33223    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33224    /// while executing the actual API request.
33225    ///
33226    /// ````text
33227    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33228    /// ````
33229    ///
33230    /// Sets the *delegate* property to the given value.
33231    pub fn delegate(
33232        mut self,
33233        new_value: &'a mut dyn common::Delegate,
33234    ) -> ContentCategoryUpdateCall<'a, C> {
33235        self._delegate = Some(new_value);
33236        self
33237    }
33238
33239    /// Set any additional parameter of the query string used in the request.
33240    /// It should be used to set parameters which are not yet available through their own
33241    /// setters.
33242    ///
33243    /// Please note that this method must not be used to set any of the known parameters
33244    /// which have their own setter method. If done anyway, the request will fail.
33245    ///
33246    /// # Additional Parameters
33247    ///
33248    /// * *alt* (query-string) - Data format for the response.
33249    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33250    /// * *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.
33251    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33252    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33253    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33254    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33255    pub fn param<T>(mut self, name: T, value: T) -> ContentCategoryUpdateCall<'a, C>
33256    where
33257        T: AsRef<str>,
33258    {
33259        self._additional_params
33260            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33261        self
33262    }
33263
33264    /// Identifies the authorization scope for the method you are building.
33265    ///
33266    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33267    /// [`Scope::Dfatrafficking`].
33268    ///
33269    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33270    /// tokens for more than one scope.
33271    ///
33272    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33273    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33274    /// sufficient, a read-write scope will do as well.
33275    pub fn add_scope<St>(mut self, scope: St) -> ContentCategoryUpdateCall<'a, C>
33276    where
33277        St: AsRef<str>,
33278    {
33279        self._scopes.insert(String::from(scope.as_ref()));
33280        self
33281    }
33282    /// Identifies the authorization scope(s) for the method you are building.
33283    ///
33284    /// See [`Self::add_scope()`] for details.
33285    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContentCategoryUpdateCall<'a, C>
33286    where
33287        I: IntoIterator<Item = St>,
33288        St: AsRef<str>,
33289    {
33290        self._scopes
33291            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33292        self
33293    }
33294
33295    /// Removes all scopes, and no default scope will be used either.
33296    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33297    /// for details).
33298    pub fn clear_scopes(mut self) -> ContentCategoryUpdateCall<'a, C> {
33299        self._scopes.clear();
33300        self
33301    }
33302}
33303
33304/// Inserts conversions.
33305///
33306/// A builder for the *batchinsert* method supported by a *conversion* resource.
33307/// It is not used directly, but through a [`ConversionMethods`] instance.
33308///
33309/// # Example
33310///
33311/// Instantiate a resource method builder
33312///
33313/// ```test_harness,no_run
33314/// # extern crate hyper;
33315/// # extern crate hyper_rustls;
33316/// # extern crate google_dfareporting3d2 as dfareporting3d2;
33317/// use dfareporting3d2::api::ConversionsBatchInsertRequest;
33318/// # async fn dox() {
33319/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33320///
33321/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33322/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33323/// #     secret,
33324/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33325/// # ).build().await.unwrap();
33326///
33327/// # let client = hyper_util::client::legacy::Client::builder(
33328/// #     hyper_util::rt::TokioExecutor::new()
33329/// # )
33330/// # .build(
33331/// #     hyper_rustls::HttpsConnectorBuilder::new()
33332/// #         .with_native_roots()
33333/// #         .unwrap()
33334/// #         .https_or_http()
33335/// #         .enable_http1()
33336/// #         .build()
33337/// # );
33338/// # let mut hub = Dfareporting::new(client, auth);
33339/// // As the method needs a request, you would usually fill it with the desired information
33340/// // into the respective structure. Some of the parts shown here might not be applicable !
33341/// // Values shown here are possibly random and not representative !
33342/// let mut req = ConversionsBatchInsertRequest::default();
33343///
33344/// // You can configure optional parameters by calling the respective setters at will, and
33345/// // execute the final call using `doit()`.
33346/// // Values shown here are possibly random and not representative !
33347/// let result = hub.conversions().batchinsert(req, -91)
33348///              .doit().await;
33349/// # }
33350/// ```
33351pub struct ConversionBatchinsertCall<'a, C>
33352where
33353    C: 'a,
33354{
33355    hub: &'a Dfareporting<C>,
33356    _request: ConversionsBatchInsertRequest,
33357    _profile_id: i64,
33358    _delegate: Option<&'a mut dyn common::Delegate>,
33359    _additional_params: HashMap<String, String>,
33360    _scopes: BTreeSet<String>,
33361}
33362
33363impl<'a, C> common::CallBuilder for ConversionBatchinsertCall<'a, C> {}
33364
33365impl<'a, C> ConversionBatchinsertCall<'a, C>
33366where
33367    C: common::Connector,
33368{
33369    /// Perform the operation you have build so far.
33370    pub async fn doit(
33371        mut self,
33372    ) -> common::Result<(common::Response, ConversionsBatchInsertResponse)> {
33373        use std::borrow::Cow;
33374        use std::io::{Read, Seek};
33375
33376        use common::{url::Params, ToParts};
33377        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33378
33379        let mut dd = common::DefaultDelegate;
33380        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33381        dlg.begin(common::MethodInfo {
33382            id: "dfareporting.conversions.batchinsert",
33383            http_method: hyper::Method::POST,
33384        });
33385
33386        for &field in ["alt", "profileId"].iter() {
33387            if self._additional_params.contains_key(field) {
33388                dlg.finished(false);
33389                return Err(common::Error::FieldClash(field));
33390            }
33391        }
33392
33393        let mut params = Params::with_capacity(4 + self._additional_params.len());
33394        params.push("profileId", self._profile_id.to_string());
33395
33396        params.extend(self._additional_params.iter());
33397
33398        params.push("alt", "json");
33399        let mut url =
33400            self.hub._base_url.clone() + "userprofiles/{profileId}/conversions/batchinsert";
33401        if self._scopes.is_empty() {
33402            self._scopes
33403                .insert(Scope::Ddmconversion.as_ref().to_string());
33404        }
33405
33406        #[allow(clippy::single_element_loop)]
33407        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
33408            url = params.uri_replacement(url, param_name, find_this, false);
33409        }
33410        {
33411            let to_remove = ["profileId"];
33412            params.remove_params(&to_remove);
33413        }
33414
33415        let url = params.parse_with_url(&url);
33416
33417        let mut json_mime_type = mime::APPLICATION_JSON;
33418        let mut request_value_reader = {
33419            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33420            common::remove_json_null_values(&mut value);
33421            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33422            serde_json::to_writer(&mut dst, &value).unwrap();
33423            dst
33424        };
33425        let request_size = request_value_reader
33426            .seek(std::io::SeekFrom::End(0))
33427            .unwrap();
33428        request_value_reader
33429            .seek(std::io::SeekFrom::Start(0))
33430            .unwrap();
33431
33432        loop {
33433            let token = match self
33434                .hub
33435                .auth
33436                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33437                .await
33438            {
33439                Ok(token) => token,
33440                Err(e) => match dlg.token(e) {
33441                    Ok(token) => token,
33442                    Err(e) => {
33443                        dlg.finished(false);
33444                        return Err(common::Error::MissingToken(e));
33445                    }
33446                },
33447            };
33448            request_value_reader
33449                .seek(std::io::SeekFrom::Start(0))
33450                .unwrap();
33451            let mut req_result = {
33452                let client = &self.hub.client;
33453                dlg.pre_request();
33454                let mut req_builder = hyper::Request::builder()
33455                    .method(hyper::Method::POST)
33456                    .uri(url.as_str())
33457                    .header(USER_AGENT, self.hub._user_agent.clone());
33458
33459                if let Some(token) = token.as_ref() {
33460                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33461                }
33462
33463                let request = req_builder
33464                    .header(CONTENT_TYPE, json_mime_type.to_string())
33465                    .header(CONTENT_LENGTH, request_size as u64)
33466                    .body(common::to_body(
33467                        request_value_reader.get_ref().clone().into(),
33468                    ));
33469
33470                client.request(request.unwrap()).await
33471            };
33472
33473            match req_result {
33474                Err(err) => {
33475                    if let common::Retry::After(d) = dlg.http_error(&err) {
33476                        sleep(d).await;
33477                        continue;
33478                    }
33479                    dlg.finished(false);
33480                    return Err(common::Error::HttpError(err));
33481                }
33482                Ok(res) => {
33483                    let (mut parts, body) = res.into_parts();
33484                    let mut body = common::Body::new(body);
33485                    if !parts.status.is_success() {
33486                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33487                        let error = serde_json::from_str(&common::to_string(&bytes));
33488                        let response = common::to_response(parts, bytes.into());
33489
33490                        if let common::Retry::After(d) =
33491                            dlg.http_failure(&response, error.as_ref().ok())
33492                        {
33493                            sleep(d).await;
33494                            continue;
33495                        }
33496
33497                        dlg.finished(false);
33498
33499                        return Err(match error {
33500                            Ok(value) => common::Error::BadRequest(value),
33501                            _ => common::Error::Failure(response),
33502                        });
33503                    }
33504                    let response = {
33505                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33506                        let encoded = common::to_string(&bytes);
33507                        match serde_json::from_str(&encoded) {
33508                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33509                            Err(error) => {
33510                                dlg.response_json_decode_error(&encoded, &error);
33511                                return Err(common::Error::JsonDecodeError(
33512                                    encoded.to_string(),
33513                                    error,
33514                                ));
33515                            }
33516                        }
33517                    };
33518
33519                    dlg.finished(true);
33520                    return Ok(response);
33521                }
33522            }
33523        }
33524    }
33525
33526    ///
33527    /// Sets the *request* property to the given value.
33528    ///
33529    /// Even though the property as already been set when instantiating this call,
33530    /// we provide this method for API completeness.
33531    pub fn request(
33532        mut self,
33533        new_value: ConversionsBatchInsertRequest,
33534    ) -> ConversionBatchinsertCall<'a, C> {
33535        self._request = new_value;
33536        self
33537    }
33538    /// User profile ID associated with this request.
33539    ///
33540    /// Sets the *profile id* path property to the given value.
33541    ///
33542    /// Even though the property as already been set when instantiating this call,
33543    /// we provide this method for API completeness.
33544    pub fn profile_id(mut self, new_value: i64) -> ConversionBatchinsertCall<'a, C> {
33545        self._profile_id = new_value;
33546        self
33547    }
33548    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33549    /// while executing the actual API request.
33550    ///
33551    /// ````text
33552    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33553    /// ````
33554    ///
33555    /// Sets the *delegate* property to the given value.
33556    pub fn delegate(
33557        mut self,
33558        new_value: &'a mut dyn common::Delegate,
33559    ) -> ConversionBatchinsertCall<'a, C> {
33560        self._delegate = Some(new_value);
33561        self
33562    }
33563
33564    /// Set any additional parameter of the query string used in the request.
33565    /// It should be used to set parameters which are not yet available through their own
33566    /// setters.
33567    ///
33568    /// Please note that this method must not be used to set any of the known parameters
33569    /// which have their own setter method. If done anyway, the request will fail.
33570    ///
33571    /// # Additional Parameters
33572    ///
33573    /// * *alt* (query-string) - Data format for the response.
33574    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33575    /// * *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.
33576    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33577    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33578    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33579    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33580    pub fn param<T>(mut self, name: T, value: T) -> ConversionBatchinsertCall<'a, C>
33581    where
33582        T: AsRef<str>,
33583    {
33584        self._additional_params
33585            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33586        self
33587    }
33588
33589    /// Identifies the authorization scope for the method you are building.
33590    ///
33591    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33592    /// [`Scope::Ddmconversion`].
33593    ///
33594    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33595    /// tokens for more than one scope.
33596    ///
33597    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33598    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33599    /// sufficient, a read-write scope will do as well.
33600    pub fn add_scope<St>(mut self, scope: St) -> ConversionBatchinsertCall<'a, C>
33601    where
33602        St: AsRef<str>,
33603    {
33604        self._scopes.insert(String::from(scope.as_ref()));
33605        self
33606    }
33607    /// Identifies the authorization scope(s) for the method you are building.
33608    ///
33609    /// See [`Self::add_scope()`] for details.
33610    pub fn add_scopes<I, St>(mut self, scopes: I) -> ConversionBatchinsertCall<'a, C>
33611    where
33612        I: IntoIterator<Item = St>,
33613        St: AsRef<str>,
33614    {
33615        self._scopes
33616            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33617        self
33618    }
33619
33620    /// Removes all scopes, and no default scope will be used either.
33621    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33622    /// for details).
33623    pub fn clear_scopes(mut self) -> ConversionBatchinsertCall<'a, C> {
33624        self._scopes.clear();
33625        self
33626    }
33627}
33628
33629/// Updates existing conversions.
33630///
33631/// A builder for the *batchupdate* method supported by a *conversion* resource.
33632/// It is not used directly, but through a [`ConversionMethods`] instance.
33633///
33634/// # Example
33635///
33636/// Instantiate a resource method builder
33637///
33638/// ```test_harness,no_run
33639/// # extern crate hyper;
33640/// # extern crate hyper_rustls;
33641/// # extern crate google_dfareporting3d2 as dfareporting3d2;
33642/// use dfareporting3d2::api::ConversionsBatchUpdateRequest;
33643/// # async fn dox() {
33644/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33645///
33646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33648/// #     secret,
33649/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33650/// # ).build().await.unwrap();
33651///
33652/// # let client = hyper_util::client::legacy::Client::builder(
33653/// #     hyper_util::rt::TokioExecutor::new()
33654/// # )
33655/// # .build(
33656/// #     hyper_rustls::HttpsConnectorBuilder::new()
33657/// #         .with_native_roots()
33658/// #         .unwrap()
33659/// #         .https_or_http()
33660/// #         .enable_http1()
33661/// #         .build()
33662/// # );
33663/// # let mut hub = Dfareporting::new(client, auth);
33664/// // As the method needs a request, you would usually fill it with the desired information
33665/// // into the respective structure. Some of the parts shown here might not be applicable !
33666/// // Values shown here are possibly random and not representative !
33667/// let mut req = ConversionsBatchUpdateRequest::default();
33668///
33669/// // You can configure optional parameters by calling the respective setters at will, and
33670/// // execute the final call using `doit()`.
33671/// // Values shown here are possibly random and not representative !
33672/// let result = hub.conversions().batchupdate(req, -43)
33673///              .doit().await;
33674/// # }
33675/// ```
33676pub struct ConversionBatchupdateCall<'a, C>
33677where
33678    C: 'a,
33679{
33680    hub: &'a Dfareporting<C>,
33681    _request: ConversionsBatchUpdateRequest,
33682    _profile_id: i64,
33683    _delegate: Option<&'a mut dyn common::Delegate>,
33684    _additional_params: HashMap<String, String>,
33685    _scopes: BTreeSet<String>,
33686}
33687
33688impl<'a, C> common::CallBuilder for ConversionBatchupdateCall<'a, C> {}
33689
33690impl<'a, C> ConversionBatchupdateCall<'a, C>
33691where
33692    C: common::Connector,
33693{
33694    /// Perform the operation you have build so far.
33695    pub async fn doit(
33696        mut self,
33697    ) -> common::Result<(common::Response, ConversionsBatchUpdateResponse)> {
33698        use std::borrow::Cow;
33699        use std::io::{Read, Seek};
33700
33701        use common::{url::Params, ToParts};
33702        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33703
33704        let mut dd = common::DefaultDelegate;
33705        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33706        dlg.begin(common::MethodInfo {
33707            id: "dfareporting.conversions.batchupdate",
33708            http_method: hyper::Method::POST,
33709        });
33710
33711        for &field in ["alt", "profileId"].iter() {
33712            if self._additional_params.contains_key(field) {
33713                dlg.finished(false);
33714                return Err(common::Error::FieldClash(field));
33715            }
33716        }
33717
33718        let mut params = Params::with_capacity(4 + self._additional_params.len());
33719        params.push("profileId", self._profile_id.to_string());
33720
33721        params.extend(self._additional_params.iter());
33722
33723        params.push("alt", "json");
33724        let mut url =
33725            self.hub._base_url.clone() + "userprofiles/{profileId}/conversions/batchupdate";
33726        if self._scopes.is_empty() {
33727            self._scopes
33728                .insert(Scope::Ddmconversion.as_ref().to_string());
33729        }
33730
33731        #[allow(clippy::single_element_loop)]
33732        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
33733            url = params.uri_replacement(url, param_name, find_this, false);
33734        }
33735        {
33736            let to_remove = ["profileId"];
33737            params.remove_params(&to_remove);
33738        }
33739
33740        let url = params.parse_with_url(&url);
33741
33742        let mut json_mime_type = mime::APPLICATION_JSON;
33743        let mut request_value_reader = {
33744            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33745            common::remove_json_null_values(&mut value);
33746            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33747            serde_json::to_writer(&mut dst, &value).unwrap();
33748            dst
33749        };
33750        let request_size = request_value_reader
33751            .seek(std::io::SeekFrom::End(0))
33752            .unwrap();
33753        request_value_reader
33754            .seek(std::io::SeekFrom::Start(0))
33755            .unwrap();
33756
33757        loop {
33758            let token = match self
33759                .hub
33760                .auth
33761                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33762                .await
33763            {
33764                Ok(token) => token,
33765                Err(e) => match dlg.token(e) {
33766                    Ok(token) => token,
33767                    Err(e) => {
33768                        dlg.finished(false);
33769                        return Err(common::Error::MissingToken(e));
33770                    }
33771                },
33772            };
33773            request_value_reader
33774                .seek(std::io::SeekFrom::Start(0))
33775                .unwrap();
33776            let mut req_result = {
33777                let client = &self.hub.client;
33778                dlg.pre_request();
33779                let mut req_builder = hyper::Request::builder()
33780                    .method(hyper::Method::POST)
33781                    .uri(url.as_str())
33782                    .header(USER_AGENT, self.hub._user_agent.clone());
33783
33784                if let Some(token) = token.as_ref() {
33785                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33786                }
33787
33788                let request = req_builder
33789                    .header(CONTENT_TYPE, json_mime_type.to_string())
33790                    .header(CONTENT_LENGTH, request_size as u64)
33791                    .body(common::to_body(
33792                        request_value_reader.get_ref().clone().into(),
33793                    ));
33794
33795                client.request(request.unwrap()).await
33796            };
33797
33798            match req_result {
33799                Err(err) => {
33800                    if let common::Retry::After(d) = dlg.http_error(&err) {
33801                        sleep(d).await;
33802                        continue;
33803                    }
33804                    dlg.finished(false);
33805                    return Err(common::Error::HttpError(err));
33806                }
33807                Ok(res) => {
33808                    let (mut parts, body) = res.into_parts();
33809                    let mut body = common::Body::new(body);
33810                    if !parts.status.is_success() {
33811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33812                        let error = serde_json::from_str(&common::to_string(&bytes));
33813                        let response = common::to_response(parts, bytes.into());
33814
33815                        if let common::Retry::After(d) =
33816                            dlg.http_failure(&response, error.as_ref().ok())
33817                        {
33818                            sleep(d).await;
33819                            continue;
33820                        }
33821
33822                        dlg.finished(false);
33823
33824                        return Err(match error {
33825                            Ok(value) => common::Error::BadRequest(value),
33826                            _ => common::Error::Failure(response),
33827                        });
33828                    }
33829                    let response = {
33830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
33831                        let encoded = common::to_string(&bytes);
33832                        match serde_json::from_str(&encoded) {
33833                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33834                            Err(error) => {
33835                                dlg.response_json_decode_error(&encoded, &error);
33836                                return Err(common::Error::JsonDecodeError(
33837                                    encoded.to_string(),
33838                                    error,
33839                                ));
33840                            }
33841                        }
33842                    };
33843
33844                    dlg.finished(true);
33845                    return Ok(response);
33846                }
33847            }
33848        }
33849    }
33850
33851    ///
33852    /// Sets the *request* property to the given value.
33853    ///
33854    /// Even though the property as already been set when instantiating this call,
33855    /// we provide this method for API completeness.
33856    pub fn request(
33857        mut self,
33858        new_value: ConversionsBatchUpdateRequest,
33859    ) -> ConversionBatchupdateCall<'a, C> {
33860        self._request = new_value;
33861        self
33862    }
33863    /// User profile ID associated with this request.
33864    ///
33865    /// Sets the *profile id* path property to the given value.
33866    ///
33867    /// Even though the property as already been set when instantiating this call,
33868    /// we provide this method for API completeness.
33869    pub fn profile_id(mut self, new_value: i64) -> ConversionBatchupdateCall<'a, C> {
33870        self._profile_id = new_value;
33871        self
33872    }
33873    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33874    /// while executing the actual API request.
33875    ///
33876    /// ````text
33877    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
33878    /// ````
33879    ///
33880    /// Sets the *delegate* property to the given value.
33881    pub fn delegate(
33882        mut self,
33883        new_value: &'a mut dyn common::Delegate,
33884    ) -> ConversionBatchupdateCall<'a, C> {
33885        self._delegate = Some(new_value);
33886        self
33887    }
33888
33889    /// Set any additional parameter of the query string used in the request.
33890    /// It should be used to set parameters which are not yet available through their own
33891    /// setters.
33892    ///
33893    /// Please note that this method must not be used to set any of the known parameters
33894    /// which have their own setter method. If done anyway, the request will fail.
33895    ///
33896    /// # Additional Parameters
33897    ///
33898    /// * *alt* (query-string) - Data format for the response.
33899    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33900    /// * *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.
33901    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33902    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33903    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
33904    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
33905    pub fn param<T>(mut self, name: T, value: T) -> ConversionBatchupdateCall<'a, C>
33906    where
33907        T: AsRef<str>,
33908    {
33909        self._additional_params
33910            .insert(name.as_ref().to_string(), value.as_ref().to_string());
33911        self
33912    }
33913
33914    /// Identifies the authorization scope for the method you are building.
33915    ///
33916    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33917    /// [`Scope::Ddmconversion`].
33918    ///
33919    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33920    /// tokens for more than one scope.
33921    ///
33922    /// Usually there is more than one suitable scope to authorize an operation, some of which may
33923    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33924    /// sufficient, a read-write scope will do as well.
33925    pub fn add_scope<St>(mut self, scope: St) -> ConversionBatchupdateCall<'a, C>
33926    where
33927        St: AsRef<str>,
33928    {
33929        self._scopes.insert(String::from(scope.as_ref()));
33930        self
33931    }
33932    /// Identifies the authorization scope(s) for the method you are building.
33933    ///
33934    /// See [`Self::add_scope()`] for details.
33935    pub fn add_scopes<I, St>(mut self, scopes: I) -> ConversionBatchupdateCall<'a, C>
33936    where
33937        I: IntoIterator<Item = St>,
33938        St: AsRef<str>,
33939    {
33940        self._scopes
33941            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33942        self
33943    }
33944
33945    /// Removes all scopes, and no default scope will be used either.
33946    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33947    /// for details).
33948    pub fn clear_scopes(mut self) -> ConversionBatchupdateCall<'a, C> {
33949        self._scopes.clear();
33950        self
33951    }
33952}
33953
33954/// Gets one country by ID.
33955///
33956/// A builder for the *get* method supported by a *country* resource.
33957/// It is not used directly, but through a [`CountryMethods`] instance.
33958///
33959/// # Example
33960///
33961/// Instantiate a resource method builder
33962///
33963/// ```test_harness,no_run
33964/// # extern crate hyper;
33965/// # extern crate hyper_rustls;
33966/// # extern crate google_dfareporting3d2 as dfareporting3d2;
33967/// # async fn dox() {
33968/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33969///
33970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
33972/// #     secret,
33973/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33974/// # ).build().await.unwrap();
33975///
33976/// # let client = hyper_util::client::legacy::Client::builder(
33977/// #     hyper_util::rt::TokioExecutor::new()
33978/// # )
33979/// # .build(
33980/// #     hyper_rustls::HttpsConnectorBuilder::new()
33981/// #         .with_native_roots()
33982/// #         .unwrap()
33983/// #         .https_or_http()
33984/// #         .enable_http1()
33985/// #         .build()
33986/// # );
33987/// # let mut hub = Dfareporting::new(client, auth);
33988/// // You can configure optional parameters by calling the respective setters at will, and
33989/// // execute the final call using `doit()`.
33990/// // Values shown here are possibly random and not representative !
33991/// let result = hub.countries().get(-13, -101)
33992///              .doit().await;
33993/// # }
33994/// ```
33995pub struct CountryGetCall<'a, C>
33996where
33997    C: 'a,
33998{
33999    hub: &'a Dfareporting<C>,
34000    _profile_id: i64,
34001    _dart_id: i64,
34002    _delegate: Option<&'a mut dyn common::Delegate>,
34003    _additional_params: HashMap<String, String>,
34004    _scopes: BTreeSet<String>,
34005}
34006
34007impl<'a, C> common::CallBuilder for CountryGetCall<'a, C> {}
34008
34009impl<'a, C> CountryGetCall<'a, C>
34010where
34011    C: common::Connector,
34012{
34013    /// Perform the operation you have build so far.
34014    pub async fn doit(mut self) -> common::Result<(common::Response, Country)> {
34015        use std::borrow::Cow;
34016        use std::io::{Read, Seek};
34017
34018        use common::{url::Params, ToParts};
34019        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34020
34021        let mut dd = common::DefaultDelegate;
34022        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34023        dlg.begin(common::MethodInfo {
34024            id: "dfareporting.countries.get",
34025            http_method: hyper::Method::GET,
34026        });
34027
34028        for &field in ["alt", "profileId", "dartId"].iter() {
34029            if self._additional_params.contains_key(field) {
34030                dlg.finished(false);
34031                return Err(common::Error::FieldClash(field));
34032            }
34033        }
34034
34035        let mut params = Params::with_capacity(4 + self._additional_params.len());
34036        params.push("profileId", self._profile_id.to_string());
34037        params.push("dartId", self._dart_id.to_string());
34038
34039        params.extend(self._additional_params.iter());
34040
34041        params.push("alt", "json");
34042        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/countries/{dartId}";
34043        if self._scopes.is_empty() {
34044            self._scopes
34045                .insert(Scope::Dfatrafficking.as_ref().to_string());
34046        }
34047
34048        #[allow(clippy::single_element_loop)]
34049        for &(find_this, param_name) in
34050            [("{profileId}", "profileId"), ("{dartId}", "dartId")].iter()
34051        {
34052            url = params.uri_replacement(url, param_name, find_this, false);
34053        }
34054        {
34055            let to_remove = ["dartId", "profileId"];
34056            params.remove_params(&to_remove);
34057        }
34058
34059        let url = params.parse_with_url(&url);
34060
34061        loop {
34062            let token = match self
34063                .hub
34064                .auth
34065                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34066                .await
34067            {
34068                Ok(token) => token,
34069                Err(e) => match dlg.token(e) {
34070                    Ok(token) => token,
34071                    Err(e) => {
34072                        dlg.finished(false);
34073                        return Err(common::Error::MissingToken(e));
34074                    }
34075                },
34076            };
34077            let mut req_result = {
34078                let client = &self.hub.client;
34079                dlg.pre_request();
34080                let mut req_builder = hyper::Request::builder()
34081                    .method(hyper::Method::GET)
34082                    .uri(url.as_str())
34083                    .header(USER_AGENT, self.hub._user_agent.clone());
34084
34085                if let Some(token) = token.as_ref() {
34086                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34087                }
34088
34089                let request = req_builder
34090                    .header(CONTENT_LENGTH, 0_u64)
34091                    .body(common::to_body::<String>(None));
34092
34093                client.request(request.unwrap()).await
34094            };
34095
34096            match req_result {
34097                Err(err) => {
34098                    if let common::Retry::After(d) = dlg.http_error(&err) {
34099                        sleep(d).await;
34100                        continue;
34101                    }
34102                    dlg.finished(false);
34103                    return Err(common::Error::HttpError(err));
34104                }
34105                Ok(res) => {
34106                    let (mut parts, body) = res.into_parts();
34107                    let mut body = common::Body::new(body);
34108                    if !parts.status.is_success() {
34109                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34110                        let error = serde_json::from_str(&common::to_string(&bytes));
34111                        let response = common::to_response(parts, bytes.into());
34112
34113                        if let common::Retry::After(d) =
34114                            dlg.http_failure(&response, error.as_ref().ok())
34115                        {
34116                            sleep(d).await;
34117                            continue;
34118                        }
34119
34120                        dlg.finished(false);
34121
34122                        return Err(match error {
34123                            Ok(value) => common::Error::BadRequest(value),
34124                            _ => common::Error::Failure(response),
34125                        });
34126                    }
34127                    let response = {
34128                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34129                        let encoded = common::to_string(&bytes);
34130                        match serde_json::from_str(&encoded) {
34131                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34132                            Err(error) => {
34133                                dlg.response_json_decode_error(&encoded, &error);
34134                                return Err(common::Error::JsonDecodeError(
34135                                    encoded.to_string(),
34136                                    error,
34137                                ));
34138                            }
34139                        }
34140                    };
34141
34142                    dlg.finished(true);
34143                    return Ok(response);
34144                }
34145            }
34146        }
34147    }
34148
34149    /// User profile ID associated with this request.
34150    ///
34151    /// Sets the *profile id* path property to the given value.
34152    ///
34153    /// Even though the property as already been set when instantiating this call,
34154    /// we provide this method for API completeness.
34155    pub fn profile_id(mut self, new_value: i64) -> CountryGetCall<'a, C> {
34156        self._profile_id = new_value;
34157        self
34158    }
34159    /// Country DART ID.
34160    ///
34161    /// Sets the *dart id* path property to the given value.
34162    ///
34163    /// Even though the property as already been set when instantiating this call,
34164    /// we provide this method for API completeness.
34165    pub fn dart_id(mut self, new_value: i64) -> CountryGetCall<'a, C> {
34166        self._dart_id = new_value;
34167        self
34168    }
34169    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34170    /// while executing the actual API request.
34171    ///
34172    /// ````text
34173    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34174    /// ````
34175    ///
34176    /// Sets the *delegate* property to the given value.
34177    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CountryGetCall<'a, C> {
34178        self._delegate = Some(new_value);
34179        self
34180    }
34181
34182    /// Set any additional parameter of the query string used in the request.
34183    /// It should be used to set parameters which are not yet available through their own
34184    /// setters.
34185    ///
34186    /// Please note that this method must not be used to set any of the known parameters
34187    /// which have their own setter method. If done anyway, the request will fail.
34188    ///
34189    /// # Additional Parameters
34190    ///
34191    /// * *alt* (query-string) - Data format for the response.
34192    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34193    /// * *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.
34194    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34195    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34196    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34197    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34198    pub fn param<T>(mut self, name: T, value: T) -> CountryGetCall<'a, C>
34199    where
34200        T: AsRef<str>,
34201    {
34202        self._additional_params
34203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34204        self
34205    }
34206
34207    /// Identifies the authorization scope for the method you are building.
34208    ///
34209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34210    /// [`Scope::Dfatrafficking`].
34211    ///
34212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34213    /// tokens for more than one scope.
34214    ///
34215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34217    /// sufficient, a read-write scope will do as well.
34218    pub fn add_scope<St>(mut self, scope: St) -> CountryGetCall<'a, C>
34219    where
34220        St: AsRef<str>,
34221    {
34222        self._scopes.insert(String::from(scope.as_ref()));
34223        self
34224    }
34225    /// Identifies the authorization scope(s) for the method you are building.
34226    ///
34227    /// See [`Self::add_scope()`] for details.
34228    pub fn add_scopes<I, St>(mut self, scopes: I) -> CountryGetCall<'a, C>
34229    where
34230        I: IntoIterator<Item = St>,
34231        St: AsRef<str>,
34232    {
34233        self._scopes
34234            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34235        self
34236    }
34237
34238    /// Removes all scopes, and no default scope will be used either.
34239    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34240    /// for details).
34241    pub fn clear_scopes(mut self) -> CountryGetCall<'a, C> {
34242        self._scopes.clear();
34243        self
34244    }
34245}
34246
34247/// Retrieves a list of countries.
34248///
34249/// A builder for the *list* method supported by a *country* resource.
34250/// It is not used directly, but through a [`CountryMethods`] instance.
34251///
34252/// # Example
34253///
34254/// Instantiate a resource method builder
34255///
34256/// ```test_harness,no_run
34257/// # extern crate hyper;
34258/// # extern crate hyper_rustls;
34259/// # extern crate google_dfareporting3d2 as dfareporting3d2;
34260/// # async fn dox() {
34261/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34262///
34263/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34264/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34265/// #     secret,
34266/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34267/// # ).build().await.unwrap();
34268///
34269/// # let client = hyper_util::client::legacy::Client::builder(
34270/// #     hyper_util::rt::TokioExecutor::new()
34271/// # )
34272/// # .build(
34273/// #     hyper_rustls::HttpsConnectorBuilder::new()
34274/// #         .with_native_roots()
34275/// #         .unwrap()
34276/// #         .https_or_http()
34277/// #         .enable_http1()
34278/// #         .build()
34279/// # );
34280/// # let mut hub = Dfareporting::new(client, auth);
34281/// // You can configure optional parameters by calling the respective setters at will, and
34282/// // execute the final call using `doit()`.
34283/// // Values shown here are possibly random and not representative !
34284/// let result = hub.countries().list(-58)
34285///              .doit().await;
34286/// # }
34287/// ```
34288pub struct CountryListCall<'a, C>
34289where
34290    C: 'a,
34291{
34292    hub: &'a Dfareporting<C>,
34293    _profile_id: i64,
34294    _delegate: Option<&'a mut dyn common::Delegate>,
34295    _additional_params: HashMap<String, String>,
34296    _scopes: BTreeSet<String>,
34297}
34298
34299impl<'a, C> common::CallBuilder for CountryListCall<'a, C> {}
34300
34301impl<'a, C> CountryListCall<'a, C>
34302where
34303    C: common::Connector,
34304{
34305    /// Perform the operation you have build so far.
34306    pub async fn doit(mut self) -> common::Result<(common::Response, CountriesListResponse)> {
34307        use std::borrow::Cow;
34308        use std::io::{Read, Seek};
34309
34310        use common::{url::Params, ToParts};
34311        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34312
34313        let mut dd = common::DefaultDelegate;
34314        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34315        dlg.begin(common::MethodInfo {
34316            id: "dfareporting.countries.list",
34317            http_method: hyper::Method::GET,
34318        });
34319
34320        for &field in ["alt", "profileId"].iter() {
34321            if self._additional_params.contains_key(field) {
34322                dlg.finished(false);
34323                return Err(common::Error::FieldClash(field));
34324            }
34325        }
34326
34327        let mut params = Params::with_capacity(3 + self._additional_params.len());
34328        params.push("profileId", self._profile_id.to_string());
34329
34330        params.extend(self._additional_params.iter());
34331
34332        params.push("alt", "json");
34333        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/countries";
34334        if self._scopes.is_empty() {
34335            self._scopes
34336                .insert(Scope::Dfatrafficking.as_ref().to_string());
34337        }
34338
34339        #[allow(clippy::single_element_loop)]
34340        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
34341            url = params.uri_replacement(url, param_name, find_this, false);
34342        }
34343        {
34344            let to_remove = ["profileId"];
34345            params.remove_params(&to_remove);
34346        }
34347
34348        let url = params.parse_with_url(&url);
34349
34350        loop {
34351            let token = match self
34352                .hub
34353                .auth
34354                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34355                .await
34356            {
34357                Ok(token) => token,
34358                Err(e) => match dlg.token(e) {
34359                    Ok(token) => token,
34360                    Err(e) => {
34361                        dlg.finished(false);
34362                        return Err(common::Error::MissingToken(e));
34363                    }
34364                },
34365            };
34366            let mut req_result = {
34367                let client = &self.hub.client;
34368                dlg.pre_request();
34369                let mut req_builder = hyper::Request::builder()
34370                    .method(hyper::Method::GET)
34371                    .uri(url.as_str())
34372                    .header(USER_AGENT, self.hub._user_agent.clone());
34373
34374                if let Some(token) = token.as_ref() {
34375                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34376                }
34377
34378                let request = req_builder
34379                    .header(CONTENT_LENGTH, 0_u64)
34380                    .body(common::to_body::<String>(None));
34381
34382                client.request(request.unwrap()).await
34383            };
34384
34385            match req_result {
34386                Err(err) => {
34387                    if let common::Retry::After(d) = dlg.http_error(&err) {
34388                        sleep(d).await;
34389                        continue;
34390                    }
34391                    dlg.finished(false);
34392                    return Err(common::Error::HttpError(err));
34393                }
34394                Ok(res) => {
34395                    let (mut parts, body) = res.into_parts();
34396                    let mut body = common::Body::new(body);
34397                    if !parts.status.is_success() {
34398                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34399                        let error = serde_json::from_str(&common::to_string(&bytes));
34400                        let response = common::to_response(parts, bytes.into());
34401
34402                        if let common::Retry::After(d) =
34403                            dlg.http_failure(&response, error.as_ref().ok())
34404                        {
34405                            sleep(d).await;
34406                            continue;
34407                        }
34408
34409                        dlg.finished(false);
34410
34411                        return Err(match error {
34412                            Ok(value) => common::Error::BadRequest(value),
34413                            _ => common::Error::Failure(response),
34414                        });
34415                    }
34416                    let response = {
34417                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34418                        let encoded = common::to_string(&bytes);
34419                        match serde_json::from_str(&encoded) {
34420                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34421                            Err(error) => {
34422                                dlg.response_json_decode_error(&encoded, &error);
34423                                return Err(common::Error::JsonDecodeError(
34424                                    encoded.to_string(),
34425                                    error,
34426                                ));
34427                            }
34428                        }
34429                    };
34430
34431                    dlg.finished(true);
34432                    return Ok(response);
34433                }
34434            }
34435        }
34436    }
34437
34438    /// User profile ID associated with this request.
34439    ///
34440    /// Sets the *profile id* path property to the given value.
34441    ///
34442    /// Even though the property as already been set when instantiating this call,
34443    /// we provide this method for API completeness.
34444    pub fn profile_id(mut self, new_value: i64) -> CountryListCall<'a, C> {
34445        self._profile_id = new_value;
34446        self
34447    }
34448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34449    /// while executing the actual API request.
34450    ///
34451    /// ````text
34452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34453    /// ````
34454    ///
34455    /// Sets the *delegate* property to the given value.
34456    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CountryListCall<'a, C> {
34457        self._delegate = Some(new_value);
34458        self
34459    }
34460
34461    /// Set any additional parameter of the query string used in the request.
34462    /// It should be used to set parameters which are not yet available through their own
34463    /// setters.
34464    ///
34465    /// Please note that this method must not be used to set any of the known parameters
34466    /// which have their own setter method. If done anyway, the request will fail.
34467    ///
34468    /// # Additional Parameters
34469    ///
34470    /// * *alt* (query-string) - Data format for the response.
34471    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34472    /// * *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.
34473    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34474    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34475    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34476    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34477    pub fn param<T>(mut self, name: T, value: T) -> CountryListCall<'a, C>
34478    where
34479        T: AsRef<str>,
34480    {
34481        self._additional_params
34482            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34483        self
34484    }
34485
34486    /// Identifies the authorization scope for the method you are building.
34487    ///
34488    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34489    /// [`Scope::Dfatrafficking`].
34490    ///
34491    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34492    /// tokens for more than one scope.
34493    ///
34494    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34495    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34496    /// sufficient, a read-write scope will do as well.
34497    pub fn add_scope<St>(mut self, scope: St) -> CountryListCall<'a, C>
34498    where
34499        St: AsRef<str>,
34500    {
34501        self._scopes.insert(String::from(scope.as_ref()));
34502        self
34503    }
34504    /// Identifies the authorization scope(s) for the method you are building.
34505    ///
34506    /// See [`Self::add_scope()`] for details.
34507    pub fn add_scopes<I, St>(mut self, scopes: I) -> CountryListCall<'a, C>
34508    where
34509        I: IntoIterator<Item = St>,
34510        St: AsRef<str>,
34511    {
34512        self._scopes
34513            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34514        self
34515    }
34516
34517    /// Removes all scopes, and no default scope will be used either.
34518    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34519    /// for details).
34520    pub fn clear_scopes(mut self) -> CountryListCall<'a, C> {
34521        self._scopes.clear();
34522        self
34523    }
34524}
34525
34526/// Inserts a new creative asset.
34527///
34528/// A builder for the *insert* method supported by a *creativeAsset* resource.
34529/// It is not used directly, but through a [`CreativeAssetMethods`] instance.
34530///
34531/// # Example
34532///
34533/// Instantiate a resource method builder
34534///
34535/// ```test_harness,no_run
34536/// # extern crate hyper;
34537/// # extern crate hyper_rustls;
34538/// # extern crate google_dfareporting3d2 as dfareporting3d2;
34539/// use dfareporting3d2::api::CreativeAssetMetadata;
34540/// use std::fs;
34541/// # async fn dox() {
34542/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34543///
34544/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34545/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
34546/// #     secret,
34547/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34548/// # ).build().await.unwrap();
34549///
34550/// # let client = hyper_util::client::legacy::Client::builder(
34551/// #     hyper_util::rt::TokioExecutor::new()
34552/// # )
34553/// # .build(
34554/// #     hyper_rustls::HttpsConnectorBuilder::new()
34555/// #         .with_native_roots()
34556/// #         .unwrap()
34557/// #         .https_or_http()
34558/// #         .enable_http1()
34559/// #         .build()
34560/// # );
34561/// # let mut hub = Dfareporting::new(client, auth);
34562/// // As the method needs a request, you would usually fill it with the desired information
34563/// // into the respective structure. Some of the parts shown here might not be applicable !
34564/// // Values shown here are possibly random and not representative !
34565/// let mut req = CreativeAssetMetadata::default();
34566///
34567/// // You can configure optional parameters by calling the respective setters at will, and
34568/// // execute the final call using `upload(...)`.
34569/// // Values shown here are possibly random and not representative !
34570/// let result = hub.creative_assets().insert(req, -91, -66)
34571///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
34572/// # }
34573/// ```
34574pub struct CreativeAssetInsertCall<'a, C>
34575where
34576    C: 'a,
34577{
34578    hub: &'a Dfareporting<C>,
34579    _request: CreativeAssetMetadata,
34580    _profile_id: i64,
34581    _advertiser_id: i64,
34582    _delegate: Option<&'a mut dyn common::Delegate>,
34583    _additional_params: HashMap<String, String>,
34584    _scopes: BTreeSet<String>,
34585}
34586
34587impl<'a, C> common::CallBuilder for CreativeAssetInsertCall<'a, C> {}
34588
34589impl<'a, C> CreativeAssetInsertCall<'a, C>
34590where
34591    C: common::Connector,
34592{
34593    /// Perform the operation you have build so far.
34594    async fn doit<RS>(
34595        mut self,
34596        mut reader: RS,
34597        reader_mime_type: mime::Mime,
34598        protocol: common::UploadProtocol,
34599    ) -> common::Result<(common::Response, CreativeAssetMetadata)>
34600    where
34601        RS: common::ReadSeek,
34602    {
34603        use std::borrow::Cow;
34604        use std::io::{Read, Seek};
34605
34606        use common::{url::Params, ToParts};
34607        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34608
34609        let mut dd = common::DefaultDelegate;
34610        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34611        dlg.begin(common::MethodInfo {
34612            id: "dfareporting.creativeAssets.insert",
34613            http_method: hyper::Method::POST,
34614        });
34615
34616        for &field in ["alt", "profileId", "advertiserId"].iter() {
34617            if self._additional_params.contains_key(field) {
34618                dlg.finished(false);
34619                return Err(common::Error::FieldClash(field));
34620            }
34621        }
34622
34623        let mut params = Params::with_capacity(5 + self._additional_params.len());
34624        params.push("profileId", self._profile_id.to_string());
34625        params.push("advertiserId", self._advertiser_id.to_string());
34626
34627        params.extend(self._additional_params.iter());
34628
34629        params.push("alt", "json");
34630        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
34631            (self.hub._root_url.clone() + "resumable/upload/dfareporting/v3.2/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets", "resumable")
34632        } else if protocol == common::UploadProtocol::Simple {
34633            (self.hub._root_url.clone() + "upload/dfareporting/v3.2/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets", "multipart")
34634        } else {
34635            unreachable!()
34636        };
34637        params.push("uploadType", upload_type);
34638        if self._scopes.is_empty() {
34639            self._scopes
34640                .insert(Scope::Dfatrafficking.as_ref().to_string());
34641        }
34642
34643        #[allow(clippy::single_element_loop)]
34644        for &(find_this, param_name) in [
34645            ("{profileId}", "profileId"),
34646            ("{advertiserId}", "advertiserId"),
34647        ]
34648        .iter()
34649        {
34650            url = params.uri_replacement(url, param_name, find_this, false);
34651        }
34652        {
34653            let to_remove = ["advertiserId", "profileId"];
34654            params.remove_params(&to_remove);
34655        }
34656
34657        let url = params.parse_with_url(&url);
34658
34659        let mut json_mime_type = mime::APPLICATION_JSON;
34660        let mut request_value_reader = {
34661            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34662            common::remove_json_null_values(&mut value);
34663            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34664            serde_json::to_writer(&mut dst, &value).unwrap();
34665            dst
34666        };
34667        let request_size = request_value_reader
34668            .seek(std::io::SeekFrom::End(0))
34669            .unwrap();
34670        request_value_reader
34671            .seek(std::io::SeekFrom::Start(0))
34672            .unwrap();
34673
34674        let mut upload_url_from_server;
34675
34676        loop {
34677            let token = match self
34678                .hub
34679                .auth
34680                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34681                .await
34682            {
34683                Ok(token) => token,
34684                Err(e) => match dlg.token(e) {
34685                    Ok(token) => token,
34686                    Err(e) => {
34687                        dlg.finished(false);
34688                        return Err(common::Error::MissingToken(e));
34689                    }
34690                },
34691            };
34692            request_value_reader
34693                .seek(std::io::SeekFrom::Start(0))
34694                .unwrap();
34695            let mut req_result = {
34696                let mut mp_reader: common::MultiPartReader = Default::default();
34697                let (mut body_reader, content_type) = match protocol {
34698                    common::UploadProtocol::Simple => {
34699                        mp_reader.reserve_exact(2);
34700                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
34701                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
34702                        if size > 1073741824 {
34703                            return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
34704                        }
34705                        mp_reader
34706                            .add_part(
34707                                &mut request_value_reader,
34708                                request_size,
34709                                json_mime_type.clone(),
34710                            )
34711                            .add_part(&mut reader, size, reader_mime_type.clone());
34712                        (
34713                            &mut mp_reader as &mut (dyn std::io::Read + Send),
34714                            common::MultiPartReader::mime_type(),
34715                        )
34716                    }
34717                    _ => (
34718                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
34719                        json_mime_type.clone(),
34720                    ),
34721                };
34722                let client = &self.hub.client;
34723                dlg.pre_request();
34724                let mut req_builder = hyper::Request::builder()
34725                    .method(hyper::Method::POST)
34726                    .uri(url.as_str())
34727                    .header(USER_AGENT, self.hub._user_agent.clone());
34728
34729                if let Some(token) = token.as_ref() {
34730                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34731                }
34732
34733                upload_url_from_server = true;
34734                if protocol == common::UploadProtocol::Resumable {
34735                    req_builder = req_builder
34736                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
34737                }
34738
34739                let mut body_reader_bytes = vec![];
34740                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
34741                let request = req_builder
34742                    .header(CONTENT_TYPE, content_type.to_string())
34743                    .body(common::to_body(body_reader_bytes.into()));
34744
34745                client.request(request.unwrap()).await
34746            };
34747
34748            match req_result {
34749                Err(err) => {
34750                    if let common::Retry::After(d) = dlg.http_error(&err) {
34751                        sleep(d).await;
34752                        continue;
34753                    }
34754                    dlg.finished(false);
34755                    return Err(common::Error::HttpError(err));
34756                }
34757                Ok(res) => {
34758                    let (mut parts, body) = res.into_parts();
34759                    let mut body = common::Body::new(body);
34760                    if !parts.status.is_success() {
34761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34762                        let error = serde_json::from_str(&common::to_string(&bytes));
34763                        let response = common::to_response(parts, bytes.into());
34764
34765                        if let common::Retry::After(d) =
34766                            dlg.http_failure(&response, error.as_ref().ok())
34767                        {
34768                            sleep(d).await;
34769                            continue;
34770                        }
34771
34772                        dlg.finished(false);
34773
34774                        return Err(match error {
34775                            Ok(value) => common::Error::BadRequest(value),
34776                            _ => common::Error::Failure(response),
34777                        });
34778                    }
34779                    if protocol == common::UploadProtocol::Resumable {
34780                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
34781                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
34782                        if size > 1073741824 {
34783                            return Err(common::Error::UploadSizeLimitExceeded(size, 1073741824));
34784                        }
34785                        let upload_result = {
34786                            let url_str = &parts
34787                                .headers
34788                                .get("Location")
34789                                .expect("LOCATION header is part of protocol")
34790                                .to_str()
34791                                .unwrap();
34792                            if upload_url_from_server {
34793                                dlg.store_upload_url(Some(url_str));
34794                            }
34795
34796                            common::ResumableUploadHelper {
34797                                client: &self.hub.client,
34798                                delegate: dlg,
34799                                start_at: if upload_url_from_server {
34800                                    Some(0)
34801                                } else {
34802                                    None
34803                                },
34804                                auth: &self.hub.auth,
34805                                user_agent: &self.hub._user_agent,
34806                                // TODO: Check this assumption
34807                                auth_header: format!(
34808                                    "Bearer {}",
34809                                    token
34810                                        .ok_or_else(|| common::Error::MissingToken(
34811                                            "resumable upload requires token".into()
34812                                        ))?
34813                                        .as_str()
34814                                ),
34815                                url: url_str,
34816                                reader: &mut reader,
34817                                media_type: reader_mime_type.clone(),
34818                                content_length: size,
34819                            }
34820                            .upload()
34821                            .await
34822                        };
34823                        match upload_result {
34824                            None => {
34825                                dlg.finished(false);
34826                                return Err(common::Error::Cancelled);
34827                            }
34828                            Some(Err(err)) => {
34829                                dlg.finished(false);
34830                                return Err(common::Error::HttpError(err));
34831                            }
34832                            Some(Ok(response)) => {
34833                                (parts, body) = response.into_parts();
34834                                if !parts.status.is_success() {
34835                                    dlg.store_upload_url(None);
34836                                    dlg.finished(false);
34837                                    return Err(common::Error::Failure(
34838                                        common::Response::from_parts(parts, body),
34839                                    ));
34840                                }
34841                            }
34842                        }
34843                    }
34844                    let response = {
34845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
34846                        let encoded = common::to_string(&bytes);
34847                        match serde_json::from_str(&encoded) {
34848                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34849                            Err(error) => {
34850                                dlg.response_json_decode_error(&encoded, &error);
34851                                return Err(common::Error::JsonDecodeError(
34852                                    encoded.to_string(),
34853                                    error,
34854                                ));
34855                            }
34856                        }
34857                    };
34858
34859                    dlg.finished(true);
34860                    return Ok(response);
34861                }
34862            }
34863        }
34864    }
34865
34866    /// Upload media in a resumable fashion.
34867    /// Even if the upload fails or is interrupted, it can be resumed for a
34868    /// certain amount of time as the server maintains state temporarily.
34869    ///
34870    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
34871    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
34872    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
34873    /// `cancel_chunk_upload(...)`.
34874    ///
34875    /// * *multipart*: yes
34876    /// * *max size*: 1024MB
34877    /// * *valid mime types*: '*/*'
34878    pub async fn upload_resumable<RS>(
34879        self,
34880        resumeable_stream: RS,
34881        mime_type: mime::Mime,
34882    ) -> common::Result<(common::Response, CreativeAssetMetadata)>
34883    where
34884        RS: common::ReadSeek,
34885    {
34886        self.doit(
34887            resumeable_stream,
34888            mime_type,
34889            common::UploadProtocol::Resumable,
34890        )
34891        .await
34892    }
34893    /// Upload media all at once.
34894    /// If the upload fails for whichever reason, all progress is lost.
34895    ///
34896    /// * *multipart*: yes
34897    /// * *max size*: 1024MB
34898    /// * *valid mime types*: '*/*'
34899    pub async fn upload<RS>(
34900        self,
34901        stream: RS,
34902        mime_type: mime::Mime,
34903    ) -> common::Result<(common::Response, CreativeAssetMetadata)>
34904    where
34905        RS: common::ReadSeek,
34906    {
34907        self.doit(stream, mime_type, common::UploadProtocol::Simple)
34908            .await
34909    }
34910
34911    ///
34912    /// Sets the *request* property to the given value.
34913    ///
34914    /// Even though the property as already been set when instantiating this call,
34915    /// we provide this method for API completeness.
34916    pub fn request(mut self, new_value: CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, C> {
34917        self._request = new_value;
34918        self
34919    }
34920    /// User profile ID associated with this request.
34921    ///
34922    /// Sets the *profile id* path property to the given value.
34923    ///
34924    /// Even though the property as already been set when instantiating this call,
34925    /// we provide this method for API completeness.
34926    pub fn profile_id(mut self, new_value: i64) -> CreativeAssetInsertCall<'a, C> {
34927        self._profile_id = new_value;
34928        self
34929    }
34930    /// Advertiser ID of this creative. This is a required field.
34931    ///
34932    /// Sets the *advertiser id* path property to the given value.
34933    ///
34934    /// Even though the property as already been set when instantiating this call,
34935    /// we provide this method for API completeness.
34936    pub fn advertiser_id(mut self, new_value: i64) -> CreativeAssetInsertCall<'a, C> {
34937        self._advertiser_id = new_value;
34938        self
34939    }
34940    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34941    /// while executing the actual API request.
34942    ///
34943    /// ````text
34944    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
34945    /// ````
34946    ///
34947    /// Sets the *delegate* property to the given value.
34948    pub fn delegate(
34949        mut self,
34950        new_value: &'a mut dyn common::Delegate,
34951    ) -> CreativeAssetInsertCall<'a, C> {
34952        self._delegate = Some(new_value);
34953        self
34954    }
34955
34956    /// Set any additional parameter of the query string used in the request.
34957    /// It should be used to set parameters which are not yet available through their own
34958    /// setters.
34959    ///
34960    /// Please note that this method must not be used to set any of the known parameters
34961    /// which have their own setter method. If done anyway, the request will fail.
34962    ///
34963    /// # Additional Parameters
34964    ///
34965    /// * *alt* (query-string) - Data format for the response.
34966    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34967    /// * *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.
34968    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34969    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34970    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
34971    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
34972    pub fn param<T>(mut self, name: T, value: T) -> CreativeAssetInsertCall<'a, C>
34973    where
34974        T: AsRef<str>,
34975    {
34976        self._additional_params
34977            .insert(name.as_ref().to_string(), value.as_ref().to_string());
34978        self
34979    }
34980
34981    /// Identifies the authorization scope for the method you are building.
34982    ///
34983    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34984    /// [`Scope::Dfatrafficking`].
34985    ///
34986    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34987    /// tokens for more than one scope.
34988    ///
34989    /// Usually there is more than one suitable scope to authorize an operation, some of which may
34990    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34991    /// sufficient, a read-write scope will do as well.
34992    pub fn add_scope<St>(mut self, scope: St) -> CreativeAssetInsertCall<'a, C>
34993    where
34994        St: AsRef<str>,
34995    {
34996        self._scopes.insert(String::from(scope.as_ref()));
34997        self
34998    }
34999    /// Identifies the authorization scope(s) for the method you are building.
35000    ///
35001    /// See [`Self::add_scope()`] for details.
35002    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeAssetInsertCall<'a, C>
35003    where
35004        I: IntoIterator<Item = St>,
35005        St: AsRef<str>,
35006    {
35007        self._scopes
35008            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35009        self
35010    }
35011
35012    /// Removes all scopes, and no default scope will be used either.
35013    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35014    /// for details).
35015    pub fn clear_scopes(mut self) -> CreativeAssetInsertCall<'a, C> {
35016        self._scopes.clear();
35017        self
35018    }
35019}
35020
35021/// Deletes an existing creative field value.
35022///
35023/// A builder for the *delete* method supported by a *creativeFieldValue* resource.
35024/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
35025///
35026/// # Example
35027///
35028/// Instantiate a resource method builder
35029///
35030/// ```test_harness,no_run
35031/// # extern crate hyper;
35032/// # extern crate hyper_rustls;
35033/// # extern crate google_dfareporting3d2 as dfareporting3d2;
35034/// # async fn dox() {
35035/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35036///
35037/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35039/// #     secret,
35040/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35041/// # ).build().await.unwrap();
35042///
35043/// # let client = hyper_util::client::legacy::Client::builder(
35044/// #     hyper_util::rt::TokioExecutor::new()
35045/// # )
35046/// # .build(
35047/// #     hyper_rustls::HttpsConnectorBuilder::new()
35048/// #         .with_native_roots()
35049/// #         .unwrap()
35050/// #         .https_or_http()
35051/// #         .enable_http1()
35052/// #         .build()
35053/// # );
35054/// # let mut hub = Dfareporting::new(client, auth);
35055/// // You can configure optional parameters by calling the respective setters at will, and
35056/// // execute the final call using `doit()`.
35057/// // Values shown here are possibly random and not representative !
35058/// let result = hub.creative_field_values().delete(-39, -34, -25)
35059///              .doit().await;
35060/// # }
35061/// ```
35062pub struct CreativeFieldValueDeleteCall<'a, C>
35063where
35064    C: 'a,
35065{
35066    hub: &'a Dfareporting<C>,
35067    _profile_id: i64,
35068    _creative_field_id: i64,
35069    _id: i64,
35070    _delegate: Option<&'a mut dyn common::Delegate>,
35071    _additional_params: HashMap<String, String>,
35072    _scopes: BTreeSet<String>,
35073}
35074
35075impl<'a, C> common::CallBuilder for CreativeFieldValueDeleteCall<'a, C> {}
35076
35077impl<'a, C> CreativeFieldValueDeleteCall<'a, C>
35078where
35079    C: common::Connector,
35080{
35081    /// Perform the operation you have build so far.
35082    pub async fn doit(mut self) -> common::Result<common::Response> {
35083        use std::borrow::Cow;
35084        use std::io::{Read, Seek};
35085
35086        use common::{url::Params, ToParts};
35087        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35088
35089        let mut dd = common::DefaultDelegate;
35090        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35091        dlg.begin(common::MethodInfo {
35092            id: "dfareporting.creativeFieldValues.delete",
35093            http_method: hyper::Method::DELETE,
35094        });
35095
35096        for &field in ["profileId", "creativeFieldId", "id"].iter() {
35097            if self._additional_params.contains_key(field) {
35098                dlg.finished(false);
35099                return Err(common::Error::FieldClash(field));
35100            }
35101        }
35102
35103        let mut params = Params::with_capacity(4 + self._additional_params.len());
35104        params.push("profileId", self._profile_id.to_string());
35105        params.push("creativeFieldId", self._creative_field_id.to_string());
35106        params.push("id", self._id.to_string());
35107
35108        params.extend(self._additional_params.iter());
35109
35110        let mut url = self.hub._base_url.clone()
35111            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}";
35112        if self._scopes.is_empty() {
35113            self._scopes
35114                .insert(Scope::Dfatrafficking.as_ref().to_string());
35115        }
35116
35117        #[allow(clippy::single_element_loop)]
35118        for &(find_this, param_name) in [
35119            ("{profileId}", "profileId"),
35120            ("{creativeFieldId}", "creativeFieldId"),
35121            ("{id}", "id"),
35122        ]
35123        .iter()
35124        {
35125            url = params.uri_replacement(url, param_name, find_this, false);
35126        }
35127        {
35128            let to_remove = ["id", "creativeFieldId", "profileId"];
35129            params.remove_params(&to_remove);
35130        }
35131
35132        let url = params.parse_with_url(&url);
35133
35134        loop {
35135            let token = match self
35136                .hub
35137                .auth
35138                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35139                .await
35140            {
35141                Ok(token) => token,
35142                Err(e) => match dlg.token(e) {
35143                    Ok(token) => token,
35144                    Err(e) => {
35145                        dlg.finished(false);
35146                        return Err(common::Error::MissingToken(e));
35147                    }
35148                },
35149            };
35150            let mut req_result = {
35151                let client = &self.hub.client;
35152                dlg.pre_request();
35153                let mut req_builder = hyper::Request::builder()
35154                    .method(hyper::Method::DELETE)
35155                    .uri(url.as_str())
35156                    .header(USER_AGENT, self.hub._user_agent.clone());
35157
35158                if let Some(token) = token.as_ref() {
35159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35160                }
35161
35162                let request = req_builder
35163                    .header(CONTENT_LENGTH, 0_u64)
35164                    .body(common::to_body::<String>(None));
35165
35166                client.request(request.unwrap()).await
35167            };
35168
35169            match req_result {
35170                Err(err) => {
35171                    if let common::Retry::After(d) = dlg.http_error(&err) {
35172                        sleep(d).await;
35173                        continue;
35174                    }
35175                    dlg.finished(false);
35176                    return Err(common::Error::HttpError(err));
35177                }
35178                Ok(res) => {
35179                    let (mut parts, body) = res.into_parts();
35180                    let mut body = common::Body::new(body);
35181                    if !parts.status.is_success() {
35182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35183                        let error = serde_json::from_str(&common::to_string(&bytes));
35184                        let response = common::to_response(parts, bytes.into());
35185
35186                        if let common::Retry::After(d) =
35187                            dlg.http_failure(&response, error.as_ref().ok())
35188                        {
35189                            sleep(d).await;
35190                            continue;
35191                        }
35192
35193                        dlg.finished(false);
35194
35195                        return Err(match error {
35196                            Ok(value) => common::Error::BadRequest(value),
35197                            _ => common::Error::Failure(response),
35198                        });
35199                    }
35200                    let response = common::Response::from_parts(parts, body);
35201
35202                    dlg.finished(true);
35203                    return Ok(response);
35204                }
35205            }
35206        }
35207    }
35208
35209    /// User profile ID associated with this request.
35210    ///
35211    /// Sets the *profile id* path property to the given value.
35212    ///
35213    /// Even though the property as already been set when instantiating this call,
35214    /// we provide this method for API completeness.
35215    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValueDeleteCall<'a, C> {
35216        self._profile_id = new_value;
35217        self
35218    }
35219    /// Creative field ID for this creative field value.
35220    ///
35221    /// Sets the *creative field id* path property to the given value.
35222    ///
35223    /// Even though the property as already been set when instantiating this call,
35224    /// we provide this method for API completeness.
35225    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValueDeleteCall<'a, C> {
35226        self._creative_field_id = new_value;
35227        self
35228    }
35229    /// Creative Field Value ID
35230    ///
35231    /// Sets the *id* path property to the given value.
35232    ///
35233    /// Even though the property as already been set when instantiating this call,
35234    /// we provide this method for API completeness.
35235    pub fn id(mut self, new_value: i64) -> CreativeFieldValueDeleteCall<'a, C> {
35236        self._id = new_value;
35237        self
35238    }
35239    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35240    /// while executing the actual API request.
35241    ///
35242    /// ````text
35243    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35244    /// ````
35245    ///
35246    /// Sets the *delegate* property to the given value.
35247    pub fn delegate(
35248        mut self,
35249        new_value: &'a mut dyn common::Delegate,
35250    ) -> CreativeFieldValueDeleteCall<'a, C> {
35251        self._delegate = Some(new_value);
35252        self
35253    }
35254
35255    /// Set any additional parameter of the query string used in the request.
35256    /// It should be used to set parameters which are not yet available through their own
35257    /// setters.
35258    ///
35259    /// Please note that this method must not be used to set any of the known parameters
35260    /// which have their own setter method. If done anyway, the request will fail.
35261    ///
35262    /// # Additional Parameters
35263    ///
35264    /// * *alt* (query-string) - Data format for the response.
35265    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35266    /// * *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.
35267    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35268    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35269    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35270    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35271    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueDeleteCall<'a, C>
35272    where
35273        T: AsRef<str>,
35274    {
35275        self._additional_params
35276            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35277        self
35278    }
35279
35280    /// Identifies the authorization scope for the method you are building.
35281    ///
35282    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35283    /// [`Scope::Dfatrafficking`].
35284    ///
35285    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35286    /// tokens for more than one scope.
35287    ///
35288    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35289    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35290    /// sufficient, a read-write scope will do as well.
35291    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValueDeleteCall<'a, C>
35292    where
35293        St: AsRef<str>,
35294    {
35295        self._scopes.insert(String::from(scope.as_ref()));
35296        self
35297    }
35298    /// Identifies the authorization scope(s) for the method you are building.
35299    ///
35300    /// See [`Self::add_scope()`] for details.
35301    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValueDeleteCall<'a, C>
35302    where
35303        I: IntoIterator<Item = St>,
35304        St: AsRef<str>,
35305    {
35306        self._scopes
35307            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35308        self
35309    }
35310
35311    /// Removes all scopes, and no default scope will be used either.
35312    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35313    /// for details).
35314    pub fn clear_scopes(mut self) -> CreativeFieldValueDeleteCall<'a, C> {
35315        self._scopes.clear();
35316        self
35317    }
35318}
35319
35320/// Gets one creative field value by ID.
35321///
35322/// A builder for the *get* method supported by a *creativeFieldValue* resource.
35323/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
35324///
35325/// # Example
35326///
35327/// Instantiate a resource method builder
35328///
35329/// ```test_harness,no_run
35330/// # extern crate hyper;
35331/// # extern crate hyper_rustls;
35332/// # extern crate google_dfareporting3d2 as dfareporting3d2;
35333/// # async fn dox() {
35334/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35335///
35336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35338/// #     secret,
35339/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35340/// # ).build().await.unwrap();
35341///
35342/// # let client = hyper_util::client::legacy::Client::builder(
35343/// #     hyper_util::rt::TokioExecutor::new()
35344/// # )
35345/// # .build(
35346/// #     hyper_rustls::HttpsConnectorBuilder::new()
35347/// #         .with_native_roots()
35348/// #         .unwrap()
35349/// #         .https_or_http()
35350/// #         .enable_http1()
35351/// #         .build()
35352/// # );
35353/// # let mut hub = Dfareporting::new(client, auth);
35354/// // You can configure optional parameters by calling the respective setters at will, and
35355/// // execute the final call using `doit()`.
35356/// // Values shown here are possibly random and not representative !
35357/// let result = hub.creative_field_values().get(-52, -84, -97)
35358///              .doit().await;
35359/// # }
35360/// ```
35361pub struct CreativeFieldValueGetCall<'a, C>
35362where
35363    C: 'a,
35364{
35365    hub: &'a Dfareporting<C>,
35366    _profile_id: i64,
35367    _creative_field_id: i64,
35368    _id: i64,
35369    _delegate: Option<&'a mut dyn common::Delegate>,
35370    _additional_params: HashMap<String, String>,
35371    _scopes: BTreeSet<String>,
35372}
35373
35374impl<'a, C> common::CallBuilder for CreativeFieldValueGetCall<'a, C> {}
35375
35376impl<'a, C> CreativeFieldValueGetCall<'a, C>
35377where
35378    C: common::Connector,
35379{
35380    /// Perform the operation you have build so far.
35381    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeFieldValue)> {
35382        use std::borrow::Cow;
35383        use std::io::{Read, Seek};
35384
35385        use common::{url::Params, ToParts};
35386        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35387
35388        let mut dd = common::DefaultDelegate;
35389        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35390        dlg.begin(common::MethodInfo {
35391            id: "dfareporting.creativeFieldValues.get",
35392            http_method: hyper::Method::GET,
35393        });
35394
35395        for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() {
35396            if self._additional_params.contains_key(field) {
35397                dlg.finished(false);
35398                return Err(common::Error::FieldClash(field));
35399            }
35400        }
35401
35402        let mut params = Params::with_capacity(5 + self._additional_params.len());
35403        params.push("profileId", self._profile_id.to_string());
35404        params.push("creativeFieldId", self._creative_field_id.to_string());
35405        params.push("id", self._id.to_string());
35406
35407        params.extend(self._additional_params.iter());
35408
35409        params.push("alt", "json");
35410        let mut url = self.hub._base_url.clone()
35411            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}";
35412        if self._scopes.is_empty() {
35413            self._scopes
35414                .insert(Scope::Dfatrafficking.as_ref().to_string());
35415        }
35416
35417        #[allow(clippy::single_element_loop)]
35418        for &(find_this, param_name) in [
35419            ("{profileId}", "profileId"),
35420            ("{creativeFieldId}", "creativeFieldId"),
35421            ("{id}", "id"),
35422        ]
35423        .iter()
35424        {
35425            url = params.uri_replacement(url, param_name, find_this, false);
35426        }
35427        {
35428            let to_remove = ["id", "creativeFieldId", "profileId"];
35429            params.remove_params(&to_remove);
35430        }
35431
35432        let url = params.parse_with_url(&url);
35433
35434        loop {
35435            let token = match self
35436                .hub
35437                .auth
35438                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35439                .await
35440            {
35441                Ok(token) => token,
35442                Err(e) => match dlg.token(e) {
35443                    Ok(token) => token,
35444                    Err(e) => {
35445                        dlg.finished(false);
35446                        return Err(common::Error::MissingToken(e));
35447                    }
35448                },
35449            };
35450            let mut req_result = {
35451                let client = &self.hub.client;
35452                dlg.pre_request();
35453                let mut req_builder = hyper::Request::builder()
35454                    .method(hyper::Method::GET)
35455                    .uri(url.as_str())
35456                    .header(USER_AGENT, self.hub._user_agent.clone());
35457
35458                if let Some(token) = token.as_ref() {
35459                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35460                }
35461
35462                let request = req_builder
35463                    .header(CONTENT_LENGTH, 0_u64)
35464                    .body(common::to_body::<String>(None));
35465
35466                client.request(request.unwrap()).await
35467            };
35468
35469            match req_result {
35470                Err(err) => {
35471                    if let common::Retry::After(d) = dlg.http_error(&err) {
35472                        sleep(d).await;
35473                        continue;
35474                    }
35475                    dlg.finished(false);
35476                    return Err(common::Error::HttpError(err));
35477                }
35478                Ok(res) => {
35479                    let (mut parts, body) = res.into_parts();
35480                    let mut body = common::Body::new(body);
35481                    if !parts.status.is_success() {
35482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35483                        let error = serde_json::from_str(&common::to_string(&bytes));
35484                        let response = common::to_response(parts, bytes.into());
35485
35486                        if let common::Retry::After(d) =
35487                            dlg.http_failure(&response, error.as_ref().ok())
35488                        {
35489                            sleep(d).await;
35490                            continue;
35491                        }
35492
35493                        dlg.finished(false);
35494
35495                        return Err(match error {
35496                            Ok(value) => common::Error::BadRequest(value),
35497                            _ => common::Error::Failure(response),
35498                        });
35499                    }
35500                    let response = {
35501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35502                        let encoded = common::to_string(&bytes);
35503                        match serde_json::from_str(&encoded) {
35504                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35505                            Err(error) => {
35506                                dlg.response_json_decode_error(&encoded, &error);
35507                                return Err(common::Error::JsonDecodeError(
35508                                    encoded.to_string(),
35509                                    error,
35510                                ));
35511                            }
35512                        }
35513                    };
35514
35515                    dlg.finished(true);
35516                    return Ok(response);
35517                }
35518            }
35519        }
35520    }
35521
35522    /// User profile ID associated with this request.
35523    ///
35524    /// Sets the *profile id* path property to the given value.
35525    ///
35526    /// Even though the property as already been set when instantiating this call,
35527    /// we provide this method for API completeness.
35528    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValueGetCall<'a, C> {
35529        self._profile_id = new_value;
35530        self
35531    }
35532    /// Creative field ID for this creative field value.
35533    ///
35534    /// Sets the *creative field id* path property to the given value.
35535    ///
35536    /// Even though the property as already been set when instantiating this call,
35537    /// we provide this method for API completeness.
35538    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValueGetCall<'a, C> {
35539        self._creative_field_id = new_value;
35540        self
35541    }
35542    /// Creative Field Value ID
35543    ///
35544    /// Sets the *id* path property to the given value.
35545    ///
35546    /// Even though the property as already been set when instantiating this call,
35547    /// we provide this method for API completeness.
35548    pub fn id(mut self, new_value: i64) -> CreativeFieldValueGetCall<'a, C> {
35549        self._id = new_value;
35550        self
35551    }
35552    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35553    /// while executing the actual API request.
35554    ///
35555    /// ````text
35556    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35557    /// ````
35558    ///
35559    /// Sets the *delegate* property to the given value.
35560    pub fn delegate(
35561        mut self,
35562        new_value: &'a mut dyn common::Delegate,
35563    ) -> CreativeFieldValueGetCall<'a, C> {
35564        self._delegate = Some(new_value);
35565        self
35566    }
35567
35568    /// Set any additional parameter of the query string used in the request.
35569    /// It should be used to set parameters which are not yet available through their own
35570    /// setters.
35571    ///
35572    /// Please note that this method must not be used to set any of the known parameters
35573    /// which have their own setter method. If done anyway, the request will fail.
35574    ///
35575    /// # Additional Parameters
35576    ///
35577    /// * *alt* (query-string) - Data format for the response.
35578    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35579    /// * *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.
35580    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35581    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35582    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35583    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35584    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueGetCall<'a, C>
35585    where
35586        T: AsRef<str>,
35587    {
35588        self._additional_params
35589            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35590        self
35591    }
35592
35593    /// Identifies the authorization scope for the method you are building.
35594    ///
35595    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35596    /// [`Scope::Dfatrafficking`].
35597    ///
35598    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35599    /// tokens for more than one scope.
35600    ///
35601    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35602    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35603    /// sufficient, a read-write scope will do as well.
35604    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValueGetCall<'a, C>
35605    where
35606        St: AsRef<str>,
35607    {
35608        self._scopes.insert(String::from(scope.as_ref()));
35609        self
35610    }
35611    /// Identifies the authorization scope(s) for the method you are building.
35612    ///
35613    /// See [`Self::add_scope()`] for details.
35614    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValueGetCall<'a, C>
35615    where
35616        I: IntoIterator<Item = St>,
35617        St: AsRef<str>,
35618    {
35619        self._scopes
35620            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35621        self
35622    }
35623
35624    /// Removes all scopes, and no default scope will be used either.
35625    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35626    /// for details).
35627    pub fn clear_scopes(mut self) -> CreativeFieldValueGetCall<'a, C> {
35628        self._scopes.clear();
35629        self
35630    }
35631}
35632
35633/// Inserts a new creative field value.
35634///
35635/// A builder for the *insert* method supported by a *creativeFieldValue* resource.
35636/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
35637///
35638/// # Example
35639///
35640/// Instantiate a resource method builder
35641///
35642/// ```test_harness,no_run
35643/// # extern crate hyper;
35644/// # extern crate hyper_rustls;
35645/// # extern crate google_dfareporting3d2 as dfareporting3d2;
35646/// use dfareporting3d2::api::CreativeFieldValue;
35647/// # async fn dox() {
35648/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35649///
35650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35652/// #     secret,
35653/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35654/// # ).build().await.unwrap();
35655///
35656/// # let client = hyper_util::client::legacy::Client::builder(
35657/// #     hyper_util::rt::TokioExecutor::new()
35658/// # )
35659/// # .build(
35660/// #     hyper_rustls::HttpsConnectorBuilder::new()
35661/// #         .with_native_roots()
35662/// #         .unwrap()
35663/// #         .https_or_http()
35664/// #         .enable_http1()
35665/// #         .build()
35666/// # );
35667/// # let mut hub = Dfareporting::new(client, auth);
35668/// // As the method needs a request, you would usually fill it with the desired information
35669/// // into the respective structure. Some of the parts shown here might not be applicable !
35670/// // Values shown here are possibly random and not representative !
35671/// let mut req = CreativeFieldValue::default();
35672///
35673/// // You can configure optional parameters by calling the respective setters at will, and
35674/// // execute the final call using `doit()`.
35675/// // Values shown here are possibly random and not representative !
35676/// let result = hub.creative_field_values().insert(req, -37, -27)
35677///              .doit().await;
35678/// # }
35679/// ```
35680pub struct CreativeFieldValueInsertCall<'a, C>
35681where
35682    C: 'a,
35683{
35684    hub: &'a Dfareporting<C>,
35685    _request: CreativeFieldValue,
35686    _profile_id: i64,
35687    _creative_field_id: i64,
35688    _delegate: Option<&'a mut dyn common::Delegate>,
35689    _additional_params: HashMap<String, String>,
35690    _scopes: BTreeSet<String>,
35691}
35692
35693impl<'a, C> common::CallBuilder for CreativeFieldValueInsertCall<'a, C> {}
35694
35695impl<'a, C> CreativeFieldValueInsertCall<'a, C>
35696where
35697    C: common::Connector,
35698{
35699    /// Perform the operation you have build so far.
35700    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeFieldValue)> {
35701        use std::borrow::Cow;
35702        use std::io::{Read, Seek};
35703
35704        use common::{url::Params, ToParts};
35705        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35706
35707        let mut dd = common::DefaultDelegate;
35708        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35709        dlg.begin(common::MethodInfo {
35710            id: "dfareporting.creativeFieldValues.insert",
35711            http_method: hyper::Method::POST,
35712        });
35713
35714        for &field in ["alt", "profileId", "creativeFieldId"].iter() {
35715            if self._additional_params.contains_key(field) {
35716                dlg.finished(false);
35717                return Err(common::Error::FieldClash(field));
35718            }
35719        }
35720
35721        let mut params = Params::with_capacity(5 + self._additional_params.len());
35722        params.push("profileId", self._profile_id.to_string());
35723        params.push("creativeFieldId", self._creative_field_id.to_string());
35724
35725        params.extend(self._additional_params.iter());
35726
35727        params.push("alt", "json");
35728        let mut url = self.hub._base_url.clone()
35729            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues";
35730        if self._scopes.is_empty() {
35731            self._scopes
35732                .insert(Scope::Dfatrafficking.as_ref().to_string());
35733        }
35734
35735        #[allow(clippy::single_element_loop)]
35736        for &(find_this, param_name) in [
35737            ("{profileId}", "profileId"),
35738            ("{creativeFieldId}", "creativeFieldId"),
35739        ]
35740        .iter()
35741        {
35742            url = params.uri_replacement(url, param_name, find_this, false);
35743        }
35744        {
35745            let to_remove = ["creativeFieldId", "profileId"];
35746            params.remove_params(&to_remove);
35747        }
35748
35749        let url = params.parse_with_url(&url);
35750
35751        let mut json_mime_type = mime::APPLICATION_JSON;
35752        let mut request_value_reader = {
35753            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
35754            common::remove_json_null_values(&mut value);
35755            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
35756            serde_json::to_writer(&mut dst, &value).unwrap();
35757            dst
35758        };
35759        let request_size = request_value_reader
35760            .seek(std::io::SeekFrom::End(0))
35761            .unwrap();
35762        request_value_reader
35763            .seek(std::io::SeekFrom::Start(0))
35764            .unwrap();
35765
35766        loop {
35767            let token = match self
35768                .hub
35769                .auth
35770                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35771                .await
35772            {
35773                Ok(token) => token,
35774                Err(e) => match dlg.token(e) {
35775                    Ok(token) => token,
35776                    Err(e) => {
35777                        dlg.finished(false);
35778                        return Err(common::Error::MissingToken(e));
35779                    }
35780                },
35781            };
35782            request_value_reader
35783                .seek(std::io::SeekFrom::Start(0))
35784                .unwrap();
35785            let mut req_result = {
35786                let client = &self.hub.client;
35787                dlg.pre_request();
35788                let mut req_builder = hyper::Request::builder()
35789                    .method(hyper::Method::POST)
35790                    .uri(url.as_str())
35791                    .header(USER_AGENT, self.hub._user_agent.clone());
35792
35793                if let Some(token) = token.as_ref() {
35794                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35795                }
35796
35797                let request = req_builder
35798                    .header(CONTENT_TYPE, json_mime_type.to_string())
35799                    .header(CONTENT_LENGTH, request_size as u64)
35800                    .body(common::to_body(
35801                        request_value_reader.get_ref().clone().into(),
35802                    ));
35803
35804                client.request(request.unwrap()).await
35805            };
35806
35807            match req_result {
35808                Err(err) => {
35809                    if let common::Retry::After(d) = dlg.http_error(&err) {
35810                        sleep(d).await;
35811                        continue;
35812                    }
35813                    dlg.finished(false);
35814                    return Err(common::Error::HttpError(err));
35815                }
35816                Ok(res) => {
35817                    let (mut parts, body) = res.into_parts();
35818                    let mut body = common::Body::new(body);
35819                    if !parts.status.is_success() {
35820                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35821                        let error = serde_json::from_str(&common::to_string(&bytes));
35822                        let response = common::to_response(parts, bytes.into());
35823
35824                        if let common::Retry::After(d) =
35825                            dlg.http_failure(&response, error.as_ref().ok())
35826                        {
35827                            sleep(d).await;
35828                            continue;
35829                        }
35830
35831                        dlg.finished(false);
35832
35833                        return Err(match error {
35834                            Ok(value) => common::Error::BadRequest(value),
35835                            _ => common::Error::Failure(response),
35836                        });
35837                    }
35838                    let response = {
35839                        let bytes = common::to_bytes(body).await.unwrap_or_default();
35840                        let encoded = common::to_string(&bytes);
35841                        match serde_json::from_str(&encoded) {
35842                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35843                            Err(error) => {
35844                                dlg.response_json_decode_error(&encoded, &error);
35845                                return Err(common::Error::JsonDecodeError(
35846                                    encoded.to_string(),
35847                                    error,
35848                                ));
35849                            }
35850                        }
35851                    };
35852
35853                    dlg.finished(true);
35854                    return Ok(response);
35855                }
35856            }
35857        }
35858    }
35859
35860    ///
35861    /// Sets the *request* property to the given value.
35862    ///
35863    /// Even though the property as already been set when instantiating this call,
35864    /// we provide this method for API completeness.
35865    pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, C> {
35866        self._request = new_value;
35867        self
35868    }
35869    /// User profile ID associated with this request.
35870    ///
35871    /// Sets the *profile id* path property to the given value.
35872    ///
35873    /// Even though the property as already been set when instantiating this call,
35874    /// we provide this method for API completeness.
35875    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValueInsertCall<'a, C> {
35876        self._profile_id = new_value;
35877        self
35878    }
35879    /// Creative field ID for this creative field value.
35880    ///
35881    /// Sets the *creative field id* path property to the given value.
35882    ///
35883    /// Even though the property as already been set when instantiating this call,
35884    /// we provide this method for API completeness.
35885    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValueInsertCall<'a, C> {
35886        self._creative_field_id = new_value;
35887        self
35888    }
35889    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35890    /// while executing the actual API request.
35891    ///
35892    /// ````text
35893    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
35894    /// ````
35895    ///
35896    /// Sets the *delegate* property to the given value.
35897    pub fn delegate(
35898        mut self,
35899        new_value: &'a mut dyn common::Delegate,
35900    ) -> CreativeFieldValueInsertCall<'a, C> {
35901        self._delegate = Some(new_value);
35902        self
35903    }
35904
35905    /// Set any additional parameter of the query string used in the request.
35906    /// It should be used to set parameters which are not yet available through their own
35907    /// setters.
35908    ///
35909    /// Please note that this method must not be used to set any of the known parameters
35910    /// which have their own setter method. If done anyway, the request will fail.
35911    ///
35912    /// # Additional Parameters
35913    ///
35914    /// * *alt* (query-string) - Data format for the response.
35915    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35916    /// * *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.
35917    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35918    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35919    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
35920    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
35921    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueInsertCall<'a, C>
35922    where
35923        T: AsRef<str>,
35924    {
35925        self._additional_params
35926            .insert(name.as_ref().to_string(), value.as_ref().to_string());
35927        self
35928    }
35929
35930    /// Identifies the authorization scope for the method you are building.
35931    ///
35932    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35933    /// [`Scope::Dfatrafficking`].
35934    ///
35935    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35936    /// tokens for more than one scope.
35937    ///
35938    /// Usually there is more than one suitable scope to authorize an operation, some of which may
35939    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35940    /// sufficient, a read-write scope will do as well.
35941    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValueInsertCall<'a, C>
35942    where
35943        St: AsRef<str>,
35944    {
35945        self._scopes.insert(String::from(scope.as_ref()));
35946        self
35947    }
35948    /// Identifies the authorization scope(s) for the method you are building.
35949    ///
35950    /// See [`Self::add_scope()`] for details.
35951    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValueInsertCall<'a, C>
35952    where
35953        I: IntoIterator<Item = St>,
35954        St: AsRef<str>,
35955    {
35956        self._scopes
35957            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35958        self
35959    }
35960
35961    /// Removes all scopes, and no default scope will be used either.
35962    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35963    /// for details).
35964    pub fn clear_scopes(mut self) -> CreativeFieldValueInsertCall<'a, C> {
35965        self._scopes.clear();
35966        self
35967    }
35968}
35969
35970/// Retrieves a list of creative field values, possibly filtered. This method supports paging.
35971///
35972/// A builder for the *list* method supported by a *creativeFieldValue* resource.
35973/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
35974///
35975/// # Example
35976///
35977/// Instantiate a resource method builder
35978///
35979/// ```test_harness,no_run
35980/// # extern crate hyper;
35981/// # extern crate hyper_rustls;
35982/// # extern crate google_dfareporting3d2 as dfareporting3d2;
35983/// # async fn dox() {
35984/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35985///
35986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
35988/// #     secret,
35989/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35990/// # ).build().await.unwrap();
35991///
35992/// # let client = hyper_util::client::legacy::Client::builder(
35993/// #     hyper_util::rt::TokioExecutor::new()
35994/// # )
35995/// # .build(
35996/// #     hyper_rustls::HttpsConnectorBuilder::new()
35997/// #         .with_native_roots()
35998/// #         .unwrap()
35999/// #         .https_or_http()
36000/// #         .enable_http1()
36001/// #         .build()
36002/// # );
36003/// # let mut hub = Dfareporting::new(client, auth);
36004/// // You can configure optional parameters by calling the respective setters at will, and
36005/// // execute the final call using `doit()`.
36006/// // Values shown here are possibly random and not representative !
36007/// let result = hub.creative_field_values().list(-53, -76)
36008///              .sort_order("duo")
36009///              .sort_field("sadipscing")
36010///              .search_string("ut")
36011///              .page_token("rebum.")
36012///              .max_results(-70)
36013///              .add_ids(-63)
36014///              .doit().await;
36015/// # }
36016/// ```
36017pub struct CreativeFieldValueListCall<'a, C>
36018where
36019    C: 'a,
36020{
36021    hub: &'a Dfareporting<C>,
36022    _profile_id: i64,
36023    _creative_field_id: i64,
36024    _sort_order: Option<String>,
36025    _sort_field: Option<String>,
36026    _search_string: Option<String>,
36027    _page_token: Option<String>,
36028    _max_results: Option<i32>,
36029    _ids: Vec<i64>,
36030    _delegate: Option<&'a mut dyn common::Delegate>,
36031    _additional_params: HashMap<String, String>,
36032    _scopes: BTreeSet<String>,
36033}
36034
36035impl<'a, C> common::CallBuilder for CreativeFieldValueListCall<'a, C> {}
36036
36037impl<'a, C> CreativeFieldValueListCall<'a, C>
36038where
36039    C: common::Connector,
36040{
36041    /// Perform the operation you have build so far.
36042    pub async fn doit(
36043        mut self,
36044    ) -> common::Result<(common::Response, CreativeFieldValuesListResponse)> {
36045        use std::borrow::Cow;
36046        use std::io::{Read, Seek};
36047
36048        use common::{url::Params, ToParts};
36049        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36050
36051        let mut dd = common::DefaultDelegate;
36052        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36053        dlg.begin(common::MethodInfo {
36054            id: "dfareporting.creativeFieldValues.list",
36055            http_method: hyper::Method::GET,
36056        });
36057
36058        for &field in [
36059            "alt",
36060            "profileId",
36061            "creativeFieldId",
36062            "sortOrder",
36063            "sortField",
36064            "searchString",
36065            "pageToken",
36066            "maxResults",
36067            "ids",
36068        ]
36069        .iter()
36070        {
36071            if self._additional_params.contains_key(field) {
36072                dlg.finished(false);
36073                return Err(common::Error::FieldClash(field));
36074            }
36075        }
36076
36077        let mut params = Params::with_capacity(10 + self._additional_params.len());
36078        params.push("profileId", self._profile_id.to_string());
36079        params.push("creativeFieldId", self._creative_field_id.to_string());
36080        if let Some(value) = self._sort_order.as_ref() {
36081            params.push("sortOrder", value);
36082        }
36083        if let Some(value) = self._sort_field.as_ref() {
36084            params.push("sortField", value);
36085        }
36086        if let Some(value) = self._search_string.as_ref() {
36087            params.push("searchString", value);
36088        }
36089        if let Some(value) = self._page_token.as_ref() {
36090            params.push("pageToken", value);
36091        }
36092        if let Some(value) = self._max_results.as_ref() {
36093            params.push("maxResults", value.to_string());
36094        }
36095        if !self._ids.is_empty() {
36096            for f in self._ids.iter() {
36097                params.push("ids", f.to_string());
36098            }
36099        }
36100
36101        params.extend(self._additional_params.iter());
36102
36103        params.push("alt", "json");
36104        let mut url = self.hub._base_url.clone()
36105            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues";
36106        if self._scopes.is_empty() {
36107            self._scopes
36108                .insert(Scope::Dfatrafficking.as_ref().to_string());
36109        }
36110
36111        #[allow(clippy::single_element_loop)]
36112        for &(find_this, param_name) in [
36113            ("{profileId}", "profileId"),
36114            ("{creativeFieldId}", "creativeFieldId"),
36115        ]
36116        .iter()
36117        {
36118            url = params.uri_replacement(url, param_name, find_this, false);
36119        }
36120        {
36121            let to_remove = ["creativeFieldId", "profileId"];
36122            params.remove_params(&to_remove);
36123        }
36124
36125        let url = params.parse_with_url(&url);
36126
36127        loop {
36128            let token = match self
36129                .hub
36130                .auth
36131                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36132                .await
36133            {
36134                Ok(token) => token,
36135                Err(e) => match dlg.token(e) {
36136                    Ok(token) => token,
36137                    Err(e) => {
36138                        dlg.finished(false);
36139                        return Err(common::Error::MissingToken(e));
36140                    }
36141                },
36142            };
36143            let mut req_result = {
36144                let client = &self.hub.client;
36145                dlg.pre_request();
36146                let mut req_builder = hyper::Request::builder()
36147                    .method(hyper::Method::GET)
36148                    .uri(url.as_str())
36149                    .header(USER_AGENT, self.hub._user_agent.clone());
36150
36151                if let Some(token) = token.as_ref() {
36152                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36153                }
36154
36155                let request = req_builder
36156                    .header(CONTENT_LENGTH, 0_u64)
36157                    .body(common::to_body::<String>(None));
36158
36159                client.request(request.unwrap()).await
36160            };
36161
36162            match req_result {
36163                Err(err) => {
36164                    if let common::Retry::After(d) = dlg.http_error(&err) {
36165                        sleep(d).await;
36166                        continue;
36167                    }
36168                    dlg.finished(false);
36169                    return Err(common::Error::HttpError(err));
36170                }
36171                Ok(res) => {
36172                    let (mut parts, body) = res.into_parts();
36173                    let mut body = common::Body::new(body);
36174                    if !parts.status.is_success() {
36175                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36176                        let error = serde_json::from_str(&common::to_string(&bytes));
36177                        let response = common::to_response(parts, bytes.into());
36178
36179                        if let common::Retry::After(d) =
36180                            dlg.http_failure(&response, error.as_ref().ok())
36181                        {
36182                            sleep(d).await;
36183                            continue;
36184                        }
36185
36186                        dlg.finished(false);
36187
36188                        return Err(match error {
36189                            Ok(value) => common::Error::BadRequest(value),
36190                            _ => common::Error::Failure(response),
36191                        });
36192                    }
36193                    let response = {
36194                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36195                        let encoded = common::to_string(&bytes);
36196                        match serde_json::from_str(&encoded) {
36197                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36198                            Err(error) => {
36199                                dlg.response_json_decode_error(&encoded, &error);
36200                                return Err(common::Error::JsonDecodeError(
36201                                    encoded.to_string(),
36202                                    error,
36203                                ));
36204                            }
36205                        }
36206                    };
36207
36208                    dlg.finished(true);
36209                    return Ok(response);
36210                }
36211            }
36212        }
36213    }
36214
36215    /// User profile ID associated with this request.
36216    ///
36217    /// Sets the *profile id* path property to the given value.
36218    ///
36219    /// Even though the property as already been set when instantiating this call,
36220    /// we provide this method for API completeness.
36221    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValueListCall<'a, C> {
36222        self._profile_id = new_value;
36223        self
36224    }
36225    /// Creative field ID for this creative field value.
36226    ///
36227    /// Sets the *creative field id* path property to the given value.
36228    ///
36229    /// Even though the property as already been set when instantiating this call,
36230    /// we provide this method for API completeness.
36231    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValueListCall<'a, C> {
36232        self._creative_field_id = new_value;
36233        self
36234    }
36235    /// Order of sorted results.
36236    ///
36237    /// Sets the *sort order* query property to the given value.
36238    pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C> {
36239        self._sort_order = Some(new_value.to_string());
36240        self
36241    }
36242    /// Field by which to sort the list.
36243    ///
36244    /// Sets the *sort field* query property to the given value.
36245    pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C> {
36246        self._sort_field = Some(new_value.to_string());
36247        self
36248    }
36249    /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed.
36250    ///
36251    /// Sets the *search string* query property to the given value.
36252    pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C> {
36253        self._search_string = Some(new_value.to_string());
36254        self
36255    }
36256    /// Value of the nextPageToken from the previous result page.
36257    ///
36258    /// Sets the *page token* query property to the given value.
36259    pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, C> {
36260        self._page_token = Some(new_value.to_string());
36261        self
36262    }
36263    /// Maximum number of results to return.
36264    ///
36265    /// Sets the *max results* query property to the given value.
36266    pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, C> {
36267        self._max_results = Some(new_value);
36268        self
36269    }
36270    /// Select only creative field values with these IDs.
36271    ///
36272    /// Append the given value to the *ids* query property.
36273    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
36274    pub fn add_ids(mut self, new_value: i64) -> CreativeFieldValueListCall<'a, C> {
36275        self._ids.push(new_value);
36276        self
36277    }
36278    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36279    /// while executing the actual API request.
36280    ///
36281    /// ````text
36282    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36283    /// ````
36284    ///
36285    /// Sets the *delegate* property to the given value.
36286    pub fn delegate(
36287        mut self,
36288        new_value: &'a mut dyn common::Delegate,
36289    ) -> CreativeFieldValueListCall<'a, C> {
36290        self._delegate = Some(new_value);
36291        self
36292    }
36293
36294    /// Set any additional parameter of the query string used in the request.
36295    /// It should be used to set parameters which are not yet available through their own
36296    /// setters.
36297    ///
36298    /// Please note that this method must not be used to set any of the known parameters
36299    /// which have their own setter method. If done anyway, the request will fail.
36300    ///
36301    /// # Additional Parameters
36302    ///
36303    /// * *alt* (query-string) - Data format for the response.
36304    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36305    /// * *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.
36306    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36307    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36308    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36309    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36310    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueListCall<'a, C>
36311    where
36312        T: AsRef<str>,
36313    {
36314        self._additional_params
36315            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36316        self
36317    }
36318
36319    /// Identifies the authorization scope for the method you are building.
36320    ///
36321    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36322    /// [`Scope::Dfatrafficking`].
36323    ///
36324    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36325    /// tokens for more than one scope.
36326    ///
36327    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36328    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36329    /// sufficient, a read-write scope will do as well.
36330    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValueListCall<'a, C>
36331    where
36332        St: AsRef<str>,
36333    {
36334        self._scopes.insert(String::from(scope.as_ref()));
36335        self
36336    }
36337    /// Identifies the authorization scope(s) for the method you are building.
36338    ///
36339    /// See [`Self::add_scope()`] for details.
36340    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValueListCall<'a, C>
36341    where
36342        I: IntoIterator<Item = St>,
36343        St: AsRef<str>,
36344    {
36345        self._scopes
36346            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36347        self
36348    }
36349
36350    /// Removes all scopes, and no default scope will be used either.
36351    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36352    /// for details).
36353    pub fn clear_scopes(mut self) -> CreativeFieldValueListCall<'a, C> {
36354        self._scopes.clear();
36355        self
36356    }
36357}
36358
36359/// Updates an existing creative field value. This method supports patch semantics.
36360///
36361/// A builder for the *patch* method supported by a *creativeFieldValue* resource.
36362/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
36363///
36364/// # Example
36365///
36366/// Instantiate a resource method builder
36367///
36368/// ```test_harness,no_run
36369/// # extern crate hyper;
36370/// # extern crate hyper_rustls;
36371/// # extern crate google_dfareporting3d2 as dfareporting3d2;
36372/// use dfareporting3d2::api::CreativeFieldValue;
36373/// # async fn dox() {
36374/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36375///
36376/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
36378/// #     secret,
36379/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36380/// # ).build().await.unwrap();
36381///
36382/// # let client = hyper_util::client::legacy::Client::builder(
36383/// #     hyper_util::rt::TokioExecutor::new()
36384/// # )
36385/// # .build(
36386/// #     hyper_rustls::HttpsConnectorBuilder::new()
36387/// #         .with_native_roots()
36388/// #         .unwrap()
36389/// #         .https_or_http()
36390/// #         .enable_http1()
36391/// #         .build()
36392/// # );
36393/// # let mut hub = Dfareporting::new(client, auth);
36394/// // As the method needs a request, you would usually fill it with the desired information
36395/// // into the respective structure. Some of the parts shown here might not be applicable !
36396/// // Values shown here are possibly random and not representative !
36397/// let mut req = CreativeFieldValue::default();
36398///
36399/// // You can configure optional parameters by calling the respective setters at will, and
36400/// // execute the final call using `doit()`.
36401/// // Values shown here are possibly random and not representative !
36402/// let result = hub.creative_field_values().patch(req, -95, -39, -10)
36403///              .doit().await;
36404/// # }
36405/// ```
36406pub struct CreativeFieldValuePatchCall<'a, C>
36407where
36408    C: 'a,
36409{
36410    hub: &'a Dfareporting<C>,
36411    _request: CreativeFieldValue,
36412    _profile_id: i64,
36413    _creative_field_id: i64,
36414    _id: i64,
36415    _delegate: Option<&'a mut dyn common::Delegate>,
36416    _additional_params: HashMap<String, String>,
36417    _scopes: BTreeSet<String>,
36418}
36419
36420impl<'a, C> common::CallBuilder for CreativeFieldValuePatchCall<'a, C> {}
36421
36422impl<'a, C> CreativeFieldValuePatchCall<'a, C>
36423where
36424    C: common::Connector,
36425{
36426    /// Perform the operation you have build so far.
36427    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeFieldValue)> {
36428        use std::borrow::Cow;
36429        use std::io::{Read, Seek};
36430
36431        use common::{url::Params, ToParts};
36432        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36433
36434        let mut dd = common::DefaultDelegate;
36435        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36436        dlg.begin(common::MethodInfo {
36437            id: "dfareporting.creativeFieldValues.patch",
36438            http_method: hyper::Method::PATCH,
36439        });
36440
36441        for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() {
36442            if self._additional_params.contains_key(field) {
36443                dlg.finished(false);
36444                return Err(common::Error::FieldClash(field));
36445            }
36446        }
36447
36448        let mut params = Params::with_capacity(6 + self._additional_params.len());
36449        params.push("profileId", self._profile_id.to_string());
36450        params.push("creativeFieldId", self._creative_field_id.to_string());
36451        params.push("id", self._id.to_string());
36452
36453        params.extend(self._additional_params.iter());
36454
36455        params.push("alt", "json");
36456        let mut url = self.hub._base_url.clone()
36457            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues";
36458        if self._scopes.is_empty() {
36459            self._scopes
36460                .insert(Scope::Dfatrafficking.as_ref().to_string());
36461        }
36462
36463        #[allow(clippy::single_element_loop)]
36464        for &(find_this, param_name) in [
36465            ("{profileId}", "profileId"),
36466            ("{creativeFieldId}", "creativeFieldId"),
36467        ]
36468        .iter()
36469        {
36470            url = params.uri_replacement(url, param_name, find_this, false);
36471        }
36472        {
36473            let to_remove = ["creativeFieldId", "profileId"];
36474            params.remove_params(&to_remove);
36475        }
36476
36477        let url = params.parse_with_url(&url);
36478
36479        let mut json_mime_type = mime::APPLICATION_JSON;
36480        let mut request_value_reader = {
36481            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36482            common::remove_json_null_values(&mut value);
36483            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36484            serde_json::to_writer(&mut dst, &value).unwrap();
36485            dst
36486        };
36487        let request_size = request_value_reader
36488            .seek(std::io::SeekFrom::End(0))
36489            .unwrap();
36490        request_value_reader
36491            .seek(std::io::SeekFrom::Start(0))
36492            .unwrap();
36493
36494        loop {
36495            let token = match self
36496                .hub
36497                .auth
36498                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36499                .await
36500            {
36501                Ok(token) => token,
36502                Err(e) => match dlg.token(e) {
36503                    Ok(token) => token,
36504                    Err(e) => {
36505                        dlg.finished(false);
36506                        return Err(common::Error::MissingToken(e));
36507                    }
36508                },
36509            };
36510            request_value_reader
36511                .seek(std::io::SeekFrom::Start(0))
36512                .unwrap();
36513            let mut req_result = {
36514                let client = &self.hub.client;
36515                dlg.pre_request();
36516                let mut req_builder = hyper::Request::builder()
36517                    .method(hyper::Method::PATCH)
36518                    .uri(url.as_str())
36519                    .header(USER_AGENT, self.hub._user_agent.clone());
36520
36521                if let Some(token) = token.as_ref() {
36522                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36523                }
36524
36525                let request = req_builder
36526                    .header(CONTENT_TYPE, json_mime_type.to_string())
36527                    .header(CONTENT_LENGTH, request_size as u64)
36528                    .body(common::to_body(
36529                        request_value_reader.get_ref().clone().into(),
36530                    ));
36531
36532                client.request(request.unwrap()).await
36533            };
36534
36535            match req_result {
36536                Err(err) => {
36537                    if let common::Retry::After(d) = dlg.http_error(&err) {
36538                        sleep(d).await;
36539                        continue;
36540                    }
36541                    dlg.finished(false);
36542                    return Err(common::Error::HttpError(err));
36543                }
36544                Ok(res) => {
36545                    let (mut parts, body) = res.into_parts();
36546                    let mut body = common::Body::new(body);
36547                    if !parts.status.is_success() {
36548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36549                        let error = serde_json::from_str(&common::to_string(&bytes));
36550                        let response = common::to_response(parts, bytes.into());
36551
36552                        if let common::Retry::After(d) =
36553                            dlg.http_failure(&response, error.as_ref().ok())
36554                        {
36555                            sleep(d).await;
36556                            continue;
36557                        }
36558
36559                        dlg.finished(false);
36560
36561                        return Err(match error {
36562                            Ok(value) => common::Error::BadRequest(value),
36563                            _ => common::Error::Failure(response),
36564                        });
36565                    }
36566                    let response = {
36567                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36568                        let encoded = common::to_string(&bytes);
36569                        match serde_json::from_str(&encoded) {
36570                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36571                            Err(error) => {
36572                                dlg.response_json_decode_error(&encoded, &error);
36573                                return Err(common::Error::JsonDecodeError(
36574                                    encoded.to_string(),
36575                                    error,
36576                                ));
36577                            }
36578                        }
36579                    };
36580
36581                    dlg.finished(true);
36582                    return Ok(response);
36583                }
36584            }
36585        }
36586    }
36587
36588    ///
36589    /// Sets the *request* property to the given value.
36590    ///
36591    /// Even though the property as already been set when instantiating this call,
36592    /// we provide this method for API completeness.
36593    pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, C> {
36594        self._request = new_value;
36595        self
36596    }
36597    /// User profile ID associated with this request.
36598    ///
36599    /// Sets the *profile id* path property to the given value.
36600    ///
36601    /// Even though the property as already been set when instantiating this call,
36602    /// we provide this method for API completeness.
36603    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValuePatchCall<'a, C> {
36604        self._profile_id = new_value;
36605        self
36606    }
36607    /// Creative field ID for this creative field value.
36608    ///
36609    /// Sets the *creative field id* path property to the given value.
36610    ///
36611    /// Even though the property as already been set when instantiating this call,
36612    /// we provide this method for API completeness.
36613    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValuePatchCall<'a, C> {
36614        self._creative_field_id = new_value;
36615        self
36616    }
36617    /// Creative Field Value ID
36618    ///
36619    /// Sets the *id* query property to the given value.
36620    ///
36621    /// Even though the property as already been set when instantiating this call,
36622    /// we provide this method for API completeness.
36623    pub fn id(mut self, new_value: i64) -> CreativeFieldValuePatchCall<'a, C> {
36624        self._id = new_value;
36625        self
36626    }
36627    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36628    /// while executing the actual API request.
36629    ///
36630    /// ````text
36631    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36632    /// ````
36633    ///
36634    /// Sets the *delegate* property to the given value.
36635    pub fn delegate(
36636        mut self,
36637        new_value: &'a mut dyn common::Delegate,
36638    ) -> CreativeFieldValuePatchCall<'a, C> {
36639        self._delegate = Some(new_value);
36640        self
36641    }
36642
36643    /// Set any additional parameter of the query string used in the request.
36644    /// It should be used to set parameters which are not yet available through their own
36645    /// setters.
36646    ///
36647    /// Please note that this method must not be used to set any of the known parameters
36648    /// which have their own setter method. If done anyway, the request will fail.
36649    ///
36650    /// # Additional Parameters
36651    ///
36652    /// * *alt* (query-string) - Data format for the response.
36653    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36654    /// * *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.
36655    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36656    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36657    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36658    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36659    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValuePatchCall<'a, C>
36660    where
36661        T: AsRef<str>,
36662    {
36663        self._additional_params
36664            .insert(name.as_ref().to_string(), value.as_ref().to_string());
36665        self
36666    }
36667
36668    /// Identifies the authorization scope for the method you are building.
36669    ///
36670    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
36671    /// [`Scope::Dfatrafficking`].
36672    ///
36673    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
36674    /// tokens for more than one scope.
36675    ///
36676    /// Usually there is more than one suitable scope to authorize an operation, some of which may
36677    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
36678    /// sufficient, a read-write scope will do as well.
36679    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValuePatchCall<'a, C>
36680    where
36681        St: AsRef<str>,
36682    {
36683        self._scopes.insert(String::from(scope.as_ref()));
36684        self
36685    }
36686    /// Identifies the authorization scope(s) for the method you are building.
36687    ///
36688    /// See [`Self::add_scope()`] for details.
36689    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValuePatchCall<'a, C>
36690    where
36691        I: IntoIterator<Item = St>,
36692        St: AsRef<str>,
36693    {
36694        self._scopes
36695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
36696        self
36697    }
36698
36699    /// Removes all scopes, and no default scope will be used either.
36700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
36701    /// for details).
36702    pub fn clear_scopes(mut self) -> CreativeFieldValuePatchCall<'a, C> {
36703        self._scopes.clear();
36704        self
36705    }
36706}
36707
36708/// Updates an existing creative field value.
36709///
36710/// A builder for the *update* method supported by a *creativeFieldValue* resource.
36711/// It is not used directly, but through a [`CreativeFieldValueMethods`] instance.
36712///
36713/// # Example
36714///
36715/// Instantiate a resource method builder
36716///
36717/// ```test_harness,no_run
36718/// # extern crate hyper;
36719/// # extern crate hyper_rustls;
36720/// # extern crate google_dfareporting3d2 as dfareporting3d2;
36721/// use dfareporting3d2::api::CreativeFieldValue;
36722/// # async fn dox() {
36723/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
36724///
36725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
36726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
36727/// #     secret,
36728/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
36729/// # ).build().await.unwrap();
36730///
36731/// # let client = hyper_util::client::legacy::Client::builder(
36732/// #     hyper_util::rt::TokioExecutor::new()
36733/// # )
36734/// # .build(
36735/// #     hyper_rustls::HttpsConnectorBuilder::new()
36736/// #         .with_native_roots()
36737/// #         .unwrap()
36738/// #         .https_or_http()
36739/// #         .enable_http1()
36740/// #         .build()
36741/// # );
36742/// # let mut hub = Dfareporting::new(client, auth);
36743/// // As the method needs a request, you would usually fill it with the desired information
36744/// // into the respective structure. Some of the parts shown here might not be applicable !
36745/// // Values shown here are possibly random and not representative !
36746/// let mut req = CreativeFieldValue::default();
36747///
36748/// // You can configure optional parameters by calling the respective setters at will, and
36749/// // execute the final call using `doit()`.
36750/// // Values shown here are possibly random and not representative !
36751/// let result = hub.creative_field_values().update(req, -74, -56)
36752///              .doit().await;
36753/// # }
36754/// ```
36755pub struct CreativeFieldValueUpdateCall<'a, C>
36756where
36757    C: 'a,
36758{
36759    hub: &'a Dfareporting<C>,
36760    _request: CreativeFieldValue,
36761    _profile_id: i64,
36762    _creative_field_id: i64,
36763    _delegate: Option<&'a mut dyn common::Delegate>,
36764    _additional_params: HashMap<String, String>,
36765    _scopes: BTreeSet<String>,
36766}
36767
36768impl<'a, C> common::CallBuilder for CreativeFieldValueUpdateCall<'a, C> {}
36769
36770impl<'a, C> CreativeFieldValueUpdateCall<'a, C>
36771where
36772    C: common::Connector,
36773{
36774    /// Perform the operation you have build so far.
36775    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeFieldValue)> {
36776        use std::borrow::Cow;
36777        use std::io::{Read, Seek};
36778
36779        use common::{url::Params, ToParts};
36780        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
36781
36782        let mut dd = common::DefaultDelegate;
36783        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
36784        dlg.begin(common::MethodInfo {
36785            id: "dfareporting.creativeFieldValues.update",
36786            http_method: hyper::Method::PUT,
36787        });
36788
36789        for &field in ["alt", "profileId", "creativeFieldId"].iter() {
36790            if self._additional_params.contains_key(field) {
36791                dlg.finished(false);
36792                return Err(common::Error::FieldClash(field));
36793            }
36794        }
36795
36796        let mut params = Params::with_capacity(5 + self._additional_params.len());
36797        params.push("profileId", self._profile_id.to_string());
36798        params.push("creativeFieldId", self._creative_field_id.to_string());
36799
36800        params.extend(self._additional_params.iter());
36801
36802        params.push("alt", "json");
36803        let mut url = self.hub._base_url.clone()
36804            + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues";
36805        if self._scopes.is_empty() {
36806            self._scopes
36807                .insert(Scope::Dfatrafficking.as_ref().to_string());
36808        }
36809
36810        #[allow(clippy::single_element_loop)]
36811        for &(find_this, param_name) in [
36812            ("{profileId}", "profileId"),
36813            ("{creativeFieldId}", "creativeFieldId"),
36814        ]
36815        .iter()
36816        {
36817            url = params.uri_replacement(url, param_name, find_this, false);
36818        }
36819        {
36820            let to_remove = ["creativeFieldId", "profileId"];
36821            params.remove_params(&to_remove);
36822        }
36823
36824        let url = params.parse_with_url(&url);
36825
36826        let mut json_mime_type = mime::APPLICATION_JSON;
36827        let mut request_value_reader = {
36828            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
36829            common::remove_json_null_values(&mut value);
36830            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
36831            serde_json::to_writer(&mut dst, &value).unwrap();
36832            dst
36833        };
36834        let request_size = request_value_reader
36835            .seek(std::io::SeekFrom::End(0))
36836            .unwrap();
36837        request_value_reader
36838            .seek(std::io::SeekFrom::Start(0))
36839            .unwrap();
36840
36841        loop {
36842            let token = match self
36843                .hub
36844                .auth
36845                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
36846                .await
36847            {
36848                Ok(token) => token,
36849                Err(e) => match dlg.token(e) {
36850                    Ok(token) => token,
36851                    Err(e) => {
36852                        dlg.finished(false);
36853                        return Err(common::Error::MissingToken(e));
36854                    }
36855                },
36856            };
36857            request_value_reader
36858                .seek(std::io::SeekFrom::Start(0))
36859                .unwrap();
36860            let mut req_result = {
36861                let client = &self.hub.client;
36862                dlg.pre_request();
36863                let mut req_builder = hyper::Request::builder()
36864                    .method(hyper::Method::PUT)
36865                    .uri(url.as_str())
36866                    .header(USER_AGENT, self.hub._user_agent.clone());
36867
36868                if let Some(token) = token.as_ref() {
36869                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
36870                }
36871
36872                let request = req_builder
36873                    .header(CONTENT_TYPE, json_mime_type.to_string())
36874                    .header(CONTENT_LENGTH, request_size as u64)
36875                    .body(common::to_body(
36876                        request_value_reader.get_ref().clone().into(),
36877                    ));
36878
36879                client.request(request.unwrap()).await
36880            };
36881
36882            match req_result {
36883                Err(err) => {
36884                    if let common::Retry::After(d) = dlg.http_error(&err) {
36885                        sleep(d).await;
36886                        continue;
36887                    }
36888                    dlg.finished(false);
36889                    return Err(common::Error::HttpError(err));
36890                }
36891                Ok(res) => {
36892                    let (mut parts, body) = res.into_parts();
36893                    let mut body = common::Body::new(body);
36894                    if !parts.status.is_success() {
36895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36896                        let error = serde_json::from_str(&common::to_string(&bytes));
36897                        let response = common::to_response(parts, bytes.into());
36898
36899                        if let common::Retry::After(d) =
36900                            dlg.http_failure(&response, error.as_ref().ok())
36901                        {
36902                            sleep(d).await;
36903                            continue;
36904                        }
36905
36906                        dlg.finished(false);
36907
36908                        return Err(match error {
36909                            Ok(value) => common::Error::BadRequest(value),
36910                            _ => common::Error::Failure(response),
36911                        });
36912                    }
36913                    let response = {
36914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
36915                        let encoded = common::to_string(&bytes);
36916                        match serde_json::from_str(&encoded) {
36917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
36918                            Err(error) => {
36919                                dlg.response_json_decode_error(&encoded, &error);
36920                                return Err(common::Error::JsonDecodeError(
36921                                    encoded.to_string(),
36922                                    error,
36923                                ));
36924                            }
36925                        }
36926                    };
36927
36928                    dlg.finished(true);
36929                    return Ok(response);
36930                }
36931            }
36932        }
36933    }
36934
36935    ///
36936    /// Sets the *request* property to the given value.
36937    ///
36938    /// Even though the property as already been set when instantiating this call,
36939    /// we provide this method for API completeness.
36940    pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, C> {
36941        self._request = new_value;
36942        self
36943    }
36944    /// User profile ID associated with this request.
36945    ///
36946    /// Sets the *profile id* path property to the given value.
36947    ///
36948    /// Even though the property as already been set when instantiating this call,
36949    /// we provide this method for API completeness.
36950    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldValueUpdateCall<'a, C> {
36951        self._profile_id = new_value;
36952        self
36953    }
36954    /// Creative field ID for this creative field value.
36955    ///
36956    /// Sets the *creative field id* path property to the given value.
36957    ///
36958    /// Even though the property as already been set when instantiating this call,
36959    /// we provide this method for API completeness.
36960    pub fn creative_field_id(mut self, new_value: i64) -> CreativeFieldValueUpdateCall<'a, C> {
36961        self._creative_field_id = new_value;
36962        self
36963    }
36964    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
36965    /// while executing the actual API request.
36966    ///
36967    /// ````text
36968    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
36969    /// ````
36970    ///
36971    /// Sets the *delegate* property to the given value.
36972    pub fn delegate(
36973        mut self,
36974        new_value: &'a mut dyn common::Delegate,
36975    ) -> CreativeFieldValueUpdateCall<'a, C> {
36976        self._delegate = Some(new_value);
36977        self
36978    }
36979
36980    /// Set any additional parameter of the query string used in the request.
36981    /// It should be used to set parameters which are not yet available through their own
36982    /// setters.
36983    ///
36984    /// Please note that this method must not be used to set any of the known parameters
36985    /// which have their own setter method. If done anyway, the request will fail.
36986    ///
36987    /// # Additional Parameters
36988    ///
36989    /// * *alt* (query-string) - Data format for the response.
36990    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
36991    /// * *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.
36992    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
36993    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
36994    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
36995    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
36996    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldValueUpdateCall<'a, C>
36997    where
36998        T: AsRef<str>,
36999    {
37000        self._additional_params
37001            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37002        self
37003    }
37004
37005    /// Identifies the authorization scope for the method you are building.
37006    ///
37007    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37008    /// [`Scope::Dfatrafficking`].
37009    ///
37010    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37011    /// tokens for more than one scope.
37012    ///
37013    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37014    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37015    /// sufficient, a read-write scope will do as well.
37016    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldValueUpdateCall<'a, C>
37017    where
37018        St: AsRef<str>,
37019    {
37020        self._scopes.insert(String::from(scope.as_ref()));
37021        self
37022    }
37023    /// Identifies the authorization scope(s) for the method you are building.
37024    ///
37025    /// See [`Self::add_scope()`] for details.
37026    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldValueUpdateCall<'a, C>
37027    where
37028        I: IntoIterator<Item = St>,
37029        St: AsRef<str>,
37030    {
37031        self._scopes
37032            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37033        self
37034    }
37035
37036    /// Removes all scopes, and no default scope will be used either.
37037    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37038    /// for details).
37039    pub fn clear_scopes(mut self) -> CreativeFieldValueUpdateCall<'a, C> {
37040        self._scopes.clear();
37041        self
37042    }
37043}
37044
37045/// Deletes an existing creative field.
37046///
37047/// A builder for the *delete* method supported by a *creativeField* resource.
37048/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
37049///
37050/// # Example
37051///
37052/// Instantiate a resource method builder
37053///
37054/// ```test_harness,no_run
37055/// # extern crate hyper;
37056/// # extern crate hyper_rustls;
37057/// # extern crate google_dfareporting3d2 as dfareporting3d2;
37058/// # async fn dox() {
37059/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37060///
37061/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37062/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
37063/// #     secret,
37064/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37065/// # ).build().await.unwrap();
37066///
37067/// # let client = hyper_util::client::legacy::Client::builder(
37068/// #     hyper_util::rt::TokioExecutor::new()
37069/// # )
37070/// # .build(
37071/// #     hyper_rustls::HttpsConnectorBuilder::new()
37072/// #         .with_native_roots()
37073/// #         .unwrap()
37074/// #         .https_or_http()
37075/// #         .enable_http1()
37076/// #         .build()
37077/// # );
37078/// # let mut hub = Dfareporting::new(client, auth);
37079/// // You can configure optional parameters by calling the respective setters at will, and
37080/// // execute the final call using `doit()`.
37081/// // Values shown here are possibly random and not representative !
37082/// let result = hub.creative_fields().delete(-33, -59)
37083///              .doit().await;
37084/// # }
37085/// ```
37086pub struct CreativeFieldDeleteCall<'a, C>
37087where
37088    C: 'a,
37089{
37090    hub: &'a Dfareporting<C>,
37091    _profile_id: i64,
37092    _id: i64,
37093    _delegate: Option<&'a mut dyn common::Delegate>,
37094    _additional_params: HashMap<String, String>,
37095    _scopes: BTreeSet<String>,
37096}
37097
37098impl<'a, C> common::CallBuilder for CreativeFieldDeleteCall<'a, C> {}
37099
37100impl<'a, C> CreativeFieldDeleteCall<'a, C>
37101where
37102    C: common::Connector,
37103{
37104    /// Perform the operation you have build so far.
37105    pub async fn doit(mut self) -> common::Result<common::Response> {
37106        use std::borrow::Cow;
37107        use std::io::{Read, Seek};
37108
37109        use common::{url::Params, ToParts};
37110        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37111
37112        let mut dd = common::DefaultDelegate;
37113        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37114        dlg.begin(common::MethodInfo {
37115            id: "dfareporting.creativeFields.delete",
37116            http_method: hyper::Method::DELETE,
37117        });
37118
37119        for &field in ["profileId", "id"].iter() {
37120            if self._additional_params.contains_key(field) {
37121                dlg.finished(false);
37122                return Err(common::Error::FieldClash(field));
37123            }
37124        }
37125
37126        let mut params = Params::with_capacity(3 + self._additional_params.len());
37127        params.push("profileId", self._profile_id.to_string());
37128        params.push("id", self._id.to_string());
37129
37130        params.extend(self._additional_params.iter());
37131
37132        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{id}";
37133        if self._scopes.is_empty() {
37134            self._scopes
37135                .insert(Scope::Dfatrafficking.as_ref().to_string());
37136        }
37137
37138        #[allow(clippy::single_element_loop)]
37139        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
37140            url = params.uri_replacement(url, param_name, find_this, false);
37141        }
37142        {
37143            let to_remove = ["id", "profileId"];
37144            params.remove_params(&to_remove);
37145        }
37146
37147        let url = params.parse_with_url(&url);
37148
37149        loop {
37150            let token = match self
37151                .hub
37152                .auth
37153                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37154                .await
37155            {
37156                Ok(token) => token,
37157                Err(e) => match dlg.token(e) {
37158                    Ok(token) => token,
37159                    Err(e) => {
37160                        dlg.finished(false);
37161                        return Err(common::Error::MissingToken(e));
37162                    }
37163                },
37164            };
37165            let mut req_result = {
37166                let client = &self.hub.client;
37167                dlg.pre_request();
37168                let mut req_builder = hyper::Request::builder()
37169                    .method(hyper::Method::DELETE)
37170                    .uri(url.as_str())
37171                    .header(USER_AGENT, self.hub._user_agent.clone());
37172
37173                if let Some(token) = token.as_ref() {
37174                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37175                }
37176
37177                let request = req_builder
37178                    .header(CONTENT_LENGTH, 0_u64)
37179                    .body(common::to_body::<String>(None));
37180
37181                client.request(request.unwrap()).await
37182            };
37183
37184            match req_result {
37185                Err(err) => {
37186                    if let common::Retry::After(d) = dlg.http_error(&err) {
37187                        sleep(d).await;
37188                        continue;
37189                    }
37190                    dlg.finished(false);
37191                    return Err(common::Error::HttpError(err));
37192                }
37193                Ok(res) => {
37194                    let (mut parts, body) = res.into_parts();
37195                    let mut body = common::Body::new(body);
37196                    if !parts.status.is_success() {
37197                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37198                        let error = serde_json::from_str(&common::to_string(&bytes));
37199                        let response = common::to_response(parts, bytes.into());
37200
37201                        if let common::Retry::After(d) =
37202                            dlg.http_failure(&response, error.as_ref().ok())
37203                        {
37204                            sleep(d).await;
37205                            continue;
37206                        }
37207
37208                        dlg.finished(false);
37209
37210                        return Err(match error {
37211                            Ok(value) => common::Error::BadRequest(value),
37212                            _ => common::Error::Failure(response),
37213                        });
37214                    }
37215                    let response = common::Response::from_parts(parts, body);
37216
37217                    dlg.finished(true);
37218                    return Ok(response);
37219                }
37220            }
37221        }
37222    }
37223
37224    /// User profile ID associated with this request.
37225    ///
37226    /// Sets the *profile id* path property to the given value.
37227    ///
37228    /// Even though the property as already been set when instantiating this call,
37229    /// we provide this method for API completeness.
37230    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldDeleteCall<'a, C> {
37231        self._profile_id = new_value;
37232        self
37233    }
37234    /// Creative Field ID
37235    ///
37236    /// Sets the *id* path property to the given value.
37237    ///
37238    /// Even though the property as already been set when instantiating this call,
37239    /// we provide this method for API completeness.
37240    pub fn id(mut self, new_value: i64) -> CreativeFieldDeleteCall<'a, C> {
37241        self._id = new_value;
37242        self
37243    }
37244    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37245    /// while executing the actual API request.
37246    ///
37247    /// ````text
37248    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37249    /// ````
37250    ///
37251    /// Sets the *delegate* property to the given value.
37252    pub fn delegate(
37253        mut self,
37254        new_value: &'a mut dyn common::Delegate,
37255    ) -> CreativeFieldDeleteCall<'a, C> {
37256        self._delegate = Some(new_value);
37257        self
37258    }
37259
37260    /// Set any additional parameter of the query string used in the request.
37261    /// It should be used to set parameters which are not yet available through their own
37262    /// setters.
37263    ///
37264    /// Please note that this method must not be used to set any of the known parameters
37265    /// which have their own setter method. If done anyway, the request will fail.
37266    ///
37267    /// # Additional Parameters
37268    ///
37269    /// * *alt* (query-string) - Data format for the response.
37270    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37271    /// * *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.
37272    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37273    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37274    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
37275    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
37276    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldDeleteCall<'a, C>
37277    where
37278        T: AsRef<str>,
37279    {
37280        self._additional_params
37281            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37282        self
37283    }
37284
37285    /// Identifies the authorization scope for the method you are building.
37286    ///
37287    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37288    /// [`Scope::Dfatrafficking`].
37289    ///
37290    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37291    /// tokens for more than one scope.
37292    ///
37293    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37294    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37295    /// sufficient, a read-write scope will do as well.
37296    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldDeleteCall<'a, C>
37297    where
37298        St: AsRef<str>,
37299    {
37300        self._scopes.insert(String::from(scope.as_ref()));
37301        self
37302    }
37303    /// Identifies the authorization scope(s) for the method you are building.
37304    ///
37305    /// See [`Self::add_scope()`] for details.
37306    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldDeleteCall<'a, C>
37307    where
37308        I: IntoIterator<Item = St>,
37309        St: AsRef<str>,
37310    {
37311        self._scopes
37312            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37313        self
37314    }
37315
37316    /// Removes all scopes, and no default scope will be used either.
37317    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37318    /// for details).
37319    pub fn clear_scopes(mut self) -> CreativeFieldDeleteCall<'a, C> {
37320        self._scopes.clear();
37321        self
37322    }
37323}
37324
37325/// Gets one creative field by ID.
37326///
37327/// A builder for the *get* method supported by a *creativeField* resource.
37328/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
37329///
37330/// # Example
37331///
37332/// Instantiate a resource method builder
37333///
37334/// ```test_harness,no_run
37335/// # extern crate hyper;
37336/// # extern crate hyper_rustls;
37337/// # extern crate google_dfareporting3d2 as dfareporting3d2;
37338/// # async fn dox() {
37339/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37340///
37341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
37343/// #     secret,
37344/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37345/// # ).build().await.unwrap();
37346///
37347/// # let client = hyper_util::client::legacy::Client::builder(
37348/// #     hyper_util::rt::TokioExecutor::new()
37349/// # )
37350/// # .build(
37351/// #     hyper_rustls::HttpsConnectorBuilder::new()
37352/// #         .with_native_roots()
37353/// #         .unwrap()
37354/// #         .https_or_http()
37355/// #         .enable_http1()
37356/// #         .build()
37357/// # );
37358/// # let mut hub = Dfareporting::new(client, auth);
37359/// // You can configure optional parameters by calling the respective setters at will, and
37360/// // execute the final call using `doit()`.
37361/// // Values shown here are possibly random and not representative !
37362/// let result = hub.creative_fields().get(-66, -27)
37363///              .doit().await;
37364/// # }
37365/// ```
37366pub struct CreativeFieldGetCall<'a, C>
37367where
37368    C: 'a,
37369{
37370    hub: &'a Dfareporting<C>,
37371    _profile_id: i64,
37372    _id: i64,
37373    _delegate: Option<&'a mut dyn common::Delegate>,
37374    _additional_params: HashMap<String, String>,
37375    _scopes: BTreeSet<String>,
37376}
37377
37378impl<'a, C> common::CallBuilder for CreativeFieldGetCall<'a, C> {}
37379
37380impl<'a, C> CreativeFieldGetCall<'a, C>
37381where
37382    C: common::Connector,
37383{
37384    /// Perform the operation you have build so far.
37385    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeField)> {
37386        use std::borrow::Cow;
37387        use std::io::{Read, Seek};
37388
37389        use common::{url::Params, ToParts};
37390        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37391
37392        let mut dd = common::DefaultDelegate;
37393        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37394        dlg.begin(common::MethodInfo {
37395            id: "dfareporting.creativeFields.get",
37396            http_method: hyper::Method::GET,
37397        });
37398
37399        for &field in ["alt", "profileId", "id"].iter() {
37400            if self._additional_params.contains_key(field) {
37401                dlg.finished(false);
37402                return Err(common::Error::FieldClash(field));
37403            }
37404        }
37405
37406        let mut params = Params::with_capacity(4 + self._additional_params.len());
37407        params.push("profileId", self._profile_id.to_string());
37408        params.push("id", self._id.to_string());
37409
37410        params.extend(self._additional_params.iter());
37411
37412        params.push("alt", "json");
37413        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{id}";
37414        if self._scopes.is_empty() {
37415            self._scopes
37416                .insert(Scope::Dfatrafficking.as_ref().to_string());
37417        }
37418
37419        #[allow(clippy::single_element_loop)]
37420        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
37421            url = params.uri_replacement(url, param_name, find_this, false);
37422        }
37423        {
37424            let to_remove = ["id", "profileId"];
37425            params.remove_params(&to_remove);
37426        }
37427
37428        let url = params.parse_with_url(&url);
37429
37430        loop {
37431            let token = match self
37432                .hub
37433                .auth
37434                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37435                .await
37436            {
37437                Ok(token) => token,
37438                Err(e) => match dlg.token(e) {
37439                    Ok(token) => token,
37440                    Err(e) => {
37441                        dlg.finished(false);
37442                        return Err(common::Error::MissingToken(e));
37443                    }
37444                },
37445            };
37446            let mut req_result = {
37447                let client = &self.hub.client;
37448                dlg.pre_request();
37449                let mut req_builder = hyper::Request::builder()
37450                    .method(hyper::Method::GET)
37451                    .uri(url.as_str())
37452                    .header(USER_AGENT, self.hub._user_agent.clone());
37453
37454                if let Some(token) = token.as_ref() {
37455                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37456                }
37457
37458                let request = req_builder
37459                    .header(CONTENT_LENGTH, 0_u64)
37460                    .body(common::to_body::<String>(None));
37461
37462                client.request(request.unwrap()).await
37463            };
37464
37465            match req_result {
37466                Err(err) => {
37467                    if let common::Retry::After(d) = dlg.http_error(&err) {
37468                        sleep(d).await;
37469                        continue;
37470                    }
37471                    dlg.finished(false);
37472                    return Err(common::Error::HttpError(err));
37473                }
37474                Ok(res) => {
37475                    let (mut parts, body) = res.into_parts();
37476                    let mut body = common::Body::new(body);
37477                    if !parts.status.is_success() {
37478                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37479                        let error = serde_json::from_str(&common::to_string(&bytes));
37480                        let response = common::to_response(parts, bytes.into());
37481
37482                        if let common::Retry::After(d) =
37483                            dlg.http_failure(&response, error.as_ref().ok())
37484                        {
37485                            sleep(d).await;
37486                            continue;
37487                        }
37488
37489                        dlg.finished(false);
37490
37491                        return Err(match error {
37492                            Ok(value) => common::Error::BadRequest(value),
37493                            _ => common::Error::Failure(response),
37494                        });
37495                    }
37496                    let response = {
37497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37498                        let encoded = common::to_string(&bytes);
37499                        match serde_json::from_str(&encoded) {
37500                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37501                            Err(error) => {
37502                                dlg.response_json_decode_error(&encoded, &error);
37503                                return Err(common::Error::JsonDecodeError(
37504                                    encoded.to_string(),
37505                                    error,
37506                                ));
37507                            }
37508                        }
37509                    };
37510
37511                    dlg.finished(true);
37512                    return Ok(response);
37513                }
37514            }
37515        }
37516    }
37517
37518    /// User profile ID associated with this request.
37519    ///
37520    /// Sets the *profile id* path property to the given value.
37521    ///
37522    /// Even though the property as already been set when instantiating this call,
37523    /// we provide this method for API completeness.
37524    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldGetCall<'a, C> {
37525        self._profile_id = new_value;
37526        self
37527    }
37528    /// Creative Field ID
37529    ///
37530    /// Sets the *id* path property to the given value.
37531    ///
37532    /// Even though the property as already been set when instantiating this call,
37533    /// we provide this method for API completeness.
37534    pub fn id(mut self, new_value: i64) -> CreativeFieldGetCall<'a, C> {
37535        self._id = new_value;
37536        self
37537    }
37538    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37539    /// while executing the actual API request.
37540    ///
37541    /// ````text
37542    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37543    /// ````
37544    ///
37545    /// Sets the *delegate* property to the given value.
37546    pub fn delegate(
37547        mut self,
37548        new_value: &'a mut dyn common::Delegate,
37549    ) -> CreativeFieldGetCall<'a, C> {
37550        self._delegate = Some(new_value);
37551        self
37552    }
37553
37554    /// Set any additional parameter of the query string used in the request.
37555    /// It should be used to set parameters which are not yet available through their own
37556    /// setters.
37557    ///
37558    /// Please note that this method must not be used to set any of the known parameters
37559    /// which have their own setter method. If done anyway, the request will fail.
37560    ///
37561    /// # Additional Parameters
37562    ///
37563    /// * *alt* (query-string) - Data format for the response.
37564    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37565    /// * *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.
37566    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37567    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37568    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
37569    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
37570    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldGetCall<'a, C>
37571    where
37572        T: AsRef<str>,
37573    {
37574        self._additional_params
37575            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37576        self
37577    }
37578
37579    /// Identifies the authorization scope for the method you are building.
37580    ///
37581    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37582    /// [`Scope::Dfatrafficking`].
37583    ///
37584    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37585    /// tokens for more than one scope.
37586    ///
37587    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37588    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37589    /// sufficient, a read-write scope will do as well.
37590    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldGetCall<'a, C>
37591    where
37592        St: AsRef<str>,
37593    {
37594        self._scopes.insert(String::from(scope.as_ref()));
37595        self
37596    }
37597    /// Identifies the authorization scope(s) for the method you are building.
37598    ///
37599    /// See [`Self::add_scope()`] for details.
37600    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldGetCall<'a, C>
37601    where
37602        I: IntoIterator<Item = St>,
37603        St: AsRef<str>,
37604    {
37605        self._scopes
37606            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37607        self
37608    }
37609
37610    /// Removes all scopes, and no default scope will be used either.
37611    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37612    /// for details).
37613    pub fn clear_scopes(mut self) -> CreativeFieldGetCall<'a, C> {
37614        self._scopes.clear();
37615        self
37616    }
37617}
37618
37619/// Inserts a new creative field.
37620///
37621/// A builder for the *insert* method supported by a *creativeField* resource.
37622/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
37623///
37624/// # Example
37625///
37626/// Instantiate a resource method builder
37627///
37628/// ```test_harness,no_run
37629/// # extern crate hyper;
37630/// # extern crate hyper_rustls;
37631/// # extern crate google_dfareporting3d2 as dfareporting3d2;
37632/// use dfareporting3d2::api::CreativeField;
37633/// # async fn dox() {
37634/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37635///
37636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37637/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
37638/// #     secret,
37639/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37640/// # ).build().await.unwrap();
37641///
37642/// # let client = hyper_util::client::legacy::Client::builder(
37643/// #     hyper_util::rt::TokioExecutor::new()
37644/// # )
37645/// # .build(
37646/// #     hyper_rustls::HttpsConnectorBuilder::new()
37647/// #         .with_native_roots()
37648/// #         .unwrap()
37649/// #         .https_or_http()
37650/// #         .enable_http1()
37651/// #         .build()
37652/// # );
37653/// # let mut hub = Dfareporting::new(client, auth);
37654/// // As the method needs a request, you would usually fill it with the desired information
37655/// // into the respective structure. Some of the parts shown here might not be applicable !
37656/// // Values shown here are possibly random and not representative !
37657/// let mut req = CreativeField::default();
37658///
37659/// // You can configure optional parameters by calling the respective setters at will, and
37660/// // execute the final call using `doit()`.
37661/// // Values shown here are possibly random and not representative !
37662/// let result = hub.creative_fields().insert(req, -88)
37663///              .doit().await;
37664/// # }
37665/// ```
37666pub struct CreativeFieldInsertCall<'a, C>
37667where
37668    C: 'a,
37669{
37670    hub: &'a Dfareporting<C>,
37671    _request: CreativeField,
37672    _profile_id: i64,
37673    _delegate: Option<&'a mut dyn common::Delegate>,
37674    _additional_params: HashMap<String, String>,
37675    _scopes: BTreeSet<String>,
37676}
37677
37678impl<'a, C> common::CallBuilder for CreativeFieldInsertCall<'a, C> {}
37679
37680impl<'a, C> CreativeFieldInsertCall<'a, C>
37681where
37682    C: common::Connector,
37683{
37684    /// Perform the operation you have build so far.
37685    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeField)> {
37686        use std::borrow::Cow;
37687        use std::io::{Read, Seek};
37688
37689        use common::{url::Params, ToParts};
37690        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
37691
37692        let mut dd = common::DefaultDelegate;
37693        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
37694        dlg.begin(common::MethodInfo {
37695            id: "dfareporting.creativeFields.insert",
37696            http_method: hyper::Method::POST,
37697        });
37698
37699        for &field in ["alt", "profileId"].iter() {
37700            if self._additional_params.contains_key(field) {
37701                dlg.finished(false);
37702                return Err(common::Error::FieldClash(field));
37703            }
37704        }
37705
37706        let mut params = Params::with_capacity(4 + self._additional_params.len());
37707        params.push("profileId", self._profile_id.to_string());
37708
37709        params.extend(self._additional_params.iter());
37710
37711        params.push("alt", "json");
37712        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields";
37713        if self._scopes.is_empty() {
37714            self._scopes
37715                .insert(Scope::Dfatrafficking.as_ref().to_string());
37716        }
37717
37718        #[allow(clippy::single_element_loop)]
37719        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
37720            url = params.uri_replacement(url, param_name, find_this, false);
37721        }
37722        {
37723            let to_remove = ["profileId"];
37724            params.remove_params(&to_remove);
37725        }
37726
37727        let url = params.parse_with_url(&url);
37728
37729        let mut json_mime_type = mime::APPLICATION_JSON;
37730        let mut request_value_reader = {
37731            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
37732            common::remove_json_null_values(&mut value);
37733            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
37734            serde_json::to_writer(&mut dst, &value).unwrap();
37735            dst
37736        };
37737        let request_size = request_value_reader
37738            .seek(std::io::SeekFrom::End(0))
37739            .unwrap();
37740        request_value_reader
37741            .seek(std::io::SeekFrom::Start(0))
37742            .unwrap();
37743
37744        loop {
37745            let token = match self
37746                .hub
37747                .auth
37748                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
37749                .await
37750            {
37751                Ok(token) => token,
37752                Err(e) => match dlg.token(e) {
37753                    Ok(token) => token,
37754                    Err(e) => {
37755                        dlg.finished(false);
37756                        return Err(common::Error::MissingToken(e));
37757                    }
37758                },
37759            };
37760            request_value_reader
37761                .seek(std::io::SeekFrom::Start(0))
37762                .unwrap();
37763            let mut req_result = {
37764                let client = &self.hub.client;
37765                dlg.pre_request();
37766                let mut req_builder = hyper::Request::builder()
37767                    .method(hyper::Method::POST)
37768                    .uri(url.as_str())
37769                    .header(USER_AGENT, self.hub._user_agent.clone());
37770
37771                if let Some(token) = token.as_ref() {
37772                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
37773                }
37774
37775                let request = req_builder
37776                    .header(CONTENT_TYPE, json_mime_type.to_string())
37777                    .header(CONTENT_LENGTH, request_size as u64)
37778                    .body(common::to_body(
37779                        request_value_reader.get_ref().clone().into(),
37780                    ));
37781
37782                client.request(request.unwrap()).await
37783            };
37784
37785            match req_result {
37786                Err(err) => {
37787                    if let common::Retry::After(d) = dlg.http_error(&err) {
37788                        sleep(d).await;
37789                        continue;
37790                    }
37791                    dlg.finished(false);
37792                    return Err(common::Error::HttpError(err));
37793                }
37794                Ok(res) => {
37795                    let (mut parts, body) = res.into_parts();
37796                    let mut body = common::Body::new(body);
37797                    if !parts.status.is_success() {
37798                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37799                        let error = serde_json::from_str(&common::to_string(&bytes));
37800                        let response = common::to_response(parts, bytes.into());
37801
37802                        if let common::Retry::After(d) =
37803                            dlg.http_failure(&response, error.as_ref().ok())
37804                        {
37805                            sleep(d).await;
37806                            continue;
37807                        }
37808
37809                        dlg.finished(false);
37810
37811                        return Err(match error {
37812                            Ok(value) => common::Error::BadRequest(value),
37813                            _ => common::Error::Failure(response),
37814                        });
37815                    }
37816                    let response = {
37817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
37818                        let encoded = common::to_string(&bytes);
37819                        match serde_json::from_str(&encoded) {
37820                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
37821                            Err(error) => {
37822                                dlg.response_json_decode_error(&encoded, &error);
37823                                return Err(common::Error::JsonDecodeError(
37824                                    encoded.to_string(),
37825                                    error,
37826                                ));
37827                            }
37828                        }
37829                    };
37830
37831                    dlg.finished(true);
37832                    return Ok(response);
37833                }
37834            }
37835        }
37836    }
37837
37838    ///
37839    /// Sets the *request* property to the given value.
37840    ///
37841    /// Even though the property as already been set when instantiating this call,
37842    /// we provide this method for API completeness.
37843    pub fn request(mut self, new_value: CreativeField) -> CreativeFieldInsertCall<'a, C> {
37844        self._request = new_value;
37845        self
37846    }
37847    /// User profile ID associated with this request.
37848    ///
37849    /// Sets the *profile id* path property to the given value.
37850    ///
37851    /// Even though the property as already been set when instantiating this call,
37852    /// we provide this method for API completeness.
37853    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldInsertCall<'a, C> {
37854        self._profile_id = new_value;
37855        self
37856    }
37857    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
37858    /// while executing the actual API request.
37859    ///
37860    /// ````text
37861    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
37862    /// ````
37863    ///
37864    /// Sets the *delegate* property to the given value.
37865    pub fn delegate(
37866        mut self,
37867        new_value: &'a mut dyn common::Delegate,
37868    ) -> CreativeFieldInsertCall<'a, C> {
37869        self._delegate = Some(new_value);
37870        self
37871    }
37872
37873    /// Set any additional parameter of the query string used in the request.
37874    /// It should be used to set parameters which are not yet available through their own
37875    /// setters.
37876    ///
37877    /// Please note that this method must not be used to set any of the known parameters
37878    /// which have their own setter method. If done anyway, the request will fail.
37879    ///
37880    /// # Additional Parameters
37881    ///
37882    /// * *alt* (query-string) - Data format for the response.
37883    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
37884    /// * *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.
37885    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
37886    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
37887    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
37888    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
37889    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldInsertCall<'a, C>
37890    where
37891        T: AsRef<str>,
37892    {
37893        self._additional_params
37894            .insert(name.as_ref().to_string(), value.as_ref().to_string());
37895        self
37896    }
37897
37898    /// Identifies the authorization scope for the method you are building.
37899    ///
37900    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
37901    /// [`Scope::Dfatrafficking`].
37902    ///
37903    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
37904    /// tokens for more than one scope.
37905    ///
37906    /// Usually there is more than one suitable scope to authorize an operation, some of which may
37907    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
37908    /// sufficient, a read-write scope will do as well.
37909    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldInsertCall<'a, C>
37910    where
37911        St: AsRef<str>,
37912    {
37913        self._scopes.insert(String::from(scope.as_ref()));
37914        self
37915    }
37916    /// Identifies the authorization scope(s) for the method you are building.
37917    ///
37918    /// See [`Self::add_scope()`] for details.
37919    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldInsertCall<'a, C>
37920    where
37921        I: IntoIterator<Item = St>,
37922        St: AsRef<str>,
37923    {
37924        self._scopes
37925            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
37926        self
37927    }
37928
37929    /// Removes all scopes, and no default scope will be used either.
37930    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
37931    /// for details).
37932    pub fn clear_scopes(mut self) -> CreativeFieldInsertCall<'a, C> {
37933        self._scopes.clear();
37934        self
37935    }
37936}
37937
37938/// Retrieves a list of creative fields, possibly filtered. This method supports paging.
37939///
37940/// A builder for the *list* method supported by a *creativeField* resource.
37941/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
37942///
37943/// # Example
37944///
37945/// Instantiate a resource method builder
37946///
37947/// ```test_harness,no_run
37948/// # extern crate hyper;
37949/// # extern crate hyper_rustls;
37950/// # extern crate google_dfareporting3d2 as dfareporting3d2;
37951/// # async fn dox() {
37952/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
37953///
37954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
37955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
37956/// #     secret,
37957/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
37958/// # ).build().await.unwrap();
37959///
37960/// # let client = hyper_util::client::legacy::Client::builder(
37961/// #     hyper_util::rt::TokioExecutor::new()
37962/// # )
37963/// # .build(
37964/// #     hyper_rustls::HttpsConnectorBuilder::new()
37965/// #         .with_native_roots()
37966/// #         .unwrap()
37967/// #         .https_or_http()
37968/// #         .enable_http1()
37969/// #         .build()
37970/// # );
37971/// # let mut hub = Dfareporting::new(client, auth);
37972/// // You can configure optional parameters by calling the respective setters at will, and
37973/// // execute the final call using `doit()`.
37974/// // Values shown here are possibly random and not representative !
37975/// let result = hub.creative_fields().list(-14)
37976///              .sort_order("Stet")
37977///              .sort_field("aliquyam")
37978///              .search_string("ut")
37979///              .page_token("sit")
37980///              .max_results(-26)
37981///              .add_ids(-16)
37982///              .add_advertiser_ids(-19)
37983///              .doit().await;
37984/// # }
37985/// ```
37986pub struct CreativeFieldListCall<'a, C>
37987where
37988    C: 'a,
37989{
37990    hub: &'a Dfareporting<C>,
37991    _profile_id: i64,
37992    _sort_order: Option<String>,
37993    _sort_field: Option<String>,
37994    _search_string: Option<String>,
37995    _page_token: Option<String>,
37996    _max_results: Option<i32>,
37997    _ids: Vec<i64>,
37998    _advertiser_ids: Vec<i64>,
37999    _delegate: Option<&'a mut dyn common::Delegate>,
38000    _additional_params: HashMap<String, String>,
38001    _scopes: BTreeSet<String>,
38002}
38003
38004impl<'a, C> common::CallBuilder for CreativeFieldListCall<'a, C> {}
38005
38006impl<'a, C> CreativeFieldListCall<'a, C>
38007where
38008    C: common::Connector,
38009{
38010    /// Perform the operation you have build so far.
38011    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeFieldsListResponse)> {
38012        use std::borrow::Cow;
38013        use std::io::{Read, Seek};
38014
38015        use common::{url::Params, ToParts};
38016        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38017
38018        let mut dd = common::DefaultDelegate;
38019        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38020        dlg.begin(common::MethodInfo {
38021            id: "dfareporting.creativeFields.list",
38022            http_method: hyper::Method::GET,
38023        });
38024
38025        for &field in [
38026            "alt",
38027            "profileId",
38028            "sortOrder",
38029            "sortField",
38030            "searchString",
38031            "pageToken",
38032            "maxResults",
38033            "ids",
38034            "advertiserIds",
38035        ]
38036        .iter()
38037        {
38038            if self._additional_params.contains_key(field) {
38039                dlg.finished(false);
38040                return Err(common::Error::FieldClash(field));
38041            }
38042        }
38043
38044        let mut params = Params::with_capacity(10 + self._additional_params.len());
38045        params.push("profileId", self._profile_id.to_string());
38046        if let Some(value) = self._sort_order.as_ref() {
38047            params.push("sortOrder", value);
38048        }
38049        if let Some(value) = self._sort_field.as_ref() {
38050            params.push("sortField", value);
38051        }
38052        if let Some(value) = self._search_string.as_ref() {
38053            params.push("searchString", value);
38054        }
38055        if let Some(value) = self._page_token.as_ref() {
38056            params.push("pageToken", value);
38057        }
38058        if let Some(value) = self._max_results.as_ref() {
38059            params.push("maxResults", value.to_string());
38060        }
38061        if !self._ids.is_empty() {
38062            for f in self._ids.iter() {
38063                params.push("ids", f.to_string());
38064            }
38065        }
38066        if !self._advertiser_ids.is_empty() {
38067            for f in self._advertiser_ids.iter() {
38068                params.push("advertiserIds", f.to_string());
38069            }
38070        }
38071
38072        params.extend(self._additional_params.iter());
38073
38074        params.push("alt", "json");
38075        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields";
38076        if self._scopes.is_empty() {
38077            self._scopes
38078                .insert(Scope::Dfatrafficking.as_ref().to_string());
38079        }
38080
38081        #[allow(clippy::single_element_loop)]
38082        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
38083            url = params.uri_replacement(url, param_name, find_this, false);
38084        }
38085        {
38086            let to_remove = ["profileId"];
38087            params.remove_params(&to_remove);
38088        }
38089
38090        let url = params.parse_with_url(&url);
38091
38092        loop {
38093            let token = match self
38094                .hub
38095                .auth
38096                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38097                .await
38098            {
38099                Ok(token) => token,
38100                Err(e) => match dlg.token(e) {
38101                    Ok(token) => token,
38102                    Err(e) => {
38103                        dlg.finished(false);
38104                        return Err(common::Error::MissingToken(e));
38105                    }
38106                },
38107            };
38108            let mut req_result = {
38109                let client = &self.hub.client;
38110                dlg.pre_request();
38111                let mut req_builder = hyper::Request::builder()
38112                    .method(hyper::Method::GET)
38113                    .uri(url.as_str())
38114                    .header(USER_AGENT, self.hub._user_agent.clone());
38115
38116                if let Some(token) = token.as_ref() {
38117                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38118                }
38119
38120                let request = req_builder
38121                    .header(CONTENT_LENGTH, 0_u64)
38122                    .body(common::to_body::<String>(None));
38123
38124                client.request(request.unwrap()).await
38125            };
38126
38127            match req_result {
38128                Err(err) => {
38129                    if let common::Retry::After(d) = dlg.http_error(&err) {
38130                        sleep(d).await;
38131                        continue;
38132                    }
38133                    dlg.finished(false);
38134                    return Err(common::Error::HttpError(err));
38135                }
38136                Ok(res) => {
38137                    let (mut parts, body) = res.into_parts();
38138                    let mut body = common::Body::new(body);
38139                    if !parts.status.is_success() {
38140                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38141                        let error = serde_json::from_str(&common::to_string(&bytes));
38142                        let response = common::to_response(parts, bytes.into());
38143
38144                        if let common::Retry::After(d) =
38145                            dlg.http_failure(&response, error.as_ref().ok())
38146                        {
38147                            sleep(d).await;
38148                            continue;
38149                        }
38150
38151                        dlg.finished(false);
38152
38153                        return Err(match error {
38154                            Ok(value) => common::Error::BadRequest(value),
38155                            _ => common::Error::Failure(response),
38156                        });
38157                    }
38158                    let response = {
38159                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38160                        let encoded = common::to_string(&bytes);
38161                        match serde_json::from_str(&encoded) {
38162                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38163                            Err(error) => {
38164                                dlg.response_json_decode_error(&encoded, &error);
38165                                return Err(common::Error::JsonDecodeError(
38166                                    encoded.to_string(),
38167                                    error,
38168                                ));
38169                            }
38170                        }
38171                    };
38172
38173                    dlg.finished(true);
38174                    return Ok(response);
38175                }
38176            }
38177        }
38178    }
38179
38180    /// User profile ID associated with this request.
38181    ///
38182    /// Sets the *profile id* path property to the given value.
38183    ///
38184    /// Even though the property as already been set when instantiating this call,
38185    /// we provide this method for API completeness.
38186    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldListCall<'a, C> {
38187        self._profile_id = new_value;
38188        self
38189    }
38190    /// Order of sorted results.
38191    ///
38192    /// Sets the *sort order* query property to the given value.
38193    pub fn sort_order(mut self, new_value: &str) -> CreativeFieldListCall<'a, C> {
38194        self._sort_order = Some(new_value.to_string());
38195        self
38196    }
38197    /// Field by which to sort the list.
38198    ///
38199    /// Sets the *sort field* query property to the given value.
38200    pub fn sort_field(mut self, new_value: &str) -> CreativeFieldListCall<'a, C> {
38201        self._sort_field = Some(new_value.to_string());
38202        self
38203    }
38204    /// Allows searching for creative fields by name or ID. Wildcards (*) are allowed. For example, "creativefield*2015" will return creative fields with names like "creativefield June 2015", "creativefield April 2015", or simply "creativefield 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativefield" will match creative fields with the name "my creativefield", "creativefield 2015", or simply "creativefield".
38205    ///
38206    /// Sets the *search string* query property to the given value.
38207    pub fn search_string(mut self, new_value: &str) -> CreativeFieldListCall<'a, C> {
38208        self._search_string = Some(new_value.to_string());
38209        self
38210    }
38211    /// Value of the nextPageToken from the previous result page.
38212    ///
38213    /// Sets the *page token* query property to the given value.
38214    pub fn page_token(mut self, new_value: &str) -> CreativeFieldListCall<'a, C> {
38215        self._page_token = Some(new_value.to_string());
38216        self
38217    }
38218    /// Maximum number of results to return.
38219    ///
38220    /// Sets the *max results* query property to the given value.
38221    pub fn max_results(mut self, new_value: i32) -> CreativeFieldListCall<'a, C> {
38222        self._max_results = Some(new_value);
38223        self
38224    }
38225    /// Select only creative fields with these IDs.
38226    ///
38227    /// Append the given value to the *ids* query property.
38228    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
38229    pub fn add_ids(mut self, new_value: i64) -> CreativeFieldListCall<'a, C> {
38230        self._ids.push(new_value);
38231        self
38232    }
38233    /// Select only creative fields that belong to these advertisers.
38234    ///
38235    /// Append the given value to the *advertiser ids* query property.
38236    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
38237    pub fn add_advertiser_ids(mut self, new_value: i64) -> CreativeFieldListCall<'a, C> {
38238        self._advertiser_ids.push(new_value);
38239        self
38240    }
38241    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38242    /// while executing the actual API request.
38243    ///
38244    /// ````text
38245    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
38246    /// ````
38247    ///
38248    /// Sets the *delegate* property to the given value.
38249    pub fn delegate(
38250        mut self,
38251        new_value: &'a mut dyn common::Delegate,
38252    ) -> CreativeFieldListCall<'a, C> {
38253        self._delegate = Some(new_value);
38254        self
38255    }
38256
38257    /// Set any additional parameter of the query string used in the request.
38258    /// It should be used to set parameters which are not yet available through their own
38259    /// setters.
38260    ///
38261    /// Please note that this method must not be used to set any of the known parameters
38262    /// which have their own setter method. If done anyway, the request will fail.
38263    ///
38264    /// # Additional Parameters
38265    ///
38266    /// * *alt* (query-string) - Data format for the response.
38267    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38268    /// * *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.
38269    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38270    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38271    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
38272    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
38273    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldListCall<'a, C>
38274    where
38275        T: AsRef<str>,
38276    {
38277        self._additional_params
38278            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38279        self
38280    }
38281
38282    /// Identifies the authorization scope for the method you are building.
38283    ///
38284    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38285    /// [`Scope::Dfatrafficking`].
38286    ///
38287    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38288    /// tokens for more than one scope.
38289    ///
38290    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38291    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38292    /// sufficient, a read-write scope will do as well.
38293    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldListCall<'a, C>
38294    where
38295        St: AsRef<str>,
38296    {
38297        self._scopes.insert(String::from(scope.as_ref()));
38298        self
38299    }
38300    /// Identifies the authorization scope(s) for the method you are building.
38301    ///
38302    /// See [`Self::add_scope()`] for details.
38303    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldListCall<'a, C>
38304    where
38305        I: IntoIterator<Item = St>,
38306        St: AsRef<str>,
38307    {
38308        self._scopes
38309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38310        self
38311    }
38312
38313    /// Removes all scopes, and no default scope will be used either.
38314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38315    /// for details).
38316    pub fn clear_scopes(mut self) -> CreativeFieldListCall<'a, C> {
38317        self._scopes.clear();
38318        self
38319    }
38320}
38321
38322/// Updates an existing creative field. This method supports patch semantics.
38323///
38324/// A builder for the *patch* method supported by a *creativeField* resource.
38325/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
38326///
38327/// # Example
38328///
38329/// Instantiate a resource method builder
38330///
38331/// ```test_harness,no_run
38332/// # extern crate hyper;
38333/// # extern crate hyper_rustls;
38334/// # extern crate google_dfareporting3d2 as dfareporting3d2;
38335/// use dfareporting3d2::api::CreativeField;
38336/// # async fn dox() {
38337/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38338///
38339/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38340/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
38341/// #     secret,
38342/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38343/// # ).build().await.unwrap();
38344///
38345/// # let client = hyper_util::client::legacy::Client::builder(
38346/// #     hyper_util::rt::TokioExecutor::new()
38347/// # )
38348/// # .build(
38349/// #     hyper_rustls::HttpsConnectorBuilder::new()
38350/// #         .with_native_roots()
38351/// #         .unwrap()
38352/// #         .https_or_http()
38353/// #         .enable_http1()
38354/// #         .build()
38355/// # );
38356/// # let mut hub = Dfareporting::new(client, auth);
38357/// // As the method needs a request, you would usually fill it with the desired information
38358/// // into the respective structure. Some of the parts shown here might not be applicable !
38359/// // Values shown here are possibly random and not representative !
38360/// let mut req = CreativeField::default();
38361///
38362/// // You can configure optional parameters by calling the respective setters at will, and
38363/// // execute the final call using `doit()`.
38364/// // Values shown here are possibly random and not representative !
38365/// let result = hub.creative_fields().patch(req, -96, -19)
38366///              .doit().await;
38367/// # }
38368/// ```
38369pub struct CreativeFieldPatchCall<'a, C>
38370where
38371    C: 'a,
38372{
38373    hub: &'a Dfareporting<C>,
38374    _request: CreativeField,
38375    _profile_id: i64,
38376    _id: i64,
38377    _delegate: Option<&'a mut dyn common::Delegate>,
38378    _additional_params: HashMap<String, String>,
38379    _scopes: BTreeSet<String>,
38380}
38381
38382impl<'a, C> common::CallBuilder for CreativeFieldPatchCall<'a, C> {}
38383
38384impl<'a, C> CreativeFieldPatchCall<'a, C>
38385where
38386    C: common::Connector,
38387{
38388    /// Perform the operation you have build so far.
38389    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeField)> {
38390        use std::borrow::Cow;
38391        use std::io::{Read, Seek};
38392
38393        use common::{url::Params, ToParts};
38394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38395
38396        let mut dd = common::DefaultDelegate;
38397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38398        dlg.begin(common::MethodInfo {
38399            id: "dfareporting.creativeFields.patch",
38400            http_method: hyper::Method::PATCH,
38401        });
38402
38403        for &field in ["alt", "profileId", "id"].iter() {
38404            if self._additional_params.contains_key(field) {
38405                dlg.finished(false);
38406                return Err(common::Error::FieldClash(field));
38407            }
38408        }
38409
38410        let mut params = Params::with_capacity(5 + self._additional_params.len());
38411        params.push("profileId", self._profile_id.to_string());
38412        params.push("id", self._id.to_string());
38413
38414        params.extend(self._additional_params.iter());
38415
38416        params.push("alt", "json");
38417        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields";
38418        if self._scopes.is_empty() {
38419            self._scopes
38420                .insert(Scope::Dfatrafficking.as_ref().to_string());
38421        }
38422
38423        #[allow(clippy::single_element_loop)]
38424        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
38425            url = params.uri_replacement(url, param_name, find_this, false);
38426        }
38427        {
38428            let to_remove = ["profileId"];
38429            params.remove_params(&to_remove);
38430        }
38431
38432        let url = params.parse_with_url(&url);
38433
38434        let mut json_mime_type = mime::APPLICATION_JSON;
38435        let mut request_value_reader = {
38436            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
38437            common::remove_json_null_values(&mut value);
38438            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
38439            serde_json::to_writer(&mut dst, &value).unwrap();
38440            dst
38441        };
38442        let request_size = request_value_reader
38443            .seek(std::io::SeekFrom::End(0))
38444            .unwrap();
38445        request_value_reader
38446            .seek(std::io::SeekFrom::Start(0))
38447            .unwrap();
38448
38449        loop {
38450            let token = match self
38451                .hub
38452                .auth
38453                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38454                .await
38455            {
38456                Ok(token) => token,
38457                Err(e) => match dlg.token(e) {
38458                    Ok(token) => token,
38459                    Err(e) => {
38460                        dlg.finished(false);
38461                        return Err(common::Error::MissingToken(e));
38462                    }
38463                },
38464            };
38465            request_value_reader
38466                .seek(std::io::SeekFrom::Start(0))
38467                .unwrap();
38468            let mut req_result = {
38469                let client = &self.hub.client;
38470                dlg.pre_request();
38471                let mut req_builder = hyper::Request::builder()
38472                    .method(hyper::Method::PATCH)
38473                    .uri(url.as_str())
38474                    .header(USER_AGENT, self.hub._user_agent.clone());
38475
38476                if let Some(token) = token.as_ref() {
38477                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38478                }
38479
38480                let request = req_builder
38481                    .header(CONTENT_TYPE, json_mime_type.to_string())
38482                    .header(CONTENT_LENGTH, request_size as u64)
38483                    .body(common::to_body(
38484                        request_value_reader.get_ref().clone().into(),
38485                    ));
38486
38487                client.request(request.unwrap()).await
38488            };
38489
38490            match req_result {
38491                Err(err) => {
38492                    if let common::Retry::After(d) = dlg.http_error(&err) {
38493                        sleep(d).await;
38494                        continue;
38495                    }
38496                    dlg.finished(false);
38497                    return Err(common::Error::HttpError(err));
38498                }
38499                Ok(res) => {
38500                    let (mut parts, body) = res.into_parts();
38501                    let mut body = common::Body::new(body);
38502                    if !parts.status.is_success() {
38503                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38504                        let error = serde_json::from_str(&common::to_string(&bytes));
38505                        let response = common::to_response(parts, bytes.into());
38506
38507                        if let common::Retry::After(d) =
38508                            dlg.http_failure(&response, error.as_ref().ok())
38509                        {
38510                            sleep(d).await;
38511                            continue;
38512                        }
38513
38514                        dlg.finished(false);
38515
38516                        return Err(match error {
38517                            Ok(value) => common::Error::BadRequest(value),
38518                            _ => common::Error::Failure(response),
38519                        });
38520                    }
38521                    let response = {
38522                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38523                        let encoded = common::to_string(&bytes);
38524                        match serde_json::from_str(&encoded) {
38525                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38526                            Err(error) => {
38527                                dlg.response_json_decode_error(&encoded, &error);
38528                                return Err(common::Error::JsonDecodeError(
38529                                    encoded.to_string(),
38530                                    error,
38531                                ));
38532                            }
38533                        }
38534                    };
38535
38536                    dlg.finished(true);
38537                    return Ok(response);
38538                }
38539            }
38540        }
38541    }
38542
38543    ///
38544    /// Sets the *request* property to the given value.
38545    ///
38546    /// Even though the property as already been set when instantiating this call,
38547    /// we provide this method for API completeness.
38548    pub fn request(mut self, new_value: CreativeField) -> CreativeFieldPatchCall<'a, C> {
38549        self._request = new_value;
38550        self
38551    }
38552    /// User profile ID associated with this request.
38553    ///
38554    /// Sets the *profile id* path property to the given value.
38555    ///
38556    /// Even though the property as already been set when instantiating this call,
38557    /// we provide this method for API completeness.
38558    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldPatchCall<'a, C> {
38559        self._profile_id = new_value;
38560        self
38561    }
38562    /// Creative Field ID
38563    ///
38564    /// Sets the *id* query property to the given value.
38565    ///
38566    /// Even though the property as already been set when instantiating this call,
38567    /// we provide this method for API completeness.
38568    pub fn id(mut self, new_value: i64) -> CreativeFieldPatchCall<'a, C> {
38569        self._id = new_value;
38570        self
38571    }
38572    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38573    /// while executing the actual API request.
38574    ///
38575    /// ````text
38576    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
38577    /// ````
38578    ///
38579    /// Sets the *delegate* property to the given value.
38580    pub fn delegate(
38581        mut self,
38582        new_value: &'a mut dyn common::Delegate,
38583    ) -> CreativeFieldPatchCall<'a, C> {
38584        self._delegate = Some(new_value);
38585        self
38586    }
38587
38588    /// Set any additional parameter of the query string used in the request.
38589    /// It should be used to set parameters which are not yet available through their own
38590    /// setters.
38591    ///
38592    /// Please note that this method must not be used to set any of the known parameters
38593    /// which have their own setter method. If done anyway, the request will fail.
38594    ///
38595    /// # Additional Parameters
38596    ///
38597    /// * *alt* (query-string) - Data format for the response.
38598    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38599    /// * *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.
38600    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38601    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38602    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
38603    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
38604    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldPatchCall<'a, C>
38605    where
38606        T: AsRef<str>,
38607    {
38608        self._additional_params
38609            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38610        self
38611    }
38612
38613    /// Identifies the authorization scope for the method you are building.
38614    ///
38615    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38616    /// [`Scope::Dfatrafficking`].
38617    ///
38618    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38619    /// tokens for more than one scope.
38620    ///
38621    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38622    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38623    /// sufficient, a read-write scope will do as well.
38624    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldPatchCall<'a, C>
38625    where
38626        St: AsRef<str>,
38627    {
38628        self._scopes.insert(String::from(scope.as_ref()));
38629        self
38630    }
38631    /// Identifies the authorization scope(s) for the method you are building.
38632    ///
38633    /// See [`Self::add_scope()`] for details.
38634    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldPatchCall<'a, C>
38635    where
38636        I: IntoIterator<Item = St>,
38637        St: AsRef<str>,
38638    {
38639        self._scopes
38640            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38641        self
38642    }
38643
38644    /// Removes all scopes, and no default scope will be used either.
38645    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38646    /// for details).
38647    pub fn clear_scopes(mut self) -> CreativeFieldPatchCall<'a, C> {
38648        self._scopes.clear();
38649        self
38650    }
38651}
38652
38653/// Updates an existing creative field.
38654///
38655/// A builder for the *update* method supported by a *creativeField* resource.
38656/// It is not used directly, but through a [`CreativeFieldMethods`] instance.
38657///
38658/// # Example
38659///
38660/// Instantiate a resource method builder
38661///
38662/// ```test_harness,no_run
38663/// # extern crate hyper;
38664/// # extern crate hyper_rustls;
38665/// # extern crate google_dfareporting3d2 as dfareporting3d2;
38666/// use dfareporting3d2::api::CreativeField;
38667/// # async fn dox() {
38668/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38669///
38670/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
38672/// #     secret,
38673/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38674/// # ).build().await.unwrap();
38675///
38676/// # let client = hyper_util::client::legacy::Client::builder(
38677/// #     hyper_util::rt::TokioExecutor::new()
38678/// # )
38679/// # .build(
38680/// #     hyper_rustls::HttpsConnectorBuilder::new()
38681/// #         .with_native_roots()
38682/// #         .unwrap()
38683/// #         .https_or_http()
38684/// #         .enable_http1()
38685/// #         .build()
38686/// # );
38687/// # let mut hub = Dfareporting::new(client, auth);
38688/// // As the method needs a request, you would usually fill it with the desired information
38689/// // into the respective structure. Some of the parts shown here might not be applicable !
38690/// // Values shown here are possibly random and not representative !
38691/// let mut req = CreativeField::default();
38692///
38693/// // You can configure optional parameters by calling the respective setters at will, and
38694/// // execute the final call using `doit()`.
38695/// // Values shown here are possibly random and not representative !
38696/// let result = hub.creative_fields().update(req, -30)
38697///              .doit().await;
38698/// # }
38699/// ```
38700pub struct CreativeFieldUpdateCall<'a, C>
38701where
38702    C: 'a,
38703{
38704    hub: &'a Dfareporting<C>,
38705    _request: CreativeField,
38706    _profile_id: i64,
38707    _delegate: Option<&'a mut dyn common::Delegate>,
38708    _additional_params: HashMap<String, String>,
38709    _scopes: BTreeSet<String>,
38710}
38711
38712impl<'a, C> common::CallBuilder for CreativeFieldUpdateCall<'a, C> {}
38713
38714impl<'a, C> CreativeFieldUpdateCall<'a, C>
38715where
38716    C: common::Connector,
38717{
38718    /// Perform the operation you have build so far.
38719    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeField)> {
38720        use std::borrow::Cow;
38721        use std::io::{Read, Seek};
38722
38723        use common::{url::Params, ToParts};
38724        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
38725
38726        let mut dd = common::DefaultDelegate;
38727        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
38728        dlg.begin(common::MethodInfo {
38729            id: "dfareporting.creativeFields.update",
38730            http_method: hyper::Method::PUT,
38731        });
38732
38733        for &field in ["alt", "profileId"].iter() {
38734            if self._additional_params.contains_key(field) {
38735                dlg.finished(false);
38736                return Err(common::Error::FieldClash(field));
38737            }
38738        }
38739
38740        let mut params = Params::with_capacity(4 + self._additional_params.len());
38741        params.push("profileId", self._profile_id.to_string());
38742
38743        params.extend(self._additional_params.iter());
38744
38745        params.push("alt", "json");
38746        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields";
38747        if self._scopes.is_empty() {
38748            self._scopes
38749                .insert(Scope::Dfatrafficking.as_ref().to_string());
38750        }
38751
38752        #[allow(clippy::single_element_loop)]
38753        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
38754            url = params.uri_replacement(url, param_name, find_this, false);
38755        }
38756        {
38757            let to_remove = ["profileId"];
38758            params.remove_params(&to_remove);
38759        }
38760
38761        let url = params.parse_with_url(&url);
38762
38763        let mut json_mime_type = mime::APPLICATION_JSON;
38764        let mut request_value_reader = {
38765            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
38766            common::remove_json_null_values(&mut value);
38767            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
38768            serde_json::to_writer(&mut dst, &value).unwrap();
38769            dst
38770        };
38771        let request_size = request_value_reader
38772            .seek(std::io::SeekFrom::End(0))
38773            .unwrap();
38774        request_value_reader
38775            .seek(std::io::SeekFrom::Start(0))
38776            .unwrap();
38777
38778        loop {
38779            let token = match self
38780                .hub
38781                .auth
38782                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
38783                .await
38784            {
38785                Ok(token) => token,
38786                Err(e) => match dlg.token(e) {
38787                    Ok(token) => token,
38788                    Err(e) => {
38789                        dlg.finished(false);
38790                        return Err(common::Error::MissingToken(e));
38791                    }
38792                },
38793            };
38794            request_value_reader
38795                .seek(std::io::SeekFrom::Start(0))
38796                .unwrap();
38797            let mut req_result = {
38798                let client = &self.hub.client;
38799                dlg.pre_request();
38800                let mut req_builder = hyper::Request::builder()
38801                    .method(hyper::Method::PUT)
38802                    .uri(url.as_str())
38803                    .header(USER_AGENT, self.hub._user_agent.clone());
38804
38805                if let Some(token) = token.as_ref() {
38806                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
38807                }
38808
38809                let request = req_builder
38810                    .header(CONTENT_TYPE, json_mime_type.to_string())
38811                    .header(CONTENT_LENGTH, request_size as u64)
38812                    .body(common::to_body(
38813                        request_value_reader.get_ref().clone().into(),
38814                    ));
38815
38816                client.request(request.unwrap()).await
38817            };
38818
38819            match req_result {
38820                Err(err) => {
38821                    if let common::Retry::After(d) = dlg.http_error(&err) {
38822                        sleep(d).await;
38823                        continue;
38824                    }
38825                    dlg.finished(false);
38826                    return Err(common::Error::HttpError(err));
38827                }
38828                Ok(res) => {
38829                    let (mut parts, body) = res.into_parts();
38830                    let mut body = common::Body::new(body);
38831                    if !parts.status.is_success() {
38832                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38833                        let error = serde_json::from_str(&common::to_string(&bytes));
38834                        let response = common::to_response(parts, bytes.into());
38835
38836                        if let common::Retry::After(d) =
38837                            dlg.http_failure(&response, error.as_ref().ok())
38838                        {
38839                            sleep(d).await;
38840                            continue;
38841                        }
38842
38843                        dlg.finished(false);
38844
38845                        return Err(match error {
38846                            Ok(value) => common::Error::BadRequest(value),
38847                            _ => common::Error::Failure(response),
38848                        });
38849                    }
38850                    let response = {
38851                        let bytes = common::to_bytes(body).await.unwrap_or_default();
38852                        let encoded = common::to_string(&bytes);
38853                        match serde_json::from_str(&encoded) {
38854                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
38855                            Err(error) => {
38856                                dlg.response_json_decode_error(&encoded, &error);
38857                                return Err(common::Error::JsonDecodeError(
38858                                    encoded.to_string(),
38859                                    error,
38860                                ));
38861                            }
38862                        }
38863                    };
38864
38865                    dlg.finished(true);
38866                    return Ok(response);
38867                }
38868            }
38869        }
38870    }
38871
38872    ///
38873    /// Sets the *request* property to the given value.
38874    ///
38875    /// Even though the property as already been set when instantiating this call,
38876    /// we provide this method for API completeness.
38877    pub fn request(mut self, new_value: CreativeField) -> CreativeFieldUpdateCall<'a, C> {
38878        self._request = new_value;
38879        self
38880    }
38881    /// User profile ID associated with this request.
38882    ///
38883    /// Sets the *profile id* path property to the given value.
38884    ///
38885    /// Even though the property as already been set when instantiating this call,
38886    /// we provide this method for API completeness.
38887    pub fn profile_id(mut self, new_value: i64) -> CreativeFieldUpdateCall<'a, C> {
38888        self._profile_id = new_value;
38889        self
38890    }
38891    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
38892    /// while executing the actual API request.
38893    ///
38894    /// ````text
38895    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
38896    /// ````
38897    ///
38898    /// Sets the *delegate* property to the given value.
38899    pub fn delegate(
38900        mut self,
38901        new_value: &'a mut dyn common::Delegate,
38902    ) -> CreativeFieldUpdateCall<'a, C> {
38903        self._delegate = Some(new_value);
38904        self
38905    }
38906
38907    /// Set any additional parameter of the query string used in the request.
38908    /// It should be used to set parameters which are not yet available through their own
38909    /// setters.
38910    ///
38911    /// Please note that this method must not be used to set any of the known parameters
38912    /// which have their own setter method. If done anyway, the request will fail.
38913    ///
38914    /// # Additional Parameters
38915    ///
38916    /// * *alt* (query-string) - Data format for the response.
38917    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
38918    /// * *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.
38919    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
38920    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
38921    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
38922    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
38923    pub fn param<T>(mut self, name: T, value: T) -> CreativeFieldUpdateCall<'a, C>
38924    where
38925        T: AsRef<str>,
38926    {
38927        self._additional_params
38928            .insert(name.as_ref().to_string(), value.as_ref().to_string());
38929        self
38930    }
38931
38932    /// Identifies the authorization scope for the method you are building.
38933    ///
38934    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
38935    /// [`Scope::Dfatrafficking`].
38936    ///
38937    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
38938    /// tokens for more than one scope.
38939    ///
38940    /// Usually there is more than one suitable scope to authorize an operation, some of which may
38941    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
38942    /// sufficient, a read-write scope will do as well.
38943    pub fn add_scope<St>(mut self, scope: St) -> CreativeFieldUpdateCall<'a, C>
38944    where
38945        St: AsRef<str>,
38946    {
38947        self._scopes.insert(String::from(scope.as_ref()));
38948        self
38949    }
38950    /// Identifies the authorization scope(s) for the method you are building.
38951    ///
38952    /// See [`Self::add_scope()`] for details.
38953    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeFieldUpdateCall<'a, C>
38954    where
38955        I: IntoIterator<Item = St>,
38956        St: AsRef<str>,
38957    {
38958        self._scopes
38959            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
38960        self
38961    }
38962
38963    /// Removes all scopes, and no default scope will be used either.
38964    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
38965    /// for details).
38966    pub fn clear_scopes(mut self) -> CreativeFieldUpdateCall<'a, C> {
38967        self._scopes.clear();
38968        self
38969    }
38970}
38971
38972/// Gets one creative group by ID.
38973///
38974/// A builder for the *get* method supported by a *creativeGroup* resource.
38975/// It is not used directly, but through a [`CreativeGroupMethods`] instance.
38976///
38977/// # Example
38978///
38979/// Instantiate a resource method builder
38980///
38981/// ```test_harness,no_run
38982/// # extern crate hyper;
38983/// # extern crate hyper_rustls;
38984/// # extern crate google_dfareporting3d2 as dfareporting3d2;
38985/// # async fn dox() {
38986/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
38987///
38988/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
38989/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
38990/// #     secret,
38991/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
38992/// # ).build().await.unwrap();
38993///
38994/// # let client = hyper_util::client::legacy::Client::builder(
38995/// #     hyper_util::rt::TokioExecutor::new()
38996/// # )
38997/// # .build(
38998/// #     hyper_rustls::HttpsConnectorBuilder::new()
38999/// #         .with_native_roots()
39000/// #         .unwrap()
39001/// #         .https_or_http()
39002/// #         .enable_http1()
39003/// #         .build()
39004/// # );
39005/// # let mut hub = Dfareporting::new(client, auth);
39006/// // You can configure optional parameters by calling the respective setters at will, and
39007/// // execute the final call using `doit()`.
39008/// // Values shown here are possibly random and not representative !
39009/// let result = hub.creative_groups().get(-38, -64)
39010///              .doit().await;
39011/// # }
39012/// ```
39013pub struct CreativeGroupGetCall<'a, C>
39014where
39015    C: 'a,
39016{
39017    hub: &'a Dfareporting<C>,
39018    _profile_id: i64,
39019    _id: i64,
39020    _delegate: Option<&'a mut dyn common::Delegate>,
39021    _additional_params: HashMap<String, String>,
39022    _scopes: BTreeSet<String>,
39023}
39024
39025impl<'a, C> common::CallBuilder for CreativeGroupGetCall<'a, C> {}
39026
39027impl<'a, C> CreativeGroupGetCall<'a, C>
39028where
39029    C: common::Connector,
39030{
39031    /// Perform the operation you have build so far.
39032    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeGroup)> {
39033        use std::borrow::Cow;
39034        use std::io::{Read, Seek};
39035
39036        use common::{url::Params, ToParts};
39037        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
39038
39039        let mut dd = common::DefaultDelegate;
39040        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
39041        dlg.begin(common::MethodInfo {
39042            id: "dfareporting.creativeGroups.get",
39043            http_method: hyper::Method::GET,
39044        });
39045
39046        for &field in ["alt", "profileId", "id"].iter() {
39047            if self._additional_params.contains_key(field) {
39048                dlg.finished(false);
39049                return Err(common::Error::FieldClash(field));
39050            }
39051        }
39052
39053        let mut params = Params::with_capacity(4 + self._additional_params.len());
39054        params.push("profileId", self._profile_id.to_string());
39055        params.push("id", self._id.to_string());
39056
39057        params.extend(self._additional_params.iter());
39058
39059        params.push("alt", "json");
39060        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups/{id}";
39061        if self._scopes.is_empty() {
39062            self._scopes
39063                .insert(Scope::Dfatrafficking.as_ref().to_string());
39064        }
39065
39066        #[allow(clippy::single_element_loop)]
39067        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
39068            url = params.uri_replacement(url, param_name, find_this, false);
39069        }
39070        {
39071            let to_remove = ["id", "profileId"];
39072            params.remove_params(&to_remove);
39073        }
39074
39075        let url = params.parse_with_url(&url);
39076
39077        loop {
39078            let token = match self
39079                .hub
39080                .auth
39081                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
39082                .await
39083            {
39084                Ok(token) => token,
39085                Err(e) => match dlg.token(e) {
39086                    Ok(token) => token,
39087                    Err(e) => {
39088                        dlg.finished(false);
39089                        return Err(common::Error::MissingToken(e));
39090                    }
39091                },
39092            };
39093            let mut req_result = {
39094                let client = &self.hub.client;
39095                dlg.pre_request();
39096                let mut req_builder = hyper::Request::builder()
39097                    .method(hyper::Method::GET)
39098                    .uri(url.as_str())
39099                    .header(USER_AGENT, self.hub._user_agent.clone());
39100
39101                if let Some(token) = token.as_ref() {
39102                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
39103                }
39104
39105                let request = req_builder
39106                    .header(CONTENT_LENGTH, 0_u64)
39107                    .body(common::to_body::<String>(None));
39108
39109                client.request(request.unwrap()).await
39110            };
39111
39112            match req_result {
39113                Err(err) => {
39114                    if let common::Retry::After(d) = dlg.http_error(&err) {
39115                        sleep(d).await;
39116                        continue;
39117                    }
39118                    dlg.finished(false);
39119                    return Err(common::Error::HttpError(err));
39120                }
39121                Ok(res) => {
39122                    let (mut parts, body) = res.into_parts();
39123                    let mut body = common::Body::new(body);
39124                    if !parts.status.is_success() {
39125                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39126                        let error = serde_json::from_str(&common::to_string(&bytes));
39127                        let response = common::to_response(parts, bytes.into());
39128
39129                        if let common::Retry::After(d) =
39130                            dlg.http_failure(&response, error.as_ref().ok())
39131                        {
39132                            sleep(d).await;
39133                            continue;
39134                        }
39135
39136                        dlg.finished(false);
39137
39138                        return Err(match error {
39139                            Ok(value) => common::Error::BadRequest(value),
39140                            _ => common::Error::Failure(response),
39141                        });
39142                    }
39143                    let response = {
39144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39145                        let encoded = common::to_string(&bytes);
39146                        match serde_json::from_str(&encoded) {
39147                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
39148                            Err(error) => {
39149                                dlg.response_json_decode_error(&encoded, &error);
39150                                return Err(common::Error::JsonDecodeError(
39151                                    encoded.to_string(),
39152                                    error,
39153                                ));
39154                            }
39155                        }
39156                    };
39157
39158                    dlg.finished(true);
39159                    return Ok(response);
39160                }
39161            }
39162        }
39163    }
39164
39165    /// User profile ID associated with this request.
39166    ///
39167    /// Sets the *profile id* path property to the given value.
39168    ///
39169    /// Even though the property as already been set when instantiating this call,
39170    /// we provide this method for API completeness.
39171    pub fn profile_id(mut self, new_value: i64) -> CreativeGroupGetCall<'a, C> {
39172        self._profile_id = new_value;
39173        self
39174    }
39175    /// Creative group ID.
39176    ///
39177    /// Sets the *id* path property to the given value.
39178    ///
39179    /// Even though the property as already been set when instantiating this call,
39180    /// we provide this method for API completeness.
39181    pub fn id(mut self, new_value: i64) -> CreativeGroupGetCall<'a, C> {
39182        self._id = new_value;
39183        self
39184    }
39185    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
39186    /// while executing the actual API request.
39187    ///
39188    /// ````text
39189    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
39190    /// ````
39191    ///
39192    /// Sets the *delegate* property to the given value.
39193    pub fn delegate(
39194        mut self,
39195        new_value: &'a mut dyn common::Delegate,
39196    ) -> CreativeGroupGetCall<'a, C> {
39197        self._delegate = Some(new_value);
39198        self
39199    }
39200
39201    /// Set any additional parameter of the query string used in the request.
39202    /// It should be used to set parameters which are not yet available through their own
39203    /// setters.
39204    ///
39205    /// Please note that this method must not be used to set any of the known parameters
39206    /// which have their own setter method. If done anyway, the request will fail.
39207    ///
39208    /// # Additional Parameters
39209    ///
39210    /// * *alt* (query-string) - Data format for the response.
39211    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
39212    /// * *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.
39213    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
39214    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
39215    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
39216    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
39217    pub fn param<T>(mut self, name: T, value: T) -> CreativeGroupGetCall<'a, C>
39218    where
39219        T: AsRef<str>,
39220    {
39221        self._additional_params
39222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
39223        self
39224    }
39225
39226    /// Identifies the authorization scope for the method you are building.
39227    ///
39228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
39229    /// [`Scope::Dfatrafficking`].
39230    ///
39231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
39232    /// tokens for more than one scope.
39233    ///
39234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
39235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
39236    /// sufficient, a read-write scope will do as well.
39237    pub fn add_scope<St>(mut self, scope: St) -> CreativeGroupGetCall<'a, C>
39238    where
39239        St: AsRef<str>,
39240    {
39241        self._scopes.insert(String::from(scope.as_ref()));
39242        self
39243    }
39244    /// Identifies the authorization scope(s) for the method you are building.
39245    ///
39246    /// See [`Self::add_scope()`] for details.
39247    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGroupGetCall<'a, C>
39248    where
39249        I: IntoIterator<Item = St>,
39250        St: AsRef<str>,
39251    {
39252        self._scopes
39253            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
39254        self
39255    }
39256
39257    /// Removes all scopes, and no default scope will be used either.
39258    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
39259    /// for details).
39260    pub fn clear_scopes(mut self) -> CreativeGroupGetCall<'a, C> {
39261        self._scopes.clear();
39262        self
39263    }
39264}
39265
39266/// Inserts a new creative group.
39267///
39268/// A builder for the *insert* method supported by a *creativeGroup* resource.
39269/// It is not used directly, but through a [`CreativeGroupMethods`] instance.
39270///
39271/// # Example
39272///
39273/// Instantiate a resource method builder
39274///
39275/// ```test_harness,no_run
39276/// # extern crate hyper;
39277/// # extern crate hyper_rustls;
39278/// # extern crate google_dfareporting3d2 as dfareporting3d2;
39279/// use dfareporting3d2::api::CreativeGroup;
39280/// # async fn dox() {
39281/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
39282///
39283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
39284/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
39285/// #     secret,
39286/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
39287/// # ).build().await.unwrap();
39288///
39289/// # let client = hyper_util::client::legacy::Client::builder(
39290/// #     hyper_util::rt::TokioExecutor::new()
39291/// # )
39292/// # .build(
39293/// #     hyper_rustls::HttpsConnectorBuilder::new()
39294/// #         .with_native_roots()
39295/// #         .unwrap()
39296/// #         .https_or_http()
39297/// #         .enable_http1()
39298/// #         .build()
39299/// # );
39300/// # let mut hub = Dfareporting::new(client, auth);
39301/// // As the method needs a request, you would usually fill it with the desired information
39302/// // into the respective structure. Some of the parts shown here might not be applicable !
39303/// // Values shown here are possibly random and not representative !
39304/// let mut req = CreativeGroup::default();
39305///
39306/// // You can configure optional parameters by calling the respective setters at will, and
39307/// // execute the final call using `doit()`.
39308/// // Values shown here are possibly random and not representative !
39309/// let result = hub.creative_groups().insert(req, -99)
39310///              .doit().await;
39311/// # }
39312/// ```
39313pub struct CreativeGroupInsertCall<'a, C>
39314where
39315    C: 'a,
39316{
39317    hub: &'a Dfareporting<C>,
39318    _request: CreativeGroup,
39319    _profile_id: i64,
39320    _delegate: Option<&'a mut dyn common::Delegate>,
39321    _additional_params: HashMap<String, String>,
39322    _scopes: BTreeSet<String>,
39323}
39324
39325impl<'a, C> common::CallBuilder for CreativeGroupInsertCall<'a, C> {}
39326
39327impl<'a, C> CreativeGroupInsertCall<'a, C>
39328where
39329    C: common::Connector,
39330{
39331    /// Perform the operation you have build so far.
39332    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeGroup)> {
39333        use std::borrow::Cow;
39334        use std::io::{Read, Seek};
39335
39336        use common::{url::Params, ToParts};
39337        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
39338
39339        let mut dd = common::DefaultDelegate;
39340        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
39341        dlg.begin(common::MethodInfo {
39342            id: "dfareporting.creativeGroups.insert",
39343            http_method: hyper::Method::POST,
39344        });
39345
39346        for &field in ["alt", "profileId"].iter() {
39347            if self._additional_params.contains_key(field) {
39348                dlg.finished(false);
39349                return Err(common::Error::FieldClash(field));
39350            }
39351        }
39352
39353        let mut params = Params::with_capacity(4 + self._additional_params.len());
39354        params.push("profileId", self._profile_id.to_string());
39355
39356        params.extend(self._additional_params.iter());
39357
39358        params.push("alt", "json");
39359        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups";
39360        if self._scopes.is_empty() {
39361            self._scopes
39362                .insert(Scope::Dfatrafficking.as_ref().to_string());
39363        }
39364
39365        #[allow(clippy::single_element_loop)]
39366        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
39367            url = params.uri_replacement(url, param_name, find_this, false);
39368        }
39369        {
39370            let to_remove = ["profileId"];
39371            params.remove_params(&to_remove);
39372        }
39373
39374        let url = params.parse_with_url(&url);
39375
39376        let mut json_mime_type = mime::APPLICATION_JSON;
39377        let mut request_value_reader = {
39378            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
39379            common::remove_json_null_values(&mut value);
39380            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
39381            serde_json::to_writer(&mut dst, &value).unwrap();
39382            dst
39383        };
39384        let request_size = request_value_reader
39385            .seek(std::io::SeekFrom::End(0))
39386            .unwrap();
39387        request_value_reader
39388            .seek(std::io::SeekFrom::Start(0))
39389            .unwrap();
39390
39391        loop {
39392            let token = match self
39393                .hub
39394                .auth
39395                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
39396                .await
39397            {
39398                Ok(token) => token,
39399                Err(e) => match dlg.token(e) {
39400                    Ok(token) => token,
39401                    Err(e) => {
39402                        dlg.finished(false);
39403                        return Err(common::Error::MissingToken(e));
39404                    }
39405                },
39406            };
39407            request_value_reader
39408                .seek(std::io::SeekFrom::Start(0))
39409                .unwrap();
39410            let mut req_result = {
39411                let client = &self.hub.client;
39412                dlg.pre_request();
39413                let mut req_builder = hyper::Request::builder()
39414                    .method(hyper::Method::POST)
39415                    .uri(url.as_str())
39416                    .header(USER_AGENT, self.hub._user_agent.clone());
39417
39418                if let Some(token) = token.as_ref() {
39419                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
39420                }
39421
39422                let request = req_builder
39423                    .header(CONTENT_TYPE, json_mime_type.to_string())
39424                    .header(CONTENT_LENGTH, request_size as u64)
39425                    .body(common::to_body(
39426                        request_value_reader.get_ref().clone().into(),
39427                    ));
39428
39429                client.request(request.unwrap()).await
39430            };
39431
39432            match req_result {
39433                Err(err) => {
39434                    if let common::Retry::After(d) = dlg.http_error(&err) {
39435                        sleep(d).await;
39436                        continue;
39437                    }
39438                    dlg.finished(false);
39439                    return Err(common::Error::HttpError(err));
39440                }
39441                Ok(res) => {
39442                    let (mut parts, body) = res.into_parts();
39443                    let mut body = common::Body::new(body);
39444                    if !parts.status.is_success() {
39445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39446                        let error = serde_json::from_str(&common::to_string(&bytes));
39447                        let response = common::to_response(parts, bytes.into());
39448
39449                        if let common::Retry::After(d) =
39450                            dlg.http_failure(&response, error.as_ref().ok())
39451                        {
39452                            sleep(d).await;
39453                            continue;
39454                        }
39455
39456                        dlg.finished(false);
39457
39458                        return Err(match error {
39459                            Ok(value) => common::Error::BadRequest(value),
39460                            _ => common::Error::Failure(response),
39461                        });
39462                    }
39463                    let response = {
39464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39465                        let encoded = common::to_string(&bytes);
39466                        match serde_json::from_str(&encoded) {
39467                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
39468                            Err(error) => {
39469                                dlg.response_json_decode_error(&encoded, &error);
39470                                return Err(common::Error::JsonDecodeError(
39471                                    encoded.to_string(),
39472                                    error,
39473                                ));
39474                            }
39475                        }
39476                    };
39477
39478                    dlg.finished(true);
39479                    return Ok(response);
39480                }
39481            }
39482        }
39483    }
39484
39485    ///
39486    /// Sets the *request* property to the given value.
39487    ///
39488    /// Even though the property as already been set when instantiating this call,
39489    /// we provide this method for API completeness.
39490    pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupInsertCall<'a, C> {
39491        self._request = new_value;
39492        self
39493    }
39494    /// User profile ID associated with this request.
39495    ///
39496    /// Sets the *profile id* path property to the given value.
39497    ///
39498    /// Even though the property as already been set when instantiating this call,
39499    /// we provide this method for API completeness.
39500    pub fn profile_id(mut self, new_value: i64) -> CreativeGroupInsertCall<'a, C> {
39501        self._profile_id = new_value;
39502        self
39503    }
39504    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
39505    /// while executing the actual API request.
39506    ///
39507    /// ````text
39508    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
39509    /// ````
39510    ///
39511    /// Sets the *delegate* property to the given value.
39512    pub fn delegate(
39513        mut self,
39514        new_value: &'a mut dyn common::Delegate,
39515    ) -> CreativeGroupInsertCall<'a, C> {
39516        self._delegate = Some(new_value);
39517        self
39518    }
39519
39520    /// Set any additional parameter of the query string used in the request.
39521    /// It should be used to set parameters which are not yet available through their own
39522    /// setters.
39523    ///
39524    /// Please note that this method must not be used to set any of the known parameters
39525    /// which have their own setter method. If done anyway, the request will fail.
39526    ///
39527    /// # Additional Parameters
39528    ///
39529    /// * *alt* (query-string) - Data format for the response.
39530    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
39531    /// * *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.
39532    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
39533    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
39534    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
39535    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
39536    pub fn param<T>(mut self, name: T, value: T) -> CreativeGroupInsertCall<'a, C>
39537    where
39538        T: AsRef<str>,
39539    {
39540        self._additional_params
39541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
39542        self
39543    }
39544
39545    /// Identifies the authorization scope for the method you are building.
39546    ///
39547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
39548    /// [`Scope::Dfatrafficking`].
39549    ///
39550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
39551    /// tokens for more than one scope.
39552    ///
39553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
39554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
39555    /// sufficient, a read-write scope will do as well.
39556    pub fn add_scope<St>(mut self, scope: St) -> CreativeGroupInsertCall<'a, C>
39557    where
39558        St: AsRef<str>,
39559    {
39560        self._scopes.insert(String::from(scope.as_ref()));
39561        self
39562    }
39563    /// Identifies the authorization scope(s) for the method you are building.
39564    ///
39565    /// See [`Self::add_scope()`] for details.
39566    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGroupInsertCall<'a, C>
39567    where
39568        I: IntoIterator<Item = St>,
39569        St: AsRef<str>,
39570    {
39571        self._scopes
39572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
39573        self
39574    }
39575
39576    /// Removes all scopes, and no default scope will be used either.
39577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
39578    /// for details).
39579    pub fn clear_scopes(mut self) -> CreativeGroupInsertCall<'a, C> {
39580        self._scopes.clear();
39581        self
39582    }
39583}
39584
39585/// Retrieves a list of creative groups, possibly filtered. This method supports paging.
39586///
39587/// A builder for the *list* method supported by a *creativeGroup* resource.
39588/// It is not used directly, but through a [`CreativeGroupMethods`] instance.
39589///
39590/// # Example
39591///
39592/// Instantiate a resource method builder
39593///
39594/// ```test_harness,no_run
39595/// # extern crate hyper;
39596/// # extern crate hyper_rustls;
39597/// # extern crate google_dfareporting3d2 as dfareporting3d2;
39598/// # async fn dox() {
39599/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
39600///
39601/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
39602/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
39603/// #     secret,
39604/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
39605/// # ).build().await.unwrap();
39606///
39607/// # let client = hyper_util::client::legacy::Client::builder(
39608/// #     hyper_util::rt::TokioExecutor::new()
39609/// # )
39610/// # .build(
39611/// #     hyper_rustls::HttpsConnectorBuilder::new()
39612/// #         .with_native_roots()
39613/// #         .unwrap()
39614/// #         .https_or_http()
39615/// #         .enable_http1()
39616/// #         .build()
39617/// # );
39618/// # let mut hub = Dfareporting::new(client, auth);
39619/// // You can configure optional parameters by calling the respective setters at will, and
39620/// // execute the final call using `doit()`.
39621/// // Values shown here are possibly random and not representative !
39622/// let result = hub.creative_groups().list(-82)
39623///              .sort_order("magna")
39624///              .sort_field("diam")
39625///              .search_string("nonumy")
39626///              .page_token("et")
39627///              .max_results(-8)
39628///              .add_ids(-23)
39629///              .group_number(-39)
39630///              .add_advertiser_ids(-43)
39631///              .doit().await;
39632/// # }
39633/// ```
39634pub struct CreativeGroupListCall<'a, C>
39635where
39636    C: 'a,
39637{
39638    hub: &'a Dfareporting<C>,
39639    _profile_id: i64,
39640    _sort_order: Option<String>,
39641    _sort_field: Option<String>,
39642    _search_string: Option<String>,
39643    _page_token: Option<String>,
39644    _max_results: Option<i32>,
39645    _ids: Vec<i64>,
39646    _group_number: Option<i32>,
39647    _advertiser_ids: Vec<i64>,
39648    _delegate: Option<&'a mut dyn common::Delegate>,
39649    _additional_params: HashMap<String, String>,
39650    _scopes: BTreeSet<String>,
39651}
39652
39653impl<'a, C> common::CallBuilder for CreativeGroupListCall<'a, C> {}
39654
39655impl<'a, C> CreativeGroupListCall<'a, C>
39656where
39657    C: common::Connector,
39658{
39659    /// Perform the operation you have build so far.
39660    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeGroupsListResponse)> {
39661        use std::borrow::Cow;
39662        use std::io::{Read, Seek};
39663
39664        use common::{url::Params, ToParts};
39665        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
39666
39667        let mut dd = common::DefaultDelegate;
39668        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
39669        dlg.begin(common::MethodInfo {
39670            id: "dfareporting.creativeGroups.list",
39671            http_method: hyper::Method::GET,
39672        });
39673
39674        for &field in [
39675            "alt",
39676            "profileId",
39677            "sortOrder",
39678            "sortField",
39679            "searchString",
39680            "pageToken",
39681            "maxResults",
39682            "ids",
39683            "groupNumber",
39684            "advertiserIds",
39685        ]
39686        .iter()
39687        {
39688            if self._additional_params.contains_key(field) {
39689                dlg.finished(false);
39690                return Err(common::Error::FieldClash(field));
39691            }
39692        }
39693
39694        let mut params = Params::with_capacity(11 + self._additional_params.len());
39695        params.push("profileId", self._profile_id.to_string());
39696        if let Some(value) = self._sort_order.as_ref() {
39697            params.push("sortOrder", value);
39698        }
39699        if let Some(value) = self._sort_field.as_ref() {
39700            params.push("sortField", value);
39701        }
39702        if let Some(value) = self._search_string.as_ref() {
39703            params.push("searchString", value);
39704        }
39705        if let Some(value) = self._page_token.as_ref() {
39706            params.push("pageToken", value);
39707        }
39708        if let Some(value) = self._max_results.as_ref() {
39709            params.push("maxResults", value.to_string());
39710        }
39711        if !self._ids.is_empty() {
39712            for f in self._ids.iter() {
39713                params.push("ids", f.to_string());
39714            }
39715        }
39716        if let Some(value) = self._group_number.as_ref() {
39717            params.push("groupNumber", value.to_string());
39718        }
39719        if !self._advertiser_ids.is_empty() {
39720            for f in self._advertiser_ids.iter() {
39721                params.push("advertiserIds", f.to_string());
39722            }
39723        }
39724
39725        params.extend(self._additional_params.iter());
39726
39727        params.push("alt", "json");
39728        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups";
39729        if self._scopes.is_empty() {
39730            self._scopes
39731                .insert(Scope::Dfatrafficking.as_ref().to_string());
39732        }
39733
39734        #[allow(clippy::single_element_loop)]
39735        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
39736            url = params.uri_replacement(url, param_name, find_this, false);
39737        }
39738        {
39739            let to_remove = ["profileId"];
39740            params.remove_params(&to_remove);
39741        }
39742
39743        let url = params.parse_with_url(&url);
39744
39745        loop {
39746            let token = match self
39747                .hub
39748                .auth
39749                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
39750                .await
39751            {
39752                Ok(token) => token,
39753                Err(e) => match dlg.token(e) {
39754                    Ok(token) => token,
39755                    Err(e) => {
39756                        dlg.finished(false);
39757                        return Err(common::Error::MissingToken(e));
39758                    }
39759                },
39760            };
39761            let mut req_result = {
39762                let client = &self.hub.client;
39763                dlg.pre_request();
39764                let mut req_builder = hyper::Request::builder()
39765                    .method(hyper::Method::GET)
39766                    .uri(url.as_str())
39767                    .header(USER_AGENT, self.hub._user_agent.clone());
39768
39769                if let Some(token) = token.as_ref() {
39770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
39771                }
39772
39773                let request = req_builder
39774                    .header(CONTENT_LENGTH, 0_u64)
39775                    .body(common::to_body::<String>(None));
39776
39777                client.request(request.unwrap()).await
39778            };
39779
39780            match req_result {
39781                Err(err) => {
39782                    if let common::Retry::After(d) = dlg.http_error(&err) {
39783                        sleep(d).await;
39784                        continue;
39785                    }
39786                    dlg.finished(false);
39787                    return Err(common::Error::HttpError(err));
39788                }
39789                Ok(res) => {
39790                    let (mut parts, body) = res.into_parts();
39791                    let mut body = common::Body::new(body);
39792                    if !parts.status.is_success() {
39793                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39794                        let error = serde_json::from_str(&common::to_string(&bytes));
39795                        let response = common::to_response(parts, bytes.into());
39796
39797                        if let common::Retry::After(d) =
39798                            dlg.http_failure(&response, error.as_ref().ok())
39799                        {
39800                            sleep(d).await;
39801                            continue;
39802                        }
39803
39804                        dlg.finished(false);
39805
39806                        return Err(match error {
39807                            Ok(value) => common::Error::BadRequest(value),
39808                            _ => common::Error::Failure(response),
39809                        });
39810                    }
39811                    let response = {
39812                        let bytes = common::to_bytes(body).await.unwrap_or_default();
39813                        let encoded = common::to_string(&bytes);
39814                        match serde_json::from_str(&encoded) {
39815                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
39816                            Err(error) => {
39817                                dlg.response_json_decode_error(&encoded, &error);
39818                                return Err(common::Error::JsonDecodeError(
39819                                    encoded.to_string(),
39820                                    error,
39821                                ));
39822                            }
39823                        }
39824                    };
39825
39826                    dlg.finished(true);
39827                    return Ok(response);
39828                }
39829            }
39830        }
39831    }
39832
39833    /// User profile ID associated with this request.
39834    ///
39835    /// Sets the *profile id* path property to the given value.
39836    ///
39837    /// Even though the property as already been set when instantiating this call,
39838    /// we provide this method for API completeness.
39839    pub fn profile_id(mut self, new_value: i64) -> CreativeGroupListCall<'a, C> {
39840        self._profile_id = new_value;
39841        self
39842    }
39843    /// Order of sorted results.
39844    ///
39845    /// Sets the *sort order* query property to the given value.
39846    pub fn sort_order(mut self, new_value: &str) -> CreativeGroupListCall<'a, C> {
39847        self._sort_order = Some(new_value.to_string());
39848        self
39849    }
39850    /// Field by which to sort the list.
39851    ///
39852    /// Sets the *sort field* query property to the given value.
39853    pub fn sort_field(mut self, new_value: &str) -> CreativeGroupListCall<'a, C> {
39854        self._sort_field = Some(new_value.to_string());
39855        self
39856    }
39857    /// Allows searching for creative groups by name or ID. Wildcards (*) are allowed. For example, "creativegroup*2015" will return creative groups with names like "creativegroup June 2015", "creativegroup April 2015", or simply "creativegroup 2015". Most of the searches also add wild-cards implicitly at the start and the end of the search string. For example, a search string of "creativegroup" will match creative groups with the name "my creativegroup", "creativegroup 2015", or simply "creativegroup".
39858    ///
39859    /// Sets the *search string* query property to the given value.
39860    pub fn search_string(mut self, new_value: &str) -> CreativeGroupListCall<'a, C> {
39861        self._search_string = Some(new_value.to_string());
39862        self
39863    }
39864    /// Value of the nextPageToken from the previous result page.
39865    ///
39866    /// Sets the *page token* query property to the given value.
39867    pub fn page_token(mut self, new_value: &str) -> CreativeGroupListCall<'a, C> {
39868        self._page_token = Some(new_value.to_string());
39869        self
39870    }
39871    /// Maximum number of results to return.
39872    ///
39873    /// Sets the *max results* query property to the given value.
39874    pub fn max_results(mut self, new_value: i32) -> CreativeGroupListCall<'a, C> {
39875        self._max_results = Some(new_value);
39876        self
39877    }
39878    /// Select only creative groups with these IDs.
39879    ///
39880    /// Append the given value to the *ids* query property.
39881    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
39882    pub fn add_ids(mut self, new_value: i64) -> CreativeGroupListCall<'a, C> {
39883        self._ids.push(new_value);
39884        self
39885    }
39886    /// Select only creative groups that belong to this subgroup.
39887    ///
39888    /// Sets the *group number* query property to the given value.
39889    pub fn group_number(mut self, new_value: i32) -> CreativeGroupListCall<'a, C> {
39890        self._group_number = Some(new_value);
39891        self
39892    }
39893    /// Select only creative groups that belong to these advertisers.
39894    ///
39895    /// Append the given value to the *advertiser ids* query property.
39896    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
39897    pub fn add_advertiser_ids(mut self, new_value: i64) -> CreativeGroupListCall<'a, C> {
39898        self._advertiser_ids.push(new_value);
39899        self
39900    }
39901    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
39902    /// while executing the actual API request.
39903    ///
39904    /// ````text
39905    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
39906    /// ````
39907    ///
39908    /// Sets the *delegate* property to the given value.
39909    pub fn delegate(
39910        mut self,
39911        new_value: &'a mut dyn common::Delegate,
39912    ) -> CreativeGroupListCall<'a, C> {
39913        self._delegate = Some(new_value);
39914        self
39915    }
39916
39917    /// Set any additional parameter of the query string used in the request.
39918    /// It should be used to set parameters which are not yet available through their own
39919    /// setters.
39920    ///
39921    /// Please note that this method must not be used to set any of the known parameters
39922    /// which have their own setter method. If done anyway, the request will fail.
39923    ///
39924    /// # Additional Parameters
39925    ///
39926    /// * *alt* (query-string) - Data format for the response.
39927    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
39928    /// * *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.
39929    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
39930    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
39931    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
39932    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
39933    pub fn param<T>(mut self, name: T, value: T) -> CreativeGroupListCall<'a, C>
39934    where
39935        T: AsRef<str>,
39936    {
39937        self._additional_params
39938            .insert(name.as_ref().to_string(), value.as_ref().to_string());
39939        self
39940    }
39941
39942    /// Identifies the authorization scope for the method you are building.
39943    ///
39944    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
39945    /// [`Scope::Dfatrafficking`].
39946    ///
39947    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
39948    /// tokens for more than one scope.
39949    ///
39950    /// Usually there is more than one suitable scope to authorize an operation, some of which may
39951    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
39952    /// sufficient, a read-write scope will do as well.
39953    pub fn add_scope<St>(mut self, scope: St) -> CreativeGroupListCall<'a, C>
39954    where
39955        St: AsRef<str>,
39956    {
39957        self._scopes.insert(String::from(scope.as_ref()));
39958        self
39959    }
39960    /// Identifies the authorization scope(s) for the method you are building.
39961    ///
39962    /// See [`Self::add_scope()`] for details.
39963    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGroupListCall<'a, C>
39964    where
39965        I: IntoIterator<Item = St>,
39966        St: AsRef<str>,
39967    {
39968        self._scopes
39969            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
39970        self
39971    }
39972
39973    /// Removes all scopes, and no default scope will be used either.
39974    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
39975    /// for details).
39976    pub fn clear_scopes(mut self) -> CreativeGroupListCall<'a, C> {
39977        self._scopes.clear();
39978        self
39979    }
39980}
39981
39982/// Updates an existing creative group. This method supports patch semantics.
39983///
39984/// A builder for the *patch* method supported by a *creativeGroup* resource.
39985/// It is not used directly, but through a [`CreativeGroupMethods`] instance.
39986///
39987/// # Example
39988///
39989/// Instantiate a resource method builder
39990///
39991/// ```test_harness,no_run
39992/// # extern crate hyper;
39993/// # extern crate hyper_rustls;
39994/// # extern crate google_dfareporting3d2 as dfareporting3d2;
39995/// use dfareporting3d2::api::CreativeGroup;
39996/// # async fn dox() {
39997/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
39998///
39999/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
40000/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
40001/// #     secret,
40002/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40003/// # ).build().await.unwrap();
40004///
40005/// # let client = hyper_util::client::legacy::Client::builder(
40006/// #     hyper_util::rt::TokioExecutor::new()
40007/// # )
40008/// # .build(
40009/// #     hyper_rustls::HttpsConnectorBuilder::new()
40010/// #         .with_native_roots()
40011/// #         .unwrap()
40012/// #         .https_or_http()
40013/// #         .enable_http1()
40014/// #         .build()
40015/// # );
40016/// # let mut hub = Dfareporting::new(client, auth);
40017/// // As the method needs a request, you would usually fill it with the desired information
40018/// // into the respective structure. Some of the parts shown here might not be applicable !
40019/// // Values shown here are possibly random and not representative !
40020/// let mut req = CreativeGroup::default();
40021///
40022/// // You can configure optional parameters by calling the respective setters at will, and
40023/// // execute the final call using `doit()`.
40024/// // Values shown here are possibly random and not representative !
40025/// let result = hub.creative_groups().patch(req, -7, -9)
40026///              .doit().await;
40027/// # }
40028/// ```
40029pub struct CreativeGroupPatchCall<'a, C>
40030where
40031    C: 'a,
40032{
40033    hub: &'a Dfareporting<C>,
40034    _request: CreativeGroup,
40035    _profile_id: i64,
40036    _id: i64,
40037    _delegate: Option<&'a mut dyn common::Delegate>,
40038    _additional_params: HashMap<String, String>,
40039    _scopes: BTreeSet<String>,
40040}
40041
40042impl<'a, C> common::CallBuilder for CreativeGroupPatchCall<'a, C> {}
40043
40044impl<'a, C> CreativeGroupPatchCall<'a, C>
40045where
40046    C: common::Connector,
40047{
40048    /// Perform the operation you have build so far.
40049    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeGroup)> {
40050        use std::borrow::Cow;
40051        use std::io::{Read, Seek};
40052
40053        use common::{url::Params, ToParts};
40054        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
40055
40056        let mut dd = common::DefaultDelegate;
40057        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
40058        dlg.begin(common::MethodInfo {
40059            id: "dfareporting.creativeGroups.patch",
40060            http_method: hyper::Method::PATCH,
40061        });
40062
40063        for &field in ["alt", "profileId", "id"].iter() {
40064            if self._additional_params.contains_key(field) {
40065                dlg.finished(false);
40066                return Err(common::Error::FieldClash(field));
40067            }
40068        }
40069
40070        let mut params = Params::with_capacity(5 + self._additional_params.len());
40071        params.push("profileId", self._profile_id.to_string());
40072        params.push("id", self._id.to_string());
40073
40074        params.extend(self._additional_params.iter());
40075
40076        params.push("alt", "json");
40077        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups";
40078        if self._scopes.is_empty() {
40079            self._scopes
40080                .insert(Scope::Dfatrafficking.as_ref().to_string());
40081        }
40082
40083        #[allow(clippy::single_element_loop)]
40084        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
40085            url = params.uri_replacement(url, param_name, find_this, false);
40086        }
40087        {
40088            let to_remove = ["profileId"];
40089            params.remove_params(&to_remove);
40090        }
40091
40092        let url = params.parse_with_url(&url);
40093
40094        let mut json_mime_type = mime::APPLICATION_JSON;
40095        let mut request_value_reader = {
40096            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
40097            common::remove_json_null_values(&mut value);
40098            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
40099            serde_json::to_writer(&mut dst, &value).unwrap();
40100            dst
40101        };
40102        let request_size = request_value_reader
40103            .seek(std::io::SeekFrom::End(0))
40104            .unwrap();
40105        request_value_reader
40106            .seek(std::io::SeekFrom::Start(0))
40107            .unwrap();
40108
40109        loop {
40110            let token = match self
40111                .hub
40112                .auth
40113                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
40114                .await
40115            {
40116                Ok(token) => token,
40117                Err(e) => match dlg.token(e) {
40118                    Ok(token) => token,
40119                    Err(e) => {
40120                        dlg.finished(false);
40121                        return Err(common::Error::MissingToken(e));
40122                    }
40123                },
40124            };
40125            request_value_reader
40126                .seek(std::io::SeekFrom::Start(0))
40127                .unwrap();
40128            let mut req_result = {
40129                let client = &self.hub.client;
40130                dlg.pre_request();
40131                let mut req_builder = hyper::Request::builder()
40132                    .method(hyper::Method::PATCH)
40133                    .uri(url.as_str())
40134                    .header(USER_AGENT, self.hub._user_agent.clone());
40135
40136                if let Some(token) = token.as_ref() {
40137                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
40138                }
40139
40140                let request = req_builder
40141                    .header(CONTENT_TYPE, json_mime_type.to_string())
40142                    .header(CONTENT_LENGTH, request_size as u64)
40143                    .body(common::to_body(
40144                        request_value_reader.get_ref().clone().into(),
40145                    ));
40146
40147                client.request(request.unwrap()).await
40148            };
40149
40150            match req_result {
40151                Err(err) => {
40152                    if let common::Retry::After(d) = dlg.http_error(&err) {
40153                        sleep(d).await;
40154                        continue;
40155                    }
40156                    dlg.finished(false);
40157                    return Err(common::Error::HttpError(err));
40158                }
40159                Ok(res) => {
40160                    let (mut parts, body) = res.into_parts();
40161                    let mut body = common::Body::new(body);
40162                    if !parts.status.is_success() {
40163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40164                        let error = serde_json::from_str(&common::to_string(&bytes));
40165                        let response = common::to_response(parts, bytes.into());
40166
40167                        if let common::Retry::After(d) =
40168                            dlg.http_failure(&response, error.as_ref().ok())
40169                        {
40170                            sleep(d).await;
40171                            continue;
40172                        }
40173
40174                        dlg.finished(false);
40175
40176                        return Err(match error {
40177                            Ok(value) => common::Error::BadRequest(value),
40178                            _ => common::Error::Failure(response),
40179                        });
40180                    }
40181                    let response = {
40182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40183                        let encoded = common::to_string(&bytes);
40184                        match serde_json::from_str(&encoded) {
40185                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
40186                            Err(error) => {
40187                                dlg.response_json_decode_error(&encoded, &error);
40188                                return Err(common::Error::JsonDecodeError(
40189                                    encoded.to_string(),
40190                                    error,
40191                                ));
40192                            }
40193                        }
40194                    };
40195
40196                    dlg.finished(true);
40197                    return Ok(response);
40198                }
40199            }
40200        }
40201    }
40202
40203    ///
40204    /// Sets the *request* property to the given value.
40205    ///
40206    /// Even though the property as already been set when instantiating this call,
40207    /// we provide this method for API completeness.
40208    pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupPatchCall<'a, C> {
40209        self._request = new_value;
40210        self
40211    }
40212    /// User profile ID associated with this request.
40213    ///
40214    /// Sets the *profile id* path property to the given value.
40215    ///
40216    /// Even though the property as already been set when instantiating this call,
40217    /// we provide this method for API completeness.
40218    pub fn profile_id(mut self, new_value: i64) -> CreativeGroupPatchCall<'a, C> {
40219        self._profile_id = new_value;
40220        self
40221    }
40222    /// Creative group ID.
40223    ///
40224    /// Sets the *id* query property to the given value.
40225    ///
40226    /// Even though the property as already been set when instantiating this call,
40227    /// we provide this method for API completeness.
40228    pub fn id(mut self, new_value: i64) -> CreativeGroupPatchCall<'a, C> {
40229        self._id = new_value;
40230        self
40231    }
40232    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
40233    /// while executing the actual API request.
40234    ///
40235    /// ````text
40236    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
40237    /// ````
40238    ///
40239    /// Sets the *delegate* property to the given value.
40240    pub fn delegate(
40241        mut self,
40242        new_value: &'a mut dyn common::Delegate,
40243    ) -> CreativeGroupPatchCall<'a, C> {
40244        self._delegate = Some(new_value);
40245        self
40246    }
40247
40248    /// Set any additional parameter of the query string used in the request.
40249    /// It should be used to set parameters which are not yet available through their own
40250    /// setters.
40251    ///
40252    /// Please note that this method must not be used to set any of the known parameters
40253    /// which have their own setter method. If done anyway, the request will fail.
40254    ///
40255    /// # Additional Parameters
40256    ///
40257    /// * *alt* (query-string) - Data format for the response.
40258    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
40259    /// * *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.
40260    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
40261    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
40262    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
40263    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
40264    pub fn param<T>(mut self, name: T, value: T) -> CreativeGroupPatchCall<'a, C>
40265    where
40266        T: AsRef<str>,
40267    {
40268        self._additional_params
40269            .insert(name.as_ref().to_string(), value.as_ref().to_string());
40270        self
40271    }
40272
40273    /// Identifies the authorization scope for the method you are building.
40274    ///
40275    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
40276    /// [`Scope::Dfatrafficking`].
40277    ///
40278    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
40279    /// tokens for more than one scope.
40280    ///
40281    /// Usually there is more than one suitable scope to authorize an operation, some of which may
40282    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
40283    /// sufficient, a read-write scope will do as well.
40284    pub fn add_scope<St>(mut self, scope: St) -> CreativeGroupPatchCall<'a, C>
40285    where
40286        St: AsRef<str>,
40287    {
40288        self._scopes.insert(String::from(scope.as_ref()));
40289        self
40290    }
40291    /// Identifies the authorization scope(s) for the method you are building.
40292    ///
40293    /// See [`Self::add_scope()`] for details.
40294    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGroupPatchCall<'a, C>
40295    where
40296        I: IntoIterator<Item = St>,
40297        St: AsRef<str>,
40298    {
40299        self._scopes
40300            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
40301        self
40302    }
40303
40304    /// Removes all scopes, and no default scope will be used either.
40305    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
40306    /// for details).
40307    pub fn clear_scopes(mut self) -> CreativeGroupPatchCall<'a, C> {
40308        self._scopes.clear();
40309        self
40310    }
40311}
40312
40313/// Updates an existing creative group.
40314///
40315/// A builder for the *update* method supported by a *creativeGroup* resource.
40316/// It is not used directly, but through a [`CreativeGroupMethods`] instance.
40317///
40318/// # Example
40319///
40320/// Instantiate a resource method builder
40321///
40322/// ```test_harness,no_run
40323/// # extern crate hyper;
40324/// # extern crate hyper_rustls;
40325/// # extern crate google_dfareporting3d2 as dfareporting3d2;
40326/// use dfareporting3d2::api::CreativeGroup;
40327/// # async fn dox() {
40328/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
40329///
40330/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
40331/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
40332/// #     secret,
40333/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40334/// # ).build().await.unwrap();
40335///
40336/// # let client = hyper_util::client::legacy::Client::builder(
40337/// #     hyper_util::rt::TokioExecutor::new()
40338/// # )
40339/// # .build(
40340/// #     hyper_rustls::HttpsConnectorBuilder::new()
40341/// #         .with_native_roots()
40342/// #         .unwrap()
40343/// #         .https_or_http()
40344/// #         .enable_http1()
40345/// #         .build()
40346/// # );
40347/// # let mut hub = Dfareporting::new(client, auth);
40348/// // As the method needs a request, you would usually fill it with the desired information
40349/// // into the respective structure. Some of the parts shown here might not be applicable !
40350/// // Values shown here are possibly random and not representative !
40351/// let mut req = CreativeGroup::default();
40352///
40353/// // You can configure optional parameters by calling the respective setters at will, and
40354/// // execute the final call using `doit()`.
40355/// // Values shown here are possibly random and not representative !
40356/// let result = hub.creative_groups().update(req, -99)
40357///              .doit().await;
40358/// # }
40359/// ```
40360pub struct CreativeGroupUpdateCall<'a, C>
40361where
40362    C: 'a,
40363{
40364    hub: &'a Dfareporting<C>,
40365    _request: CreativeGroup,
40366    _profile_id: i64,
40367    _delegate: Option<&'a mut dyn common::Delegate>,
40368    _additional_params: HashMap<String, String>,
40369    _scopes: BTreeSet<String>,
40370}
40371
40372impl<'a, C> common::CallBuilder for CreativeGroupUpdateCall<'a, C> {}
40373
40374impl<'a, C> CreativeGroupUpdateCall<'a, C>
40375where
40376    C: common::Connector,
40377{
40378    /// Perform the operation you have build so far.
40379    pub async fn doit(mut self) -> common::Result<(common::Response, CreativeGroup)> {
40380        use std::borrow::Cow;
40381        use std::io::{Read, Seek};
40382
40383        use common::{url::Params, ToParts};
40384        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
40385
40386        let mut dd = common::DefaultDelegate;
40387        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
40388        dlg.begin(common::MethodInfo {
40389            id: "dfareporting.creativeGroups.update",
40390            http_method: hyper::Method::PUT,
40391        });
40392
40393        for &field in ["alt", "profileId"].iter() {
40394            if self._additional_params.contains_key(field) {
40395                dlg.finished(false);
40396                return Err(common::Error::FieldClash(field));
40397            }
40398        }
40399
40400        let mut params = Params::with_capacity(4 + self._additional_params.len());
40401        params.push("profileId", self._profile_id.to_string());
40402
40403        params.extend(self._additional_params.iter());
40404
40405        params.push("alt", "json");
40406        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups";
40407        if self._scopes.is_empty() {
40408            self._scopes
40409                .insert(Scope::Dfatrafficking.as_ref().to_string());
40410        }
40411
40412        #[allow(clippy::single_element_loop)]
40413        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
40414            url = params.uri_replacement(url, param_name, find_this, false);
40415        }
40416        {
40417            let to_remove = ["profileId"];
40418            params.remove_params(&to_remove);
40419        }
40420
40421        let url = params.parse_with_url(&url);
40422
40423        let mut json_mime_type = mime::APPLICATION_JSON;
40424        let mut request_value_reader = {
40425            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
40426            common::remove_json_null_values(&mut value);
40427            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
40428            serde_json::to_writer(&mut dst, &value).unwrap();
40429            dst
40430        };
40431        let request_size = request_value_reader
40432            .seek(std::io::SeekFrom::End(0))
40433            .unwrap();
40434        request_value_reader
40435            .seek(std::io::SeekFrom::Start(0))
40436            .unwrap();
40437
40438        loop {
40439            let token = match self
40440                .hub
40441                .auth
40442                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
40443                .await
40444            {
40445                Ok(token) => token,
40446                Err(e) => match dlg.token(e) {
40447                    Ok(token) => token,
40448                    Err(e) => {
40449                        dlg.finished(false);
40450                        return Err(common::Error::MissingToken(e));
40451                    }
40452                },
40453            };
40454            request_value_reader
40455                .seek(std::io::SeekFrom::Start(0))
40456                .unwrap();
40457            let mut req_result = {
40458                let client = &self.hub.client;
40459                dlg.pre_request();
40460                let mut req_builder = hyper::Request::builder()
40461                    .method(hyper::Method::PUT)
40462                    .uri(url.as_str())
40463                    .header(USER_AGENT, self.hub._user_agent.clone());
40464
40465                if let Some(token) = token.as_ref() {
40466                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
40467                }
40468
40469                let request = req_builder
40470                    .header(CONTENT_TYPE, json_mime_type.to_string())
40471                    .header(CONTENT_LENGTH, request_size as u64)
40472                    .body(common::to_body(
40473                        request_value_reader.get_ref().clone().into(),
40474                    ));
40475
40476                client.request(request.unwrap()).await
40477            };
40478
40479            match req_result {
40480                Err(err) => {
40481                    if let common::Retry::After(d) = dlg.http_error(&err) {
40482                        sleep(d).await;
40483                        continue;
40484                    }
40485                    dlg.finished(false);
40486                    return Err(common::Error::HttpError(err));
40487                }
40488                Ok(res) => {
40489                    let (mut parts, body) = res.into_parts();
40490                    let mut body = common::Body::new(body);
40491                    if !parts.status.is_success() {
40492                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40493                        let error = serde_json::from_str(&common::to_string(&bytes));
40494                        let response = common::to_response(parts, bytes.into());
40495
40496                        if let common::Retry::After(d) =
40497                            dlg.http_failure(&response, error.as_ref().ok())
40498                        {
40499                            sleep(d).await;
40500                            continue;
40501                        }
40502
40503                        dlg.finished(false);
40504
40505                        return Err(match error {
40506                            Ok(value) => common::Error::BadRequest(value),
40507                            _ => common::Error::Failure(response),
40508                        });
40509                    }
40510                    let response = {
40511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40512                        let encoded = common::to_string(&bytes);
40513                        match serde_json::from_str(&encoded) {
40514                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
40515                            Err(error) => {
40516                                dlg.response_json_decode_error(&encoded, &error);
40517                                return Err(common::Error::JsonDecodeError(
40518                                    encoded.to_string(),
40519                                    error,
40520                                ));
40521                            }
40522                        }
40523                    };
40524
40525                    dlg.finished(true);
40526                    return Ok(response);
40527                }
40528            }
40529        }
40530    }
40531
40532    ///
40533    /// Sets the *request* property to the given value.
40534    ///
40535    /// Even though the property as already been set when instantiating this call,
40536    /// we provide this method for API completeness.
40537    pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupUpdateCall<'a, C> {
40538        self._request = new_value;
40539        self
40540    }
40541    /// User profile ID associated with this request.
40542    ///
40543    /// Sets the *profile id* path property to the given value.
40544    ///
40545    /// Even though the property as already been set when instantiating this call,
40546    /// we provide this method for API completeness.
40547    pub fn profile_id(mut self, new_value: i64) -> CreativeGroupUpdateCall<'a, C> {
40548        self._profile_id = new_value;
40549        self
40550    }
40551    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
40552    /// while executing the actual API request.
40553    ///
40554    /// ````text
40555    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
40556    /// ````
40557    ///
40558    /// Sets the *delegate* property to the given value.
40559    pub fn delegate(
40560        mut self,
40561        new_value: &'a mut dyn common::Delegate,
40562    ) -> CreativeGroupUpdateCall<'a, C> {
40563        self._delegate = Some(new_value);
40564        self
40565    }
40566
40567    /// Set any additional parameter of the query string used in the request.
40568    /// It should be used to set parameters which are not yet available through their own
40569    /// setters.
40570    ///
40571    /// Please note that this method must not be used to set any of the known parameters
40572    /// which have their own setter method. If done anyway, the request will fail.
40573    ///
40574    /// # Additional Parameters
40575    ///
40576    /// * *alt* (query-string) - Data format for the response.
40577    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
40578    /// * *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.
40579    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
40580    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
40581    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
40582    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
40583    pub fn param<T>(mut self, name: T, value: T) -> CreativeGroupUpdateCall<'a, C>
40584    where
40585        T: AsRef<str>,
40586    {
40587        self._additional_params
40588            .insert(name.as_ref().to_string(), value.as_ref().to_string());
40589        self
40590    }
40591
40592    /// Identifies the authorization scope for the method you are building.
40593    ///
40594    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
40595    /// [`Scope::Dfatrafficking`].
40596    ///
40597    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
40598    /// tokens for more than one scope.
40599    ///
40600    /// Usually there is more than one suitable scope to authorize an operation, some of which may
40601    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
40602    /// sufficient, a read-write scope will do as well.
40603    pub fn add_scope<St>(mut self, scope: St) -> CreativeGroupUpdateCall<'a, C>
40604    where
40605        St: AsRef<str>,
40606    {
40607        self._scopes.insert(String::from(scope.as_ref()));
40608        self
40609    }
40610    /// Identifies the authorization scope(s) for the method you are building.
40611    ///
40612    /// See [`Self::add_scope()`] for details.
40613    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGroupUpdateCall<'a, C>
40614    where
40615        I: IntoIterator<Item = St>,
40616        St: AsRef<str>,
40617    {
40618        self._scopes
40619            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
40620        self
40621    }
40622
40623    /// Removes all scopes, and no default scope will be used either.
40624    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
40625    /// for details).
40626    pub fn clear_scopes(mut self) -> CreativeGroupUpdateCall<'a, C> {
40627        self._scopes.clear();
40628        self
40629    }
40630}
40631
40632/// Gets one creative by ID.
40633///
40634/// A builder for the *get* method supported by a *creative* resource.
40635/// It is not used directly, but through a [`CreativeMethods`] instance.
40636///
40637/// # Example
40638///
40639/// Instantiate a resource method builder
40640///
40641/// ```test_harness,no_run
40642/// # extern crate hyper;
40643/// # extern crate hyper_rustls;
40644/// # extern crate google_dfareporting3d2 as dfareporting3d2;
40645/// # async fn dox() {
40646/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
40647///
40648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
40649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
40650/// #     secret,
40651/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40652/// # ).build().await.unwrap();
40653///
40654/// # let client = hyper_util::client::legacy::Client::builder(
40655/// #     hyper_util::rt::TokioExecutor::new()
40656/// # )
40657/// # .build(
40658/// #     hyper_rustls::HttpsConnectorBuilder::new()
40659/// #         .with_native_roots()
40660/// #         .unwrap()
40661/// #         .https_or_http()
40662/// #         .enable_http1()
40663/// #         .build()
40664/// # );
40665/// # let mut hub = Dfareporting::new(client, auth);
40666/// // You can configure optional parameters by calling the respective setters at will, and
40667/// // execute the final call using `doit()`.
40668/// // Values shown here are possibly random and not representative !
40669/// let result = hub.creatives().get(-79, -77)
40670///              .doit().await;
40671/// # }
40672/// ```
40673pub struct CreativeGetCall<'a, C>
40674where
40675    C: 'a,
40676{
40677    hub: &'a Dfareporting<C>,
40678    _profile_id: i64,
40679    _id: i64,
40680    _delegate: Option<&'a mut dyn common::Delegate>,
40681    _additional_params: HashMap<String, String>,
40682    _scopes: BTreeSet<String>,
40683}
40684
40685impl<'a, C> common::CallBuilder for CreativeGetCall<'a, C> {}
40686
40687impl<'a, C> CreativeGetCall<'a, C>
40688where
40689    C: common::Connector,
40690{
40691    /// Perform the operation you have build so far.
40692    pub async fn doit(mut self) -> common::Result<(common::Response, Creative)> {
40693        use std::borrow::Cow;
40694        use std::io::{Read, Seek};
40695
40696        use common::{url::Params, ToParts};
40697        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
40698
40699        let mut dd = common::DefaultDelegate;
40700        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
40701        dlg.begin(common::MethodInfo {
40702            id: "dfareporting.creatives.get",
40703            http_method: hyper::Method::GET,
40704        });
40705
40706        for &field in ["alt", "profileId", "id"].iter() {
40707            if self._additional_params.contains_key(field) {
40708                dlg.finished(false);
40709                return Err(common::Error::FieldClash(field));
40710            }
40711        }
40712
40713        let mut params = Params::with_capacity(4 + self._additional_params.len());
40714        params.push("profileId", self._profile_id.to_string());
40715        params.push("id", self._id.to_string());
40716
40717        params.extend(self._additional_params.iter());
40718
40719        params.push("alt", "json");
40720        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives/{id}";
40721        if self._scopes.is_empty() {
40722            self._scopes
40723                .insert(Scope::Dfatrafficking.as_ref().to_string());
40724        }
40725
40726        #[allow(clippy::single_element_loop)]
40727        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
40728            url = params.uri_replacement(url, param_name, find_this, false);
40729        }
40730        {
40731            let to_remove = ["id", "profileId"];
40732            params.remove_params(&to_remove);
40733        }
40734
40735        let url = params.parse_with_url(&url);
40736
40737        loop {
40738            let token = match self
40739                .hub
40740                .auth
40741                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
40742                .await
40743            {
40744                Ok(token) => token,
40745                Err(e) => match dlg.token(e) {
40746                    Ok(token) => token,
40747                    Err(e) => {
40748                        dlg.finished(false);
40749                        return Err(common::Error::MissingToken(e));
40750                    }
40751                },
40752            };
40753            let mut req_result = {
40754                let client = &self.hub.client;
40755                dlg.pre_request();
40756                let mut req_builder = hyper::Request::builder()
40757                    .method(hyper::Method::GET)
40758                    .uri(url.as_str())
40759                    .header(USER_AGENT, self.hub._user_agent.clone());
40760
40761                if let Some(token) = token.as_ref() {
40762                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
40763                }
40764
40765                let request = req_builder
40766                    .header(CONTENT_LENGTH, 0_u64)
40767                    .body(common::to_body::<String>(None));
40768
40769                client.request(request.unwrap()).await
40770            };
40771
40772            match req_result {
40773                Err(err) => {
40774                    if let common::Retry::After(d) = dlg.http_error(&err) {
40775                        sleep(d).await;
40776                        continue;
40777                    }
40778                    dlg.finished(false);
40779                    return Err(common::Error::HttpError(err));
40780                }
40781                Ok(res) => {
40782                    let (mut parts, body) = res.into_parts();
40783                    let mut body = common::Body::new(body);
40784                    if !parts.status.is_success() {
40785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40786                        let error = serde_json::from_str(&common::to_string(&bytes));
40787                        let response = common::to_response(parts, bytes.into());
40788
40789                        if let common::Retry::After(d) =
40790                            dlg.http_failure(&response, error.as_ref().ok())
40791                        {
40792                            sleep(d).await;
40793                            continue;
40794                        }
40795
40796                        dlg.finished(false);
40797
40798                        return Err(match error {
40799                            Ok(value) => common::Error::BadRequest(value),
40800                            _ => common::Error::Failure(response),
40801                        });
40802                    }
40803                    let response = {
40804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
40805                        let encoded = common::to_string(&bytes);
40806                        match serde_json::from_str(&encoded) {
40807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
40808                            Err(error) => {
40809                                dlg.response_json_decode_error(&encoded, &error);
40810                                return Err(common::Error::JsonDecodeError(
40811                                    encoded.to_string(),
40812                                    error,
40813                                ));
40814                            }
40815                        }
40816                    };
40817
40818                    dlg.finished(true);
40819                    return Ok(response);
40820                }
40821            }
40822        }
40823    }
40824
40825    /// User profile ID associated with this request.
40826    ///
40827    /// Sets the *profile id* path property to the given value.
40828    ///
40829    /// Even though the property as already been set when instantiating this call,
40830    /// we provide this method for API completeness.
40831    pub fn profile_id(mut self, new_value: i64) -> CreativeGetCall<'a, C> {
40832        self._profile_id = new_value;
40833        self
40834    }
40835    /// Creative ID.
40836    ///
40837    /// Sets the *id* path property to the given value.
40838    ///
40839    /// Even though the property as already been set when instantiating this call,
40840    /// we provide this method for API completeness.
40841    pub fn id(mut self, new_value: i64) -> CreativeGetCall<'a, C> {
40842        self._id = new_value;
40843        self
40844    }
40845    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
40846    /// while executing the actual API request.
40847    ///
40848    /// ````text
40849    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
40850    /// ````
40851    ///
40852    /// Sets the *delegate* property to the given value.
40853    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CreativeGetCall<'a, C> {
40854        self._delegate = Some(new_value);
40855        self
40856    }
40857
40858    /// Set any additional parameter of the query string used in the request.
40859    /// It should be used to set parameters which are not yet available through their own
40860    /// setters.
40861    ///
40862    /// Please note that this method must not be used to set any of the known parameters
40863    /// which have their own setter method. If done anyway, the request will fail.
40864    ///
40865    /// # Additional Parameters
40866    ///
40867    /// * *alt* (query-string) - Data format for the response.
40868    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
40869    /// * *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.
40870    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
40871    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
40872    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
40873    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
40874    pub fn param<T>(mut self, name: T, value: T) -> CreativeGetCall<'a, C>
40875    where
40876        T: AsRef<str>,
40877    {
40878        self._additional_params
40879            .insert(name.as_ref().to_string(), value.as_ref().to_string());
40880        self
40881    }
40882
40883    /// Identifies the authorization scope for the method you are building.
40884    ///
40885    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
40886    /// [`Scope::Dfatrafficking`].
40887    ///
40888    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
40889    /// tokens for more than one scope.
40890    ///
40891    /// Usually there is more than one suitable scope to authorize an operation, some of which may
40892    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
40893    /// sufficient, a read-write scope will do as well.
40894    pub fn add_scope<St>(mut self, scope: St) -> CreativeGetCall<'a, C>
40895    where
40896        St: AsRef<str>,
40897    {
40898        self._scopes.insert(String::from(scope.as_ref()));
40899        self
40900    }
40901    /// Identifies the authorization scope(s) for the method you are building.
40902    ///
40903    /// See [`Self::add_scope()`] for details.
40904    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGetCall<'a, C>
40905    where
40906        I: IntoIterator<Item = St>,
40907        St: AsRef<str>,
40908    {
40909        self._scopes
40910            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
40911        self
40912    }
40913
40914    /// Removes all scopes, and no default scope will be used either.
40915    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
40916    /// for details).
40917    pub fn clear_scopes(mut self) -> CreativeGetCall<'a, C> {
40918        self._scopes.clear();
40919        self
40920    }
40921}
40922
40923/// Inserts a new creative.
40924///
40925/// A builder for the *insert* method supported by a *creative* resource.
40926/// It is not used directly, but through a [`CreativeMethods`] instance.
40927///
40928/// # Example
40929///
40930/// Instantiate a resource method builder
40931///
40932/// ```test_harness,no_run
40933/// # extern crate hyper;
40934/// # extern crate hyper_rustls;
40935/// # extern crate google_dfareporting3d2 as dfareporting3d2;
40936/// use dfareporting3d2::api::Creative;
40937/// # async fn dox() {
40938/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
40939///
40940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
40941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
40942/// #     secret,
40943/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
40944/// # ).build().await.unwrap();
40945///
40946/// # let client = hyper_util::client::legacy::Client::builder(
40947/// #     hyper_util::rt::TokioExecutor::new()
40948/// # )
40949/// # .build(
40950/// #     hyper_rustls::HttpsConnectorBuilder::new()
40951/// #         .with_native_roots()
40952/// #         .unwrap()
40953/// #         .https_or_http()
40954/// #         .enable_http1()
40955/// #         .build()
40956/// # );
40957/// # let mut hub = Dfareporting::new(client, auth);
40958/// // As the method needs a request, you would usually fill it with the desired information
40959/// // into the respective structure. Some of the parts shown here might not be applicable !
40960/// // Values shown here are possibly random and not representative !
40961/// let mut req = Creative::default();
40962///
40963/// // You can configure optional parameters by calling the respective setters at will, and
40964/// // execute the final call using `doit()`.
40965/// // Values shown here are possibly random and not representative !
40966/// let result = hub.creatives().insert(req, -81)
40967///              .doit().await;
40968/// # }
40969/// ```
40970pub struct CreativeInsertCall<'a, C>
40971where
40972    C: 'a,
40973{
40974    hub: &'a Dfareporting<C>,
40975    _request: Creative,
40976    _profile_id: i64,
40977    _delegate: Option<&'a mut dyn common::Delegate>,
40978    _additional_params: HashMap<String, String>,
40979    _scopes: BTreeSet<String>,
40980}
40981
40982impl<'a, C> common::CallBuilder for CreativeInsertCall<'a, C> {}
40983
40984impl<'a, C> CreativeInsertCall<'a, C>
40985where
40986    C: common::Connector,
40987{
40988    /// Perform the operation you have build so far.
40989    pub async fn doit(mut self) -> common::Result<(common::Response, Creative)> {
40990        use std::borrow::Cow;
40991        use std::io::{Read, Seek};
40992
40993        use common::{url::Params, ToParts};
40994        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
40995
40996        let mut dd = common::DefaultDelegate;
40997        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
40998        dlg.begin(common::MethodInfo {
40999            id: "dfareporting.creatives.insert",
41000            http_method: hyper::Method::POST,
41001        });
41002
41003        for &field in ["alt", "profileId"].iter() {
41004            if self._additional_params.contains_key(field) {
41005                dlg.finished(false);
41006                return Err(common::Error::FieldClash(field));
41007            }
41008        }
41009
41010        let mut params = Params::with_capacity(4 + self._additional_params.len());
41011        params.push("profileId", self._profile_id.to_string());
41012
41013        params.extend(self._additional_params.iter());
41014
41015        params.push("alt", "json");
41016        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives";
41017        if self._scopes.is_empty() {
41018            self._scopes
41019                .insert(Scope::Dfatrafficking.as_ref().to_string());
41020        }
41021
41022        #[allow(clippy::single_element_loop)]
41023        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
41024            url = params.uri_replacement(url, param_name, find_this, false);
41025        }
41026        {
41027            let to_remove = ["profileId"];
41028            params.remove_params(&to_remove);
41029        }
41030
41031        let url = params.parse_with_url(&url);
41032
41033        let mut json_mime_type = mime::APPLICATION_JSON;
41034        let mut request_value_reader = {
41035            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
41036            common::remove_json_null_values(&mut value);
41037            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
41038            serde_json::to_writer(&mut dst, &value).unwrap();
41039            dst
41040        };
41041        let request_size = request_value_reader
41042            .seek(std::io::SeekFrom::End(0))
41043            .unwrap();
41044        request_value_reader
41045            .seek(std::io::SeekFrom::Start(0))
41046            .unwrap();
41047
41048        loop {
41049            let token = match self
41050                .hub
41051                .auth
41052                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
41053                .await
41054            {
41055                Ok(token) => token,
41056                Err(e) => match dlg.token(e) {
41057                    Ok(token) => token,
41058                    Err(e) => {
41059                        dlg.finished(false);
41060                        return Err(common::Error::MissingToken(e));
41061                    }
41062                },
41063            };
41064            request_value_reader
41065                .seek(std::io::SeekFrom::Start(0))
41066                .unwrap();
41067            let mut req_result = {
41068                let client = &self.hub.client;
41069                dlg.pre_request();
41070                let mut req_builder = hyper::Request::builder()
41071                    .method(hyper::Method::POST)
41072                    .uri(url.as_str())
41073                    .header(USER_AGENT, self.hub._user_agent.clone());
41074
41075                if let Some(token) = token.as_ref() {
41076                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
41077                }
41078
41079                let request = req_builder
41080                    .header(CONTENT_TYPE, json_mime_type.to_string())
41081                    .header(CONTENT_LENGTH, request_size as u64)
41082                    .body(common::to_body(
41083                        request_value_reader.get_ref().clone().into(),
41084                    ));
41085
41086                client.request(request.unwrap()).await
41087            };
41088
41089            match req_result {
41090                Err(err) => {
41091                    if let common::Retry::After(d) = dlg.http_error(&err) {
41092                        sleep(d).await;
41093                        continue;
41094                    }
41095                    dlg.finished(false);
41096                    return Err(common::Error::HttpError(err));
41097                }
41098                Ok(res) => {
41099                    let (mut parts, body) = res.into_parts();
41100                    let mut body = common::Body::new(body);
41101                    if !parts.status.is_success() {
41102                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41103                        let error = serde_json::from_str(&common::to_string(&bytes));
41104                        let response = common::to_response(parts, bytes.into());
41105
41106                        if let common::Retry::After(d) =
41107                            dlg.http_failure(&response, error.as_ref().ok())
41108                        {
41109                            sleep(d).await;
41110                            continue;
41111                        }
41112
41113                        dlg.finished(false);
41114
41115                        return Err(match error {
41116                            Ok(value) => common::Error::BadRequest(value),
41117                            _ => common::Error::Failure(response),
41118                        });
41119                    }
41120                    let response = {
41121                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41122                        let encoded = common::to_string(&bytes);
41123                        match serde_json::from_str(&encoded) {
41124                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
41125                            Err(error) => {
41126                                dlg.response_json_decode_error(&encoded, &error);
41127                                return Err(common::Error::JsonDecodeError(
41128                                    encoded.to_string(),
41129                                    error,
41130                                ));
41131                            }
41132                        }
41133                    };
41134
41135                    dlg.finished(true);
41136                    return Ok(response);
41137                }
41138            }
41139        }
41140    }
41141
41142    ///
41143    /// Sets the *request* property to the given value.
41144    ///
41145    /// Even though the property as already been set when instantiating this call,
41146    /// we provide this method for API completeness.
41147    pub fn request(mut self, new_value: Creative) -> CreativeInsertCall<'a, C> {
41148        self._request = new_value;
41149        self
41150    }
41151    /// User profile ID associated with this request.
41152    ///
41153    /// Sets the *profile id* path property to the given value.
41154    ///
41155    /// Even though the property as already been set when instantiating this call,
41156    /// we provide this method for API completeness.
41157    pub fn profile_id(mut self, new_value: i64) -> CreativeInsertCall<'a, C> {
41158        self._profile_id = new_value;
41159        self
41160    }
41161    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
41162    /// while executing the actual API request.
41163    ///
41164    /// ````text
41165    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
41166    /// ````
41167    ///
41168    /// Sets the *delegate* property to the given value.
41169    pub fn delegate(
41170        mut self,
41171        new_value: &'a mut dyn common::Delegate,
41172    ) -> CreativeInsertCall<'a, C> {
41173        self._delegate = Some(new_value);
41174        self
41175    }
41176
41177    /// Set any additional parameter of the query string used in the request.
41178    /// It should be used to set parameters which are not yet available through their own
41179    /// setters.
41180    ///
41181    /// Please note that this method must not be used to set any of the known parameters
41182    /// which have their own setter method. If done anyway, the request will fail.
41183    ///
41184    /// # Additional Parameters
41185    ///
41186    /// * *alt* (query-string) - Data format for the response.
41187    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
41188    /// * *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.
41189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
41190    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
41191    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
41192    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
41193    pub fn param<T>(mut self, name: T, value: T) -> CreativeInsertCall<'a, C>
41194    where
41195        T: AsRef<str>,
41196    {
41197        self._additional_params
41198            .insert(name.as_ref().to_string(), value.as_ref().to_string());
41199        self
41200    }
41201
41202    /// Identifies the authorization scope for the method you are building.
41203    ///
41204    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
41205    /// [`Scope::Dfatrafficking`].
41206    ///
41207    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
41208    /// tokens for more than one scope.
41209    ///
41210    /// Usually there is more than one suitable scope to authorize an operation, some of which may
41211    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
41212    /// sufficient, a read-write scope will do as well.
41213    pub fn add_scope<St>(mut self, scope: St) -> CreativeInsertCall<'a, C>
41214    where
41215        St: AsRef<str>,
41216    {
41217        self._scopes.insert(String::from(scope.as_ref()));
41218        self
41219    }
41220    /// Identifies the authorization scope(s) for the method you are building.
41221    ///
41222    /// See [`Self::add_scope()`] for details.
41223    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeInsertCall<'a, C>
41224    where
41225        I: IntoIterator<Item = St>,
41226        St: AsRef<str>,
41227    {
41228        self._scopes
41229            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
41230        self
41231    }
41232
41233    /// Removes all scopes, and no default scope will be used either.
41234    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
41235    /// for details).
41236    pub fn clear_scopes(mut self) -> CreativeInsertCall<'a, C> {
41237        self._scopes.clear();
41238        self
41239    }
41240}
41241
41242/// Retrieves a list of creatives, possibly filtered. This method supports paging.
41243///
41244/// A builder for the *list* method supported by a *creative* resource.
41245/// It is not used directly, but through a [`CreativeMethods`] instance.
41246///
41247/// # Example
41248///
41249/// Instantiate a resource method builder
41250///
41251/// ```test_harness,no_run
41252/// # extern crate hyper;
41253/// # extern crate hyper_rustls;
41254/// # extern crate google_dfareporting3d2 as dfareporting3d2;
41255/// # async fn dox() {
41256/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
41257///
41258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
41259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
41260/// #     secret,
41261/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
41262/// # ).build().await.unwrap();
41263///
41264/// # let client = hyper_util::client::legacy::Client::builder(
41265/// #     hyper_util::rt::TokioExecutor::new()
41266/// # )
41267/// # .build(
41268/// #     hyper_rustls::HttpsConnectorBuilder::new()
41269/// #         .with_native_roots()
41270/// #         .unwrap()
41271/// #         .https_or_http()
41272/// #         .enable_http1()
41273/// #         .build()
41274/// # );
41275/// # let mut hub = Dfareporting::new(client, auth);
41276/// // You can configure optional parameters by calling the respective setters at will, and
41277/// // execute the final call using `doit()`.
41278/// // Values shown here are possibly random and not representative !
41279/// let result = hub.creatives().list(-71)
41280///              .add_types("ipsum")
41281///              .studio_creative_id(-73)
41282///              .sort_order("dolores")
41283///              .sort_field("consetetur")
41284///              .add_size_ids(-11)
41285///              .search_string("justo")
41286///              .add_rendering_ids(-45)
41287///              .page_token("diam")
41288///              .max_results(-10)
41289///              .add_ids(-50)
41290///              .add_creative_field_ids(-15)
41291///              .add_companion_creative_ids(-62)
41292///              .campaign_id(-5)
41293///              .archived(true)
41294///              .advertiser_id(-98)
41295///              .active(true)
41296///              .doit().await;
41297/// # }
41298/// ```
41299pub struct CreativeListCall<'a, C>
41300where
41301    C: 'a,
41302{
41303    hub: &'a Dfareporting<C>,
41304    _profile_id: i64,
41305    _types: Vec<String>,
41306    _studio_creative_id: Option<i64>,
41307    _sort_order: Option<String>,
41308    _sort_field: Option<String>,
41309    _size_ids: Vec<i64>,
41310    _search_string: Option<String>,
41311    _rendering_ids: Vec<i64>,
41312    _page_token: Option<String>,
41313    _max_results: Option<i32>,
41314    _ids: Vec<i64>,
41315    _creative_field_ids: Vec<i64>,
41316    _companion_creative_ids: Vec<i64>,
41317    _campaign_id: Option<i64>,
41318    _archived: Option<bool>,
41319    _advertiser_id: Option<i64>,
41320    _active: Option<bool>,
41321    _delegate: Option<&'a mut dyn common::Delegate>,
41322    _additional_params: HashMap<String, String>,
41323    _scopes: BTreeSet<String>,
41324}
41325
41326impl<'a, C> common::CallBuilder for CreativeListCall<'a, C> {}
41327
41328impl<'a, C> CreativeListCall<'a, C>
41329where
41330    C: common::Connector,
41331{
41332    /// Perform the operation you have build so far.
41333    pub async fn doit(mut self) -> common::Result<(common::Response, CreativesListResponse)> {
41334        use std::borrow::Cow;
41335        use std::io::{Read, Seek};
41336
41337        use common::{url::Params, ToParts};
41338        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
41339
41340        let mut dd = common::DefaultDelegate;
41341        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
41342        dlg.begin(common::MethodInfo {
41343            id: "dfareporting.creatives.list",
41344            http_method: hyper::Method::GET,
41345        });
41346
41347        for &field in [
41348            "alt",
41349            "profileId",
41350            "types",
41351            "studioCreativeId",
41352            "sortOrder",
41353            "sortField",
41354            "sizeIds",
41355            "searchString",
41356            "renderingIds",
41357            "pageToken",
41358            "maxResults",
41359            "ids",
41360            "creativeFieldIds",
41361            "companionCreativeIds",
41362            "campaignId",
41363            "archived",
41364            "advertiserId",
41365            "active",
41366        ]
41367        .iter()
41368        {
41369            if self._additional_params.contains_key(field) {
41370                dlg.finished(false);
41371                return Err(common::Error::FieldClash(field));
41372            }
41373        }
41374
41375        let mut params = Params::with_capacity(19 + self._additional_params.len());
41376        params.push("profileId", self._profile_id.to_string());
41377        if !self._types.is_empty() {
41378            for f in self._types.iter() {
41379                params.push("types", f);
41380            }
41381        }
41382        if let Some(value) = self._studio_creative_id.as_ref() {
41383            params.push("studioCreativeId", value.to_string());
41384        }
41385        if let Some(value) = self._sort_order.as_ref() {
41386            params.push("sortOrder", value);
41387        }
41388        if let Some(value) = self._sort_field.as_ref() {
41389            params.push("sortField", value);
41390        }
41391        if !self._size_ids.is_empty() {
41392            for f in self._size_ids.iter() {
41393                params.push("sizeIds", f.to_string());
41394            }
41395        }
41396        if let Some(value) = self._search_string.as_ref() {
41397            params.push("searchString", value);
41398        }
41399        if !self._rendering_ids.is_empty() {
41400            for f in self._rendering_ids.iter() {
41401                params.push("renderingIds", f.to_string());
41402            }
41403        }
41404        if let Some(value) = self._page_token.as_ref() {
41405            params.push("pageToken", value);
41406        }
41407        if let Some(value) = self._max_results.as_ref() {
41408            params.push("maxResults", value.to_string());
41409        }
41410        if !self._ids.is_empty() {
41411            for f in self._ids.iter() {
41412                params.push("ids", f.to_string());
41413            }
41414        }
41415        if !self._creative_field_ids.is_empty() {
41416            for f in self._creative_field_ids.iter() {
41417                params.push("creativeFieldIds", f.to_string());
41418            }
41419        }
41420        if !self._companion_creative_ids.is_empty() {
41421            for f in self._companion_creative_ids.iter() {
41422                params.push("companionCreativeIds", f.to_string());
41423            }
41424        }
41425        if let Some(value) = self._campaign_id.as_ref() {
41426            params.push("campaignId", value.to_string());
41427        }
41428        if let Some(value) = self._archived.as_ref() {
41429            params.push("archived", value.to_string());
41430        }
41431        if let Some(value) = self._advertiser_id.as_ref() {
41432            params.push("advertiserId", value.to_string());
41433        }
41434        if let Some(value) = self._active.as_ref() {
41435            params.push("active", value.to_string());
41436        }
41437
41438        params.extend(self._additional_params.iter());
41439
41440        params.push("alt", "json");
41441        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives";
41442        if self._scopes.is_empty() {
41443            self._scopes
41444                .insert(Scope::Dfatrafficking.as_ref().to_string());
41445        }
41446
41447        #[allow(clippy::single_element_loop)]
41448        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
41449            url = params.uri_replacement(url, param_name, find_this, false);
41450        }
41451        {
41452            let to_remove = ["profileId"];
41453            params.remove_params(&to_remove);
41454        }
41455
41456        let url = params.parse_with_url(&url);
41457
41458        loop {
41459            let token = match self
41460                .hub
41461                .auth
41462                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
41463                .await
41464            {
41465                Ok(token) => token,
41466                Err(e) => match dlg.token(e) {
41467                    Ok(token) => token,
41468                    Err(e) => {
41469                        dlg.finished(false);
41470                        return Err(common::Error::MissingToken(e));
41471                    }
41472                },
41473            };
41474            let mut req_result = {
41475                let client = &self.hub.client;
41476                dlg.pre_request();
41477                let mut req_builder = hyper::Request::builder()
41478                    .method(hyper::Method::GET)
41479                    .uri(url.as_str())
41480                    .header(USER_AGENT, self.hub._user_agent.clone());
41481
41482                if let Some(token) = token.as_ref() {
41483                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
41484                }
41485
41486                let request = req_builder
41487                    .header(CONTENT_LENGTH, 0_u64)
41488                    .body(common::to_body::<String>(None));
41489
41490                client.request(request.unwrap()).await
41491            };
41492
41493            match req_result {
41494                Err(err) => {
41495                    if let common::Retry::After(d) = dlg.http_error(&err) {
41496                        sleep(d).await;
41497                        continue;
41498                    }
41499                    dlg.finished(false);
41500                    return Err(common::Error::HttpError(err));
41501                }
41502                Ok(res) => {
41503                    let (mut parts, body) = res.into_parts();
41504                    let mut body = common::Body::new(body);
41505                    if !parts.status.is_success() {
41506                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41507                        let error = serde_json::from_str(&common::to_string(&bytes));
41508                        let response = common::to_response(parts, bytes.into());
41509
41510                        if let common::Retry::After(d) =
41511                            dlg.http_failure(&response, error.as_ref().ok())
41512                        {
41513                            sleep(d).await;
41514                            continue;
41515                        }
41516
41517                        dlg.finished(false);
41518
41519                        return Err(match error {
41520                            Ok(value) => common::Error::BadRequest(value),
41521                            _ => common::Error::Failure(response),
41522                        });
41523                    }
41524                    let response = {
41525                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41526                        let encoded = common::to_string(&bytes);
41527                        match serde_json::from_str(&encoded) {
41528                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
41529                            Err(error) => {
41530                                dlg.response_json_decode_error(&encoded, &error);
41531                                return Err(common::Error::JsonDecodeError(
41532                                    encoded.to_string(),
41533                                    error,
41534                                ));
41535                            }
41536                        }
41537                    };
41538
41539                    dlg.finished(true);
41540                    return Ok(response);
41541                }
41542            }
41543        }
41544    }
41545
41546    /// User profile ID associated with this request.
41547    ///
41548    /// Sets the *profile id* path property to the given value.
41549    ///
41550    /// Even though the property as already been set when instantiating this call,
41551    /// we provide this method for API completeness.
41552    pub fn profile_id(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41553        self._profile_id = new_value;
41554        self
41555    }
41556    /// Select only creatives with these creative types.
41557    ///
41558    /// Append the given value to the *types* query property.
41559    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41560    pub fn add_types(mut self, new_value: &str) -> CreativeListCall<'a, C> {
41561        self._types.push(new_value.to_string());
41562        self
41563    }
41564    /// Select only creatives corresponding to this Studio creative ID.
41565    ///
41566    /// Sets the *studio creative id* query property to the given value.
41567    pub fn studio_creative_id(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41568        self._studio_creative_id = Some(new_value);
41569        self
41570    }
41571    /// Order of sorted results.
41572    ///
41573    /// Sets the *sort order* query property to the given value.
41574    pub fn sort_order(mut self, new_value: &str) -> CreativeListCall<'a, C> {
41575        self._sort_order = Some(new_value.to_string());
41576        self
41577    }
41578    /// Field by which to sort the list.
41579    ///
41580    /// Sets the *sort field* query property to the given value.
41581    pub fn sort_field(mut self, new_value: &str) -> CreativeListCall<'a, C> {
41582        self._sort_field = Some(new_value.to_string());
41583        self
41584    }
41585    /// Select only creatives with these size IDs.
41586    ///
41587    /// Append the given value to the *size ids* query property.
41588    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41589    pub fn add_size_ids(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41590        self._size_ids.push(new_value);
41591        self
41592    }
41593    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "creative*2015" will return objects with names like "creative June 2015", "creative April 2015", or simply "creative 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "creative" will match objects with name "my creative", "creative 2015", or simply "creative".
41594    ///
41595    /// Sets the *search string* query property to the given value.
41596    pub fn search_string(mut self, new_value: &str) -> CreativeListCall<'a, C> {
41597        self._search_string = Some(new_value.to_string());
41598        self
41599    }
41600    /// Select only creatives with these rendering IDs.
41601    ///
41602    /// Append the given value to the *rendering ids* query property.
41603    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41604    pub fn add_rendering_ids(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41605        self._rendering_ids.push(new_value);
41606        self
41607    }
41608    /// Value of the nextPageToken from the previous result page.
41609    ///
41610    /// Sets the *page token* query property to the given value.
41611    pub fn page_token(mut self, new_value: &str) -> CreativeListCall<'a, C> {
41612        self._page_token = Some(new_value.to_string());
41613        self
41614    }
41615    /// Maximum number of results to return.
41616    ///
41617    /// Sets the *max results* query property to the given value.
41618    pub fn max_results(mut self, new_value: i32) -> CreativeListCall<'a, C> {
41619        self._max_results = Some(new_value);
41620        self
41621    }
41622    /// Select only creatives with these IDs.
41623    ///
41624    /// Append the given value to the *ids* query property.
41625    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41626    pub fn add_ids(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41627        self._ids.push(new_value);
41628        self
41629    }
41630    /// Select only creatives with these creative field IDs.
41631    ///
41632    /// Append the given value to the *creative field ids* query property.
41633    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41634    pub fn add_creative_field_ids(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41635        self._creative_field_ids.push(new_value);
41636        self
41637    }
41638    /// Select only in-stream video creatives with these companion IDs.
41639    ///
41640    /// Append the given value to the *companion creative ids* query property.
41641    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
41642    pub fn add_companion_creative_ids(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41643        self._companion_creative_ids.push(new_value);
41644        self
41645    }
41646    /// Select only creatives with this campaign ID.
41647    ///
41648    /// Sets the *campaign id* query property to the given value.
41649    pub fn campaign_id(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41650        self._campaign_id = Some(new_value);
41651        self
41652    }
41653    /// Select only archived creatives. Leave blank to select archived and unarchived creatives.
41654    ///
41655    /// Sets the *archived* query property to the given value.
41656    pub fn archived(mut self, new_value: bool) -> CreativeListCall<'a, C> {
41657        self._archived = Some(new_value);
41658        self
41659    }
41660    /// Select only creatives with this advertiser ID.
41661    ///
41662    /// Sets the *advertiser id* query property to the given value.
41663    pub fn advertiser_id(mut self, new_value: i64) -> CreativeListCall<'a, C> {
41664        self._advertiser_id = Some(new_value);
41665        self
41666    }
41667    /// Select only active creatives. Leave blank to select active and inactive creatives.
41668    ///
41669    /// Sets the *active* query property to the given value.
41670    pub fn active(mut self, new_value: bool) -> CreativeListCall<'a, C> {
41671        self._active = Some(new_value);
41672        self
41673    }
41674    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
41675    /// while executing the actual API request.
41676    ///
41677    /// ````text
41678    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
41679    /// ````
41680    ///
41681    /// Sets the *delegate* property to the given value.
41682    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CreativeListCall<'a, C> {
41683        self._delegate = Some(new_value);
41684        self
41685    }
41686
41687    /// Set any additional parameter of the query string used in the request.
41688    /// It should be used to set parameters which are not yet available through their own
41689    /// setters.
41690    ///
41691    /// Please note that this method must not be used to set any of the known parameters
41692    /// which have their own setter method. If done anyway, the request will fail.
41693    ///
41694    /// # Additional Parameters
41695    ///
41696    /// * *alt* (query-string) - Data format for the response.
41697    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
41698    /// * *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.
41699    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
41700    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
41701    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
41702    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
41703    pub fn param<T>(mut self, name: T, value: T) -> CreativeListCall<'a, C>
41704    where
41705        T: AsRef<str>,
41706    {
41707        self._additional_params
41708            .insert(name.as_ref().to_string(), value.as_ref().to_string());
41709        self
41710    }
41711
41712    /// Identifies the authorization scope for the method you are building.
41713    ///
41714    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
41715    /// [`Scope::Dfatrafficking`].
41716    ///
41717    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
41718    /// tokens for more than one scope.
41719    ///
41720    /// Usually there is more than one suitable scope to authorize an operation, some of which may
41721    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
41722    /// sufficient, a read-write scope will do as well.
41723    pub fn add_scope<St>(mut self, scope: St) -> CreativeListCall<'a, C>
41724    where
41725        St: AsRef<str>,
41726    {
41727        self._scopes.insert(String::from(scope.as_ref()));
41728        self
41729    }
41730    /// Identifies the authorization scope(s) for the method you are building.
41731    ///
41732    /// See [`Self::add_scope()`] for details.
41733    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeListCall<'a, C>
41734    where
41735        I: IntoIterator<Item = St>,
41736        St: AsRef<str>,
41737    {
41738        self._scopes
41739            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
41740        self
41741    }
41742
41743    /// Removes all scopes, and no default scope will be used either.
41744    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
41745    /// for details).
41746    pub fn clear_scopes(mut self) -> CreativeListCall<'a, C> {
41747        self._scopes.clear();
41748        self
41749    }
41750}
41751
41752/// Updates an existing creative. This method supports patch semantics.
41753///
41754/// A builder for the *patch* method supported by a *creative* resource.
41755/// It is not used directly, but through a [`CreativeMethods`] instance.
41756///
41757/// # Example
41758///
41759/// Instantiate a resource method builder
41760///
41761/// ```test_harness,no_run
41762/// # extern crate hyper;
41763/// # extern crate hyper_rustls;
41764/// # extern crate google_dfareporting3d2 as dfareporting3d2;
41765/// use dfareporting3d2::api::Creative;
41766/// # async fn dox() {
41767/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
41768///
41769/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
41770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
41771/// #     secret,
41772/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
41773/// # ).build().await.unwrap();
41774///
41775/// # let client = hyper_util::client::legacy::Client::builder(
41776/// #     hyper_util::rt::TokioExecutor::new()
41777/// # )
41778/// # .build(
41779/// #     hyper_rustls::HttpsConnectorBuilder::new()
41780/// #         .with_native_roots()
41781/// #         .unwrap()
41782/// #         .https_or_http()
41783/// #         .enable_http1()
41784/// #         .build()
41785/// # );
41786/// # let mut hub = Dfareporting::new(client, auth);
41787/// // As the method needs a request, you would usually fill it with the desired information
41788/// // into the respective structure. Some of the parts shown here might not be applicable !
41789/// // Values shown here are possibly random and not representative !
41790/// let mut req = Creative::default();
41791///
41792/// // You can configure optional parameters by calling the respective setters at will, and
41793/// // execute the final call using `doit()`.
41794/// // Values shown here are possibly random and not representative !
41795/// let result = hub.creatives().patch(req, -56, -21)
41796///              .doit().await;
41797/// # }
41798/// ```
41799pub struct CreativePatchCall<'a, C>
41800where
41801    C: 'a,
41802{
41803    hub: &'a Dfareporting<C>,
41804    _request: Creative,
41805    _profile_id: i64,
41806    _id: i64,
41807    _delegate: Option<&'a mut dyn common::Delegate>,
41808    _additional_params: HashMap<String, String>,
41809    _scopes: BTreeSet<String>,
41810}
41811
41812impl<'a, C> common::CallBuilder for CreativePatchCall<'a, C> {}
41813
41814impl<'a, C> CreativePatchCall<'a, C>
41815where
41816    C: common::Connector,
41817{
41818    /// Perform the operation you have build so far.
41819    pub async fn doit(mut self) -> common::Result<(common::Response, Creative)> {
41820        use std::borrow::Cow;
41821        use std::io::{Read, Seek};
41822
41823        use common::{url::Params, ToParts};
41824        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
41825
41826        let mut dd = common::DefaultDelegate;
41827        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
41828        dlg.begin(common::MethodInfo {
41829            id: "dfareporting.creatives.patch",
41830            http_method: hyper::Method::PATCH,
41831        });
41832
41833        for &field in ["alt", "profileId", "id"].iter() {
41834            if self._additional_params.contains_key(field) {
41835                dlg.finished(false);
41836                return Err(common::Error::FieldClash(field));
41837            }
41838        }
41839
41840        let mut params = Params::with_capacity(5 + self._additional_params.len());
41841        params.push("profileId", self._profile_id.to_string());
41842        params.push("id", self._id.to_string());
41843
41844        params.extend(self._additional_params.iter());
41845
41846        params.push("alt", "json");
41847        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives";
41848        if self._scopes.is_empty() {
41849            self._scopes
41850                .insert(Scope::Dfatrafficking.as_ref().to_string());
41851        }
41852
41853        #[allow(clippy::single_element_loop)]
41854        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
41855            url = params.uri_replacement(url, param_name, find_this, false);
41856        }
41857        {
41858            let to_remove = ["profileId"];
41859            params.remove_params(&to_remove);
41860        }
41861
41862        let url = params.parse_with_url(&url);
41863
41864        let mut json_mime_type = mime::APPLICATION_JSON;
41865        let mut request_value_reader = {
41866            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
41867            common::remove_json_null_values(&mut value);
41868            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
41869            serde_json::to_writer(&mut dst, &value).unwrap();
41870            dst
41871        };
41872        let request_size = request_value_reader
41873            .seek(std::io::SeekFrom::End(0))
41874            .unwrap();
41875        request_value_reader
41876            .seek(std::io::SeekFrom::Start(0))
41877            .unwrap();
41878
41879        loop {
41880            let token = match self
41881                .hub
41882                .auth
41883                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
41884                .await
41885            {
41886                Ok(token) => token,
41887                Err(e) => match dlg.token(e) {
41888                    Ok(token) => token,
41889                    Err(e) => {
41890                        dlg.finished(false);
41891                        return Err(common::Error::MissingToken(e));
41892                    }
41893                },
41894            };
41895            request_value_reader
41896                .seek(std::io::SeekFrom::Start(0))
41897                .unwrap();
41898            let mut req_result = {
41899                let client = &self.hub.client;
41900                dlg.pre_request();
41901                let mut req_builder = hyper::Request::builder()
41902                    .method(hyper::Method::PATCH)
41903                    .uri(url.as_str())
41904                    .header(USER_AGENT, self.hub._user_agent.clone());
41905
41906                if let Some(token) = token.as_ref() {
41907                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
41908                }
41909
41910                let request = req_builder
41911                    .header(CONTENT_TYPE, json_mime_type.to_string())
41912                    .header(CONTENT_LENGTH, request_size as u64)
41913                    .body(common::to_body(
41914                        request_value_reader.get_ref().clone().into(),
41915                    ));
41916
41917                client.request(request.unwrap()).await
41918            };
41919
41920            match req_result {
41921                Err(err) => {
41922                    if let common::Retry::After(d) = dlg.http_error(&err) {
41923                        sleep(d).await;
41924                        continue;
41925                    }
41926                    dlg.finished(false);
41927                    return Err(common::Error::HttpError(err));
41928                }
41929                Ok(res) => {
41930                    let (mut parts, body) = res.into_parts();
41931                    let mut body = common::Body::new(body);
41932                    if !parts.status.is_success() {
41933                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41934                        let error = serde_json::from_str(&common::to_string(&bytes));
41935                        let response = common::to_response(parts, bytes.into());
41936
41937                        if let common::Retry::After(d) =
41938                            dlg.http_failure(&response, error.as_ref().ok())
41939                        {
41940                            sleep(d).await;
41941                            continue;
41942                        }
41943
41944                        dlg.finished(false);
41945
41946                        return Err(match error {
41947                            Ok(value) => common::Error::BadRequest(value),
41948                            _ => common::Error::Failure(response),
41949                        });
41950                    }
41951                    let response = {
41952                        let bytes = common::to_bytes(body).await.unwrap_or_default();
41953                        let encoded = common::to_string(&bytes);
41954                        match serde_json::from_str(&encoded) {
41955                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
41956                            Err(error) => {
41957                                dlg.response_json_decode_error(&encoded, &error);
41958                                return Err(common::Error::JsonDecodeError(
41959                                    encoded.to_string(),
41960                                    error,
41961                                ));
41962                            }
41963                        }
41964                    };
41965
41966                    dlg.finished(true);
41967                    return Ok(response);
41968                }
41969            }
41970        }
41971    }
41972
41973    ///
41974    /// Sets the *request* property to the given value.
41975    ///
41976    /// Even though the property as already been set when instantiating this call,
41977    /// we provide this method for API completeness.
41978    pub fn request(mut self, new_value: Creative) -> CreativePatchCall<'a, C> {
41979        self._request = new_value;
41980        self
41981    }
41982    /// User profile ID associated with this request.
41983    ///
41984    /// Sets the *profile id* path property to the given value.
41985    ///
41986    /// Even though the property as already been set when instantiating this call,
41987    /// we provide this method for API completeness.
41988    pub fn profile_id(mut self, new_value: i64) -> CreativePatchCall<'a, C> {
41989        self._profile_id = new_value;
41990        self
41991    }
41992    /// Creative ID.
41993    ///
41994    /// Sets the *id* query property to the given value.
41995    ///
41996    /// Even though the property as already been set when instantiating this call,
41997    /// we provide this method for API completeness.
41998    pub fn id(mut self, new_value: i64) -> CreativePatchCall<'a, C> {
41999        self._id = new_value;
42000        self
42001    }
42002    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
42003    /// while executing the actual API request.
42004    ///
42005    /// ````text
42006    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
42007    /// ````
42008    ///
42009    /// Sets the *delegate* property to the given value.
42010    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CreativePatchCall<'a, C> {
42011        self._delegate = Some(new_value);
42012        self
42013    }
42014
42015    /// Set any additional parameter of the query string used in the request.
42016    /// It should be used to set parameters which are not yet available through their own
42017    /// setters.
42018    ///
42019    /// Please note that this method must not be used to set any of the known parameters
42020    /// which have their own setter method. If done anyway, the request will fail.
42021    ///
42022    /// # Additional Parameters
42023    ///
42024    /// * *alt* (query-string) - Data format for the response.
42025    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
42026    /// * *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.
42027    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
42028    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
42029    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
42030    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
42031    pub fn param<T>(mut self, name: T, value: T) -> CreativePatchCall<'a, C>
42032    where
42033        T: AsRef<str>,
42034    {
42035        self._additional_params
42036            .insert(name.as_ref().to_string(), value.as_ref().to_string());
42037        self
42038    }
42039
42040    /// Identifies the authorization scope for the method you are building.
42041    ///
42042    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
42043    /// [`Scope::Dfatrafficking`].
42044    ///
42045    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
42046    /// tokens for more than one scope.
42047    ///
42048    /// Usually there is more than one suitable scope to authorize an operation, some of which may
42049    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
42050    /// sufficient, a read-write scope will do as well.
42051    pub fn add_scope<St>(mut self, scope: St) -> CreativePatchCall<'a, C>
42052    where
42053        St: AsRef<str>,
42054    {
42055        self._scopes.insert(String::from(scope.as_ref()));
42056        self
42057    }
42058    /// Identifies the authorization scope(s) for the method you are building.
42059    ///
42060    /// See [`Self::add_scope()`] for details.
42061    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativePatchCall<'a, C>
42062    where
42063        I: IntoIterator<Item = St>,
42064        St: AsRef<str>,
42065    {
42066        self._scopes
42067            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
42068        self
42069    }
42070
42071    /// Removes all scopes, and no default scope will be used either.
42072    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
42073    /// for details).
42074    pub fn clear_scopes(mut self) -> CreativePatchCall<'a, C> {
42075        self._scopes.clear();
42076        self
42077    }
42078}
42079
42080/// Updates an existing creative.
42081///
42082/// A builder for the *update* method supported by a *creative* resource.
42083/// It is not used directly, but through a [`CreativeMethods`] instance.
42084///
42085/// # Example
42086///
42087/// Instantiate a resource method builder
42088///
42089/// ```test_harness,no_run
42090/// # extern crate hyper;
42091/// # extern crate hyper_rustls;
42092/// # extern crate google_dfareporting3d2 as dfareporting3d2;
42093/// use dfareporting3d2::api::Creative;
42094/// # async fn dox() {
42095/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
42096///
42097/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
42098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
42099/// #     secret,
42100/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
42101/// # ).build().await.unwrap();
42102///
42103/// # let client = hyper_util::client::legacy::Client::builder(
42104/// #     hyper_util::rt::TokioExecutor::new()
42105/// # )
42106/// # .build(
42107/// #     hyper_rustls::HttpsConnectorBuilder::new()
42108/// #         .with_native_roots()
42109/// #         .unwrap()
42110/// #         .https_or_http()
42111/// #         .enable_http1()
42112/// #         .build()
42113/// # );
42114/// # let mut hub = Dfareporting::new(client, auth);
42115/// // As the method needs a request, you would usually fill it with the desired information
42116/// // into the respective structure. Some of the parts shown here might not be applicable !
42117/// // Values shown here are possibly random and not representative !
42118/// let mut req = Creative::default();
42119///
42120/// // You can configure optional parameters by calling the respective setters at will, and
42121/// // execute the final call using `doit()`.
42122/// // Values shown here are possibly random and not representative !
42123/// let result = hub.creatives().update(req, -88)
42124///              .doit().await;
42125/// # }
42126/// ```
42127pub struct CreativeUpdateCall<'a, C>
42128where
42129    C: 'a,
42130{
42131    hub: &'a Dfareporting<C>,
42132    _request: Creative,
42133    _profile_id: i64,
42134    _delegate: Option<&'a mut dyn common::Delegate>,
42135    _additional_params: HashMap<String, String>,
42136    _scopes: BTreeSet<String>,
42137}
42138
42139impl<'a, C> common::CallBuilder for CreativeUpdateCall<'a, C> {}
42140
42141impl<'a, C> CreativeUpdateCall<'a, C>
42142where
42143    C: common::Connector,
42144{
42145    /// Perform the operation you have build so far.
42146    pub async fn doit(mut self) -> common::Result<(common::Response, Creative)> {
42147        use std::borrow::Cow;
42148        use std::io::{Read, Seek};
42149
42150        use common::{url::Params, ToParts};
42151        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
42152
42153        let mut dd = common::DefaultDelegate;
42154        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
42155        dlg.begin(common::MethodInfo {
42156            id: "dfareporting.creatives.update",
42157            http_method: hyper::Method::PUT,
42158        });
42159
42160        for &field in ["alt", "profileId"].iter() {
42161            if self._additional_params.contains_key(field) {
42162                dlg.finished(false);
42163                return Err(common::Error::FieldClash(field));
42164            }
42165        }
42166
42167        let mut params = Params::with_capacity(4 + self._additional_params.len());
42168        params.push("profileId", self._profile_id.to_string());
42169
42170        params.extend(self._additional_params.iter());
42171
42172        params.push("alt", "json");
42173        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives";
42174        if self._scopes.is_empty() {
42175            self._scopes
42176                .insert(Scope::Dfatrafficking.as_ref().to_string());
42177        }
42178
42179        #[allow(clippy::single_element_loop)]
42180        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
42181            url = params.uri_replacement(url, param_name, find_this, false);
42182        }
42183        {
42184            let to_remove = ["profileId"];
42185            params.remove_params(&to_remove);
42186        }
42187
42188        let url = params.parse_with_url(&url);
42189
42190        let mut json_mime_type = mime::APPLICATION_JSON;
42191        let mut request_value_reader = {
42192            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
42193            common::remove_json_null_values(&mut value);
42194            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
42195            serde_json::to_writer(&mut dst, &value).unwrap();
42196            dst
42197        };
42198        let request_size = request_value_reader
42199            .seek(std::io::SeekFrom::End(0))
42200            .unwrap();
42201        request_value_reader
42202            .seek(std::io::SeekFrom::Start(0))
42203            .unwrap();
42204
42205        loop {
42206            let token = match self
42207                .hub
42208                .auth
42209                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
42210                .await
42211            {
42212                Ok(token) => token,
42213                Err(e) => match dlg.token(e) {
42214                    Ok(token) => token,
42215                    Err(e) => {
42216                        dlg.finished(false);
42217                        return Err(common::Error::MissingToken(e));
42218                    }
42219                },
42220            };
42221            request_value_reader
42222                .seek(std::io::SeekFrom::Start(0))
42223                .unwrap();
42224            let mut req_result = {
42225                let client = &self.hub.client;
42226                dlg.pre_request();
42227                let mut req_builder = hyper::Request::builder()
42228                    .method(hyper::Method::PUT)
42229                    .uri(url.as_str())
42230                    .header(USER_AGENT, self.hub._user_agent.clone());
42231
42232                if let Some(token) = token.as_ref() {
42233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
42234                }
42235
42236                let request = req_builder
42237                    .header(CONTENT_TYPE, json_mime_type.to_string())
42238                    .header(CONTENT_LENGTH, request_size as u64)
42239                    .body(common::to_body(
42240                        request_value_reader.get_ref().clone().into(),
42241                    ));
42242
42243                client.request(request.unwrap()).await
42244            };
42245
42246            match req_result {
42247                Err(err) => {
42248                    if let common::Retry::After(d) = dlg.http_error(&err) {
42249                        sleep(d).await;
42250                        continue;
42251                    }
42252                    dlg.finished(false);
42253                    return Err(common::Error::HttpError(err));
42254                }
42255                Ok(res) => {
42256                    let (mut parts, body) = res.into_parts();
42257                    let mut body = common::Body::new(body);
42258                    if !parts.status.is_success() {
42259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42260                        let error = serde_json::from_str(&common::to_string(&bytes));
42261                        let response = common::to_response(parts, bytes.into());
42262
42263                        if let common::Retry::After(d) =
42264                            dlg.http_failure(&response, error.as_ref().ok())
42265                        {
42266                            sleep(d).await;
42267                            continue;
42268                        }
42269
42270                        dlg.finished(false);
42271
42272                        return Err(match error {
42273                            Ok(value) => common::Error::BadRequest(value),
42274                            _ => common::Error::Failure(response),
42275                        });
42276                    }
42277                    let response = {
42278                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42279                        let encoded = common::to_string(&bytes);
42280                        match serde_json::from_str(&encoded) {
42281                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
42282                            Err(error) => {
42283                                dlg.response_json_decode_error(&encoded, &error);
42284                                return Err(common::Error::JsonDecodeError(
42285                                    encoded.to_string(),
42286                                    error,
42287                                ));
42288                            }
42289                        }
42290                    };
42291
42292                    dlg.finished(true);
42293                    return Ok(response);
42294                }
42295            }
42296        }
42297    }
42298
42299    ///
42300    /// Sets the *request* property to the given value.
42301    ///
42302    /// Even though the property as already been set when instantiating this call,
42303    /// we provide this method for API completeness.
42304    pub fn request(mut self, new_value: Creative) -> CreativeUpdateCall<'a, C> {
42305        self._request = new_value;
42306        self
42307    }
42308    /// User profile ID associated with this request.
42309    ///
42310    /// Sets the *profile id* path property to the given value.
42311    ///
42312    /// Even though the property as already been set when instantiating this call,
42313    /// we provide this method for API completeness.
42314    pub fn profile_id(mut self, new_value: i64) -> CreativeUpdateCall<'a, C> {
42315        self._profile_id = new_value;
42316        self
42317    }
42318    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
42319    /// while executing the actual API request.
42320    ///
42321    /// ````text
42322    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
42323    /// ````
42324    ///
42325    /// Sets the *delegate* property to the given value.
42326    pub fn delegate(
42327        mut self,
42328        new_value: &'a mut dyn common::Delegate,
42329    ) -> CreativeUpdateCall<'a, C> {
42330        self._delegate = Some(new_value);
42331        self
42332    }
42333
42334    /// Set any additional parameter of the query string used in the request.
42335    /// It should be used to set parameters which are not yet available through their own
42336    /// setters.
42337    ///
42338    /// Please note that this method must not be used to set any of the known parameters
42339    /// which have their own setter method. If done anyway, the request will fail.
42340    ///
42341    /// # Additional Parameters
42342    ///
42343    /// * *alt* (query-string) - Data format for the response.
42344    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
42345    /// * *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.
42346    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
42347    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
42348    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
42349    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
42350    pub fn param<T>(mut self, name: T, value: T) -> CreativeUpdateCall<'a, C>
42351    where
42352        T: AsRef<str>,
42353    {
42354        self._additional_params
42355            .insert(name.as_ref().to_string(), value.as_ref().to_string());
42356        self
42357    }
42358
42359    /// Identifies the authorization scope for the method you are building.
42360    ///
42361    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
42362    /// [`Scope::Dfatrafficking`].
42363    ///
42364    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
42365    /// tokens for more than one scope.
42366    ///
42367    /// Usually there is more than one suitable scope to authorize an operation, some of which may
42368    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
42369    /// sufficient, a read-write scope will do as well.
42370    pub fn add_scope<St>(mut self, scope: St) -> CreativeUpdateCall<'a, C>
42371    where
42372        St: AsRef<str>,
42373    {
42374        self._scopes.insert(String::from(scope.as_ref()));
42375        self
42376    }
42377    /// Identifies the authorization scope(s) for the method you are building.
42378    ///
42379    /// See [`Self::add_scope()`] for details.
42380    pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeUpdateCall<'a, C>
42381    where
42382        I: IntoIterator<Item = St>,
42383        St: AsRef<str>,
42384    {
42385        self._scopes
42386            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
42387        self
42388    }
42389
42390    /// Removes all scopes, and no default scope will be used either.
42391    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
42392    /// for details).
42393    pub fn clear_scopes(mut self) -> CreativeUpdateCall<'a, C> {
42394        self._scopes.clear();
42395        self
42396    }
42397}
42398
42399/// Retrieves list of report dimension values for a list of filters.
42400///
42401/// A builder for the *query* method supported by a *dimensionValue* resource.
42402/// It is not used directly, but through a [`DimensionValueMethods`] instance.
42403///
42404/// # Example
42405///
42406/// Instantiate a resource method builder
42407///
42408/// ```test_harness,no_run
42409/// # extern crate hyper;
42410/// # extern crate hyper_rustls;
42411/// # extern crate google_dfareporting3d2 as dfareporting3d2;
42412/// use dfareporting3d2::api::DimensionValueRequest;
42413/// # async fn dox() {
42414/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
42415///
42416/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
42417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
42418/// #     secret,
42419/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
42420/// # ).build().await.unwrap();
42421///
42422/// # let client = hyper_util::client::legacy::Client::builder(
42423/// #     hyper_util::rt::TokioExecutor::new()
42424/// # )
42425/// # .build(
42426/// #     hyper_rustls::HttpsConnectorBuilder::new()
42427/// #         .with_native_roots()
42428/// #         .unwrap()
42429/// #         .https_or_http()
42430/// #         .enable_http1()
42431/// #         .build()
42432/// # );
42433/// # let mut hub = Dfareporting::new(client, auth);
42434/// // As the method needs a request, you would usually fill it with the desired information
42435/// // into the respective structure. Some of the parts shown here might not be applicable !
42436/// // Values shown here are possibly random and not representative !
42437/// let mut req = DimensionValueRequest::default();
42438///
42439/// // You can configure optional parameters by calling the respective setters at will, and
42440/// // execute the final call using `doit()`.
42441/// // Values shown here are possibly random and not representative !
42442/// let result = hub.dimension_values().query(req, -1)
42443///              .page_token("sed")
42444///              .max_results(-91)
42445///              .doit().await;
42446/// # }
42447/// ```
42448pub struct DimensionValueQueryCall<'a, C>
42449where
42450    C: 'a,
42451{
42452    hub: &'a Dfareporting<C>,
42453    _request: DimensionValueRequest,
42454    _profile_id: i64,
42455    _page_token: Option<String>,
42456    _max_results: Option<i32>,
42457    _delegate: Option<&'a mut dyn common::Delegate>,
42458    _additional_params: HashMap<String, String>,
42459    _scopes: BTreeSet<String>,
42460}
42461
42462impl<'a, C> common::CallBuilder for DimensionValueQueryCall<'a, C> {}
42463
42464impl<'a, C> DimensionValueQueryCall<'a, C>
42465where
42466    C: common::Connector,
42467{
42468    /// Perform the operation you have build so far.
42469    pub async fn doit(mut self) -> common::Result<(common::Response, DimensionValueList)> {
42470        use std::borrow::Cow;
42471        use std::io::{Read, Seek};
42472
42473        use common::{url::Params, ToParts};
42474        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
42475
42476        let mut dd = common::DefaultDelegate;
42477        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
42478        dlg.begin(common::MethodInfo {
42479            id: "dfareporting.dimensionValues.query",
42480            http_method: hyper::Method::POST,
42481        });
42482
42483        for &field in ["alt", "profileId", "pageToken", "maxResults"].iter() {
42484            if self._additional_params.contains_key(field) {
42485                dlg.finished(false);
42486                return Err(common::Error::FieldClash(field));
42487            }
42488        }
42489
42490        let mut params = Params::with_capacity(6 + self._additional_params.len());
42491        params.push("profileId", self._profile_id.to_string());
42492        if let Some(value) = self._page_token.as_ref() {
42493            params.push("pageToken", value);
42494        }
42495        if let Some(value) = self._max_results.as_ref() {
42496            params.push("maxResults", value.to_string());
42497        }
42498
42499        params.extend(self._additional_params.iter());
42500
42501        params.push("alt", "json");
42502        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dimensionvalues/query";
42503        if self._scopes.is_empty() {
42504            self._scopes.insert(Scope::Full.as_ref().to_string());
42505        }
42506
42507        #[allow(clippy::single_element_loop)]
42508        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
42509            url = params.uri_replacement(url, param_name, find_this, false);
42510        }
42511        {
42512            let to_remove = ["profileId"];
42513            params.remove_params(&to_remove);
42514        }
42515
42516        let url = params.parse_with_url(&url);
42517
42518        let mut json_mime_type = mime::APPLICATION_JSON;
42519        let mut request_value_reader = {
42520            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
42521            common::remove_json_null_values(&mut value);
42522            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
42523            serde_json::to_writer(&mut dst, &value).unwrap();
42524            dst
42525        };
42526        let request_size = request_value_reader
42527            .seek(std::io::SeekFrom::End(0))
42528            .unwrap();
42529        request_value_reader
42530            .seek(std::io::SeekFrom::Start(0))
42531            .unwrap();
42532
42533        loop {
42534            let token = match self
42535                .hub
42536                .auth
42537                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
42538                .await
42539            {
42540                Ok(token) => token,
42541                Err(e) => match dlg.token(e) {
42542                    Ok(token) => token,
42543                    Err(e) => {
42544                        dlg.finished(false);
42545                        return Err(common::Error::MissingToken(e));
42546                    }
42547                },
42548            };
42549            request_value_reader
42550                .seek(std::io::SeekFrom::Start(0))
42551                .unwrap();
42552            let mut req_result = {
42553                let client = &self.hub.client;
42554                dlg.pre_request();
42555                let mut req_builder = hyper::Request::builder()
42556                    .method(hyper::Method::POST)
42557                    .uri(url.as_str())
42558                    .header(USER_AGENT, self.hub._user_agent.clone());
42559
42560                if let Some(token) = token.as_ref() {
42561                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
42562                }
42563
42564                let request = req_builder
42565                    .header(CONTENT_TYPE, json_mime_type.to_string())
42566                    .header(CONTENT_LENGTH, request_size as u64)
42567                    .body(common::to_body(
42568                        request_value_reader.get_ref().clone().into(),
42569                    ));
42570
42571                client.request(request.unwrap()).await
42572            };
42573
42574            match req_result {
42575                Err(err) => {
42576                    if let common::Retry::After(d) = dlg.http_error(&err) {
42577                        sleep(d).await;
42578                        continue;
42579                    }
42580                    dlg.finished(false);
42581                    return Err(common::Error::HttpError(err));
42582                }
42583                Ok(res) => {
42584                    let (mut parts, body) = res.into_parts();
42585                    let mut body = common::Body::new(body);
42586                    if !parts.status.is_success() {
42587                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42588                        let error = serde_json::from_str(&common::to_string(&bytes));
42589                        let response = common::to_response(parts, bytes.into());
42590
42591                        if let common::Retry::After(d) =
42592                            dlg.http_failure(&response, error.as_ref().ok())
42593                        {
42594                            sleep(d).await;
42595                            continue;
42596                        }
42597
42598                        dlg.finished(false);
42599
42600                        return Err(match error {
42601                            Ok(value) => common::Error::BadRequest(value),
42602                            _ => common::Error::Failure(response),
42603                        });
42604                    }
42605                    let response = {
42606                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42607                        let encoded = common::to_string(&bytes);
42608                        match serde_json::from_str(&encoded) {
42609                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
42610                            Err(error) => {
42611                                dlg.response_json_decode_error(&encoded, &error);
42612                                return Err(common::Error::JsonDecodeError(
42613                                    encoded.to_string(),
42614                                    error,
42615                                ));
42616                            }
42617                        }
42618                    };
42619
42620                    dlg.finished(true);
42621                    return Ok(response);
42622                }
42623            }
42624        }
42625    }
42626
42627    ///
42628    /// Sets the *request* property to the given value.
42629    ///
42630    /// Even though the property as already been set when instantiating this call,
42631    /// we provide this method for API completeness.
42632    pub fn request(mut self, new_value: DimensionValueRequest) -> DimensionValueQueryCall<'a, C> {
42633        self._request = new_value;
42634        self
42635    }
42636    /// The DFA user profile ID.
42637    ///
42638    /// Sets the *profile id* path property to the given value.
42639    ///
42640    /// Even though the property as already been set when instantiating this call,
42641    /// we provide this method for API completeness.
42642    pub fn profile_id(mut self, new_value: i64) -> DimensionValueQueryCall<'a, C> {
42643        self._profile_id = new_value;
42644        self
42645    }
42646    /// The value of the nextToken from the previous result page.
42647    ///
42648    /// Sets the *page token* query property to the given value.
42649    pub fn page_token(mut self, new_value: &str) -> DimensionValueQueryCall<'a, C> {
42650        self._page_token = Some(new_value.to_string());
42651        self
42652    }
42653    /// Maximum number of results to return.
42654    ///
42655    /// Sets the *max results* query property to the given value.
42656    pub fn max_results(mut self, new_value: i32) -> DimensionValueQueryCall<'a, C> {
42657        self._max_results = Some(new_value);
42658        self
42659    }
42660    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
42661    /// while executing the actual API request.
42662    ///
42663    /// ````text
42664    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
42665    /// ````
42666    ///
42667    /// Sets the *delegate* property to the given value.
42668    pub fn delegate(
42669        mut self,
42670        new_value: &'a mut dyn common::Delegate,
42671    ) -> DimensionValueQueryCall<'a, C> {
42672        self._delegate = Some(new_value);
42673        self
42674    }
42675
42676    /// Set any additional parameter of the query string used in the request.
42677    /// It should be used to set parameters which are not yet available through their own
42678    /// setters.
42679    ///
42680    /// Please note that this method must not be used to set any of the known parameters
42681    /// which have their own setter method. If done anyway, the request will fail.
42682    ///
42683    /// # Additional Parameters
42684    ///
42685    /// * *alt* (query-string) - Data format for the response.
42686    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
42687    /// * *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.
42688    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
42689    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
42690    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
42691    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
42692    pub fn param<T>(mut self, name: T, value: T) -> DimensionValueQueryCall<'a, C>
42693    where
42694        T: AsRef<str>,
42695    {
42696        self._additional_params
42697            .insert(name.as_ref().to_string(), value.as_ref().to_string());
42698        self
42699    }
42700
42701    /// Identifies the authorization scope for the method you are building.
42702    ///
42703    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
42704    /// [`Scope::Full`].
42705    ///
42706    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
42707    /// tokens for more than one scope.
42708    ///
42709    /// Usually there is more than one suitable scope to authorize an operation, some of which may
42710    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
42711    /// sufficient, a read-write scope will do as well.
42712    pub fn add_scope<St>(mut self, scope: St) -> DimensionValueQueryCall<'a, C>
42713    where
42714        St: AsRef<str>,
42715    {
42716        self._scopes.insert(String::from(scope.as_ref()));
42717        self
42718    }
42719    /// Identifies the authorization scope(s) for the method you are building.
42720    ///
42721    /// See [`Self::add_scope()`] for details.
42722    pub fn add_scopes<I, St>(mut self, scopes: I) -> DimensionValueQueryCall<'a, C>
42723    where
42724        I: IntoIterator<Item = St>,
42725        St: AsRef<str>,
42726    {
42727        self._scopes
42728            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
42729        self
42730    }
42731
42732    /// Removes all scopes, and no default scope will be used either.
42733    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
42734    /// for details).
42735    pub fn clear_scopes(mut self) -> DimensionValueQueryCall<'a, C> {
42736        self._scopes.clear();
42737        self
42738    }
42739}
42740
42741/// Gets one directory site contact by ID.
42742///
42743/// A builder for the *get* method supported by a *directorySiteContact* resource.
42744/// It is not used directly, but through a [`DirectorySiteContactMethods`] instance.
42745///
42746/// # Example
42747///
42748/// Instantiate a resource method builder
42749///
42750/// ```test_harness,no_run
42751/// # extern crate hyper;
42752/// # extern crate hyper_rustls;
42753/// # extern crate google_dfareporting3d2 as dfareporting3d2;
42754/// # async fn dox() {
42755/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
42756///
42757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
42758/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
42759/// #     secret,
42760/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
42761/// # ).build().await.unwrap();
42762///
42763/// # let client = hyper_util::client::legacy::Client::builder(
42764/// #     hyper_util::rt::TokioExecutor::new()
42765/// # )
42766/// # .build(
42767/// #     hyper_rustls::HttpsConnectorBuilder::new()
42768/// #         .with_native_roots()
42769/// #         .unwrap()
42770/// #         .https_or_http()
42771/// #         .enable_http1()
42772/// #         .build()
42773/// # );
42774/// # let mut hub = Dfareporting::new(client, auth);
42775/// // You can configure optional parameters by calling the respective setters at will, and
42776/// // execute the final call using `doit()`.
42777/// // Values shown here are possibly random and not representative !
42778/// let result = hub.directory_site_contacts().get(-10, -100)
42779///              .doit().await;
42780/// # }
42781/// ```
42782pub struct DirectorySiteContactGetCall<'a, C>
42783where
42784    C: 'a,
42785{
42786    hub: &'a Dfareporting<C>,
42787    _profile_id: i64,
42788    _id: i64,
42789    _delegate: Option<&'a mut dyn common::Delegate>,
42790    _additional_params: HashMap<String, String>,
42791    _scopes: BTreeSet<String>,
42792}
42793
42794impl<'a, C> common::CallBuilder for DirectorySiteContactGetCall<'a, C> {}
42795
42796impl<'a, C> DirectorySiteContactGetCall<'a, C>
42797where
42798    C: common::Connector,
42799{
42800    /// Perform the operation you have build so far.
42801    pub async fn doit(mut self) -> common::Result<(common::Response, DirectorySiteContact)> {
42802        use std::borrow::Cow;
42803        use std::io::{Read, Seek};
42804
42805        use common::{url::Params, ToParts};
42806        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
42807
42808        let mut dd = common::DefaultDelegate;
42809        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
42810        dlg.begin(common::MethodInfo {
42811            id: "dfareporting.directorySiteContacts.get",
42812            http_method: hyper::Method::GET,
42813        });
42814
42815        for &field in ["alt", "profileId", "id"].iter() {
42816            if self._additional_params.contains_key(field) {
42817                dlg.finished(false);
42818                return Err(common::Error::FieldClash(field));
42819            }
42820        }
42821
42822        let mut params = Params::with_capacity(4 + self._additional_params.len());
42823        params.push("profileId", self._profile_id.to_string());
42824        params.push("id", self._id.to_string());
42825
42826        params.extend(self._additional_params.iter());
42827
42828        params.push("alt", "json");
42829        let mut url =
42830            self.hub._base_url.clone() + "userprofiles/{profileId}/directorySiteContacts/{id}";
42831        if self._scopes.is_empty() {
42832            self._scopes
42833                .insert(Scope::Dfatrafficking.as_ref().to_string());
42834        }
42835
42836        #[allow(clippy::single_element_loop)]
42837        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
42838            url = params.uri_replacement(url, param_name, find_this, false);
42839        }
42840        {
42841            let to_remove = ["id", "profileId"];
42842            params.remove_params(&to_remove);
42843        }
42844
42845        let url = params.parse_with_url(&url);
42846
42847        loop {
42848            let token = match self
42849                .hub
42850                .auth
42851                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
42852                .await
42853            {
42854                Ok(token) => token,
42855                Err(e) => match dlg.token(e) {
42856                    Ok(token) => token,
42857                    Err(e) => {
42858                        dlg.finished(false);
42859                        return Err(common::Error::MissingToken(e));
42860                    }
42861                },
42862            };
42863            let mut req_result = {
42864                let client = &self.hub.client;
42865                dlg.pre_request();
42866                let mut req_builder = hyper::Request::builder()
42867                    .method(hyper::Method::GET)
42868                    .uri(url.as_str())
42869                    .header(USER_AGENT, self.hub._user_agent.clone());
42870
42871                if let Some(token) = token.as_ref() {
42872                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
42873                }
42874
42875                let request = req_builder
42876                    .header(CONTENT_LENGTH, 0_u64)
42877                    .body(common::to_body::<String>(None));
42878
42879                client.request(request.unwrap()).await
42880            };
42881
42882            match req_result {
42883                Err(err) => {
42884                    if let common::Retry::After(d) = dlg.http_error(&err) {
42885                        sleep(d).await;
42886                        continue;
42887                    }
42888                    dlg.finished(false);
42889                    return Err(common::Error::HttpError(err));
42890                }
42891                Ok(res) => {
42892                    let (mut parts, body) = res.into_parts();
42893                    let mut body = common::Body::new(body);
42894                    if !parts.status.is_success() {
42895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42896                        let error = serde_json::from_str(&common::to_string(&bytes));
42897                        let response = common::to_response(parts, bytes.into());
42898
42899                        if let common::Retry::After(d) =
42900                            dlg.http_failure(&response, error.as_ref().ok())
42901                        {
42902                            sleep(d).await;
42903                            continue;
42904                        }
42905
42906                        dlg.finished(false);
42907
42908                        return Err(match error {
42909                            Ok(value) => common::Error::BadRequest(value),
42910                            _ => common::Error::Failure(response),
42911                        });
42912                    }
42913                    let response = {
42914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
42915                        let encoded = common::to_string(&bytes);
42916                        match serde_json::from_str(&encoded) {
42917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
42918                            Err(error) => {
42919                                dlg.response_json_decode_error(&encoded, &error);
42920                                return Err(common::Error::JsonDecodeError(
42921                                    encoded.to_string(),
42922                                    error,
42923                                ));
42924                            }
42925                        }
42926                    };
42927
42928                    dlg.finished(true);
42929                    return Ok(response);
42930                }
42931            }
42932        }
42933    }
42934
42935    /// User profile ID associated with this request.
42936    ///
42937    /// Sets the *profile id* path property to the given value.
42938    ///
42939    /// Even though the property as already been set when instantiating this call,
42940    /// we provide this method for API completeness.
42941    pub fn profile_id(mut self, new_value: i64) -> DirectorySiteContactGetCall<'a, C> {
42942        self._profile_id = new_value;
42943        self
42944    }
42945    /// Directory site contact ID.
42946    ///
42947    /// Sets the *id* path property to the given value.
42948    ///
42949    /// Even though the property as already been set when instantiating this call,
42950    /// we provide this method for API completeness.
42951    pub fn id(mut self, new_value: i64) -> DirectorySiteContactGetCall<'a, C> {
42952        self._id = new_value;
42953        self
42954    }
42955    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
42956    /// while executing the actual API request.
42957    ///
42958    /// ````text
42959    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
42960    /// ````
42961    ///
42962    /// Sets the *delegate* property to the given value.
42963    pub fn delegate(
42964        mut self,
42965        new_value: &'a mut dyn common::Delegate,
42966    ) -> DirectorySiteContactGetCall<'a, C> {
42967        self._delegate = Some(new_value);
42968        self
42969    }
42970
42971    /// Set any additional parameter of the query string used in the request.
42972    /// It should be used to set parameters which are not yet available through their own
42973    /// setters.
42974    ///
42975    /// Please note that this method must not be used to set any of the known parameters
42976    /// which have their own setter method. If done anyway, the request will fail.
42977    ///
42978    /// # Additional Parameters
42979    ///
42980    /// * *alt* (query-string) - Data format for the response.
42981    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
42982    /// * *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.
42983    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
42984    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
42985    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
42986    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
42987    pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteContactGetCall<'a, C>
42988    where
42989        T: AsRef<str>,
42990    {
42991        self._additional_params
42992            .insert(name.as_ref().to_string(), value.as_ref().to_string());
42993        self
42994    }
42995
42996    /// Identifies the authorization scope for the method you are building.
42997    ///
42998    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
42999    /// [`Scope::Dfatrafficking`].
43000    ///
43001    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
43002    /// tokens for more than one scope.
43003    ///
43004    /// Usually there is more than one suitable scope to authorize an operation, some of which may
43005    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
43006    /// sufficient, a read-write scope will do as well.
43007    pub fn add_scope<St>(mut self, scope: St) -> DirectorySiteContactGetCall<'a, C>
43008    where
43009        St: AsRef<str>,
43010    {
43011        self._scopes.insert(String::from(scope.as_ref()));
43012        self
43013    }
43014    /// Identifies the authorization scope(s) for the method you are building.
43015    ///
43016    /// See [`Self::add_scope()`] for details.
43017    pub fn add_scopes<I, St>(mut self, scopes: I) -> DirectorySiteContactGetCall<'a, C>
43018    where
43019        I: IntoIterator<Item = St>,
43020        St: AsRef<str>,
43021    {
43022        self._scopes
43023            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
43024        self
43025    }
43026
43027    /// Removes all scopes, and no default scope will be used either.
43028    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
43029    /// for details).
43030    pub fn clear_scopes(mut self) -> DirectorySiteContactGetCall<'a, C> {
43031        self._scopes.clear();
43032        self
43033    }
43034}
43035
43036/// Retrieves a list of directory site contacts, possibly filtered. This method supports paging.
43037///
43038/// A builder for the *list* method supported by a *directorySiteContact* resource.
43039/// It is not used directly, but through a [`DirectorySiteContactMethods`] instance.
43040///
43041/// # Example
43042///
43043/// Instantiate a resource method builder
43044///
43045/// ```test_harness,no_run
43046/// # extern crate hyper;
43047/// # extern crate hyper_rustls;
43048/// # extern crate google_dfareporting3d2 as dfareporting3d2;
43049/// # async fn dox() {
43050/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
43051///
43052/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
43053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
43054/// #     secret,
43055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
43056/// # ).build().await.unwrap();
43057///
43058/// # let client = hyper_util::client::legacy::Client::builder(
43059/// #     hyper_util::rt::TokioExecutor::new()
43060/// # )
43061/// # .build(
43062/// #     hyper_rustls::HttpsConnectorBuilder::new()
43063/// #         .with_native_roots()
43064/// #         .unwrap()
43065/// #         .https_or_http()
43066/// #         .enable_http1()
43067/// #         .build()
43068/// # );
43069/// # let mut hub = Dfareporting::new(client, auth);
43070/// // You can configure optional parameters by calling the respective setters at will, and
43071/// // execute the final call using `doit()`.
43072/// // Values shown here are possibly random and not representative !
43073/// let result = hub.directory_site_contacts().list(-63)
43074///              .sort_order("justo")
43075///              .sort_field("ea")
43076///              .search_string("At")
43077///              .page_token("erat")
43078///              .max_results(-14)
43079///              .add_ids(-76)
43080///              .add_directory_site_ids(-88)
43081///              .doit().await;
43082/// # }
43083/// ```
43084pub struct DirectorySiteContactListCall<'a, C>
43085where
43086    C: 'a,
43087{
43088    hub: &'a Dfareporting<C>,
43089    _profile_id: i64,
43090    _sort_order: Option<String>,
43091    _sort_field: Option<String>,
43092    _search_string: Option<String>,
43093    _page_token: Option<String>,
43094    _max_results: Option<i32>,
43095    _ids: Vec<i64>,
43096    _directory_site_ids: Vec<i64>,
43097    _delegate: Option<&'a mut dyn common::Delegate>,
43098    _additional_params: HashMap<String, String>,
43099    _scopes: BTreeSet<String>,
43100}
43101
43102impl<'a, C> common::CallBuilder for DirectorySiteContactListCall<'a, C> {}
43103
43104impl<'a, C> DirectorySiteContactListCall<'a, C>
43105where
43106    C: common::Connector,
43107{
43108    /// Perform the operation you have build so far.
43109    pub async fn doit(
43110        mut self,
43111    ) -> common::Result<(common::Response, DirectorySiteContactsListResponse)> {
43112        use std::borrow::Cow;
43113        use std::io::{Read, Seek};
43114
43115        use common::{url::Params, ToParts};
43116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
43117
43118        let mut dd = common::DefaultDelegate;
43119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
43120        dlg.begin(common::MethodInfo {
43121            id: "dfareporting.directorySiteContacts.list",
43122            http_method: hyper::Method::GET,
43123        });
43124
43125        for &field in [
43126            "alt",
43127            "profileId",
43128            "sortOrder",
43129            "sortField",
43130            "searchString",
43131            "pageToken",
43132            "maxResults",
43133            "ids",
43134            "directorySiteIds",
43135        ]
43136        .iter()
43137        {
43138            if self._additional_params.contains_key(field) {
43139                dlg.finished(false);
43140                return Err(common::Error::FieldClash(field));
43141            }
43142        }
43143
43144        let mut params = Params::with_capacity(10 + self._additional_params.len());
43145        params.push("profileId", self._profile_id.to_string());
43146        if let Some(value) = self._sort_order.as_ref() {
43147            params.push("sortOrder", value);
43148        }
43149        if let Some(value) = self._sort_field.as_ref() {
43150            params.push("sortField", value);
43151        }
43152        if let Some(value) = self._search_string.as_ref() {
43153            params.push("searchString", value);
43154        }
43155        if let Some(value) = self._page_token.as_ref() {
43156            params.push("pageToken", value);
43157        }
43158        if let Some(value) = self._max_results.as_ref() {
43159            params.push("maxResults", value.to_string());
43160        }
43161        if !self._ids.is_empty() {
43162            for f in self._ids.iter() {
43163                params.push("ids", f.to_string());
43164            }
43165        }
43166        if !self._directory_site_ids.is_empty() {
43167            for f in self._directory_site_ids.iter() {
43168                params.push("directorySiteIds", f.to_string());
43169            }
43170        }
43171
43172        params.extend(self._additional_params.iter());
43173
43174        params.push("alt", "json");
43175        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySiteContacts";
43176        if self._scopes.is_empty() {
43177            self._scopes
43178                .insert(Scope::Dfatrafficking.as_ref().to_string());
43179        }
43180
43181        #[allow(clippy::single_element_loop)]
43182        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
43183            url = params.uri_replacement(url, param_name, find_this, false);
43184        }
43185        {
43186            let to_remove = ["profileId"];
43187            params.remove_params(&to_remove);
43188        }
43189
43190        let url = params.parse_with_url(&url);
43191
43192        loop {
43193            let token = match self
43194                .hub
43195                .auth
43196                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
43197                .await
43198            {
43199                Ok(token) => token,
43200                Err(e) => match dlg.token(e) {
43201                    Ok(token) => token,
43202                    Err(e) => {
43203                        dlg.finished(false);
43204                        return Err(common::Error::MissingToken(e));
43205                    }
43206                },
43207            };
43208            let mut req_result = {
43209                let client = &self.hub.client;
43210                dlg.pre_request();
43211                let mut req_builder = hyper::Request::builder()
43212                    .method(hyper::Method::GET)
43213                    .uri(url.as_str())
43214                    .header(USER_AGENT, self.hub._user_agent.clone());
43215
43216                if let Some(token) = token.as_ref() {
43217                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
43218                }
43219
43220                let request = req_builder
43221                    .header(CONTENT_LENGTH, 0_u64)
43222                    .body(common::to_body::<String>(None));
43223
43224                client.request(request.unwrap()).await
43225            };
43226
43227            match req_result {
43228                Err(err) => {
43229                    if let common::Retry::After(d) = dlg.http_error(&err) {
43230                        sleep(d).await;
43231                        continue;
43232                    }
43233                    dlg.finished(false);
43234                    return Err(common::Error::HttpError(err));
43235                }
43236                Ok(res) => {
43237                    let (mut parts, body) = res.into_parts();
43238                    let mut body = common::Body::new(body);
43239                    if !parts.status.is_success() {
43240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43241                        let error = serde_json::from_str(&common::to_string(&bytes));
43242                        let response = common::to_response(parts, bytes.into());
43243
43244                        if let common::Retry::After(d) =
43245                            dlg.http_failure(&response, error.as_ref().ok())
43246                        {
43247                            sleep(d).await;
43248                            continue;
43249                        }
43250
43251                        dlg.finished(false);
43252
43253                        return Err(match error {
43254                            Ok(value) => common::Error::BadRequest(value),
43255                            _ => common::Error::Failure(response),
43256                        });
43257                    }
43258                    let response = {
43259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43260                        let encoded = common::to_string(&bytes);
43261                        match serde_json::from_str(&encoded) {
43262                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
43263                            Err(error) => {
43264                                dlg.response_json_decode_error(&encoded, &error);
43265                                return Err(common::Error::JsonDecodeError(
43266                                    encoded.to_string(),
43267                                    error,
43268                                ));
43269                            }
43270                        }
43271                    };
43272
43273                    dlg.finished(true);
43274                    return Ok(response);
43275                }
43276            }
43277        }
43278    }
43279
43280    /// User profile ID associated with this request.
43281    ///
43282    /// Sets the *profile id* path property to the given value.
43283    ///
43284    /// Even though the property as already been set when instantiating this call,
43285    /// we provide this method for API completeness.
43286    pub fn profile_id(mut self, new_value: i64) -> DirectorySiteContactListCall<'a, C> {
43287        self._profile_id = new_value;
43288        self
43289    }
43290    /// Order of sorted results.
43291    ///
43292    /// Sets the *sort order* query property to the given value.
43293    pub fn sort_order(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C> {
43294        self._sort_order = Some(new_value.to_string());
43295        self
43296    }
43297    /// Field by which to sort the list.
43298    ///
43299    /// Sets the *sort field* query property to the given value.
43300    pub fn sort_field(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C> {
43301        self._sort_field = Some(new_value.to_string());
43302        self
43303    }
43304    /// Allows searching for objects by name, ID or email. Wildcards (*) are allowed. For example, "directory site contact*2015" will return objects with names like "directory site contact June 2015", "directory site contact April 2015", or simply "directory site contact 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site contact" will match objects with name "my directory site contact", "directory site contact 2015", or simply "directory site contact".
43305    ///
43306    /// Sets the *search string* query property to the given value.
43307    pub fn search_string(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C> {
43308        self._search_string = Some(new_value.to_string());
43309        self
43310    }
43311    /// Value of the nextPageToken from the previous result page.
43312    ///
43313    /// Sets the *page token* query property to the given value.
43314    pub fn page_token(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, C> {
43315        self._page_token = Some(new_value.to_string());
43316        self
43317    }
43318    /// Maximum number of results to return.
43319    ///
43320    /// Sets the *max results* query property to the given value.
43321    pub fn max_results(mut self, new_value: i32) -> DirectorySiteContactListCall<'a, C> {
43322        self._max_results = Some(new_value);
43323        self
43324    }
43325    /// Select only directory site contacts with these IDs.
43326    ///
43327    /// Append the given value to the *ids* query property.
43328    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
43329    pub fn add_ids(mut self, new_value: i64) -> DirectorySiteContactListCall<'a, C> {
43330        self._ids.push(new_value);
43331        self
43332    }
43333    /// Select only directory site contacts with these directory site IDs. This is a required field.
43334    ///
43335    /// Append the given value to the *directory site ids* query property.
43336    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
43337    pub fn add_directory_site_ids(mut self, new_value: i64) -> DirectorySiteContactListCall<'a, C> {
43338        self._directory_site_ids.push(new_value);
43339        self
43340    }
43341    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
43342    /// while executing the actual API request.
43343    ///
43344    /// ````text
43345    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
43346    /// ````
43347    ///
43348    /// Sets the *delegate* property to the given value.
43349    pub fn delegate(
43350        mut self,
43351        new_value: &'a mut dyn common::Delegate,
43352    ) -> DirectorySiteContactListCall<'a, C> {
43353        self._delegate = Some(new_value);
43354        self
43355    }
43356
43357    /// Set any additional parameter of the query string used in the request.
43358    /// It should be used to set parameters which are not yet available through their own
43359    /// setters.
43360    ///
43361    /// Please note that this method must not be used to set any of the known parameters
43362    /// which have their own setter method. If done anyway, the request will fail.
43363    ///
43364    /// # Additional Parameters
43365    ///
43366    /// * *alt* (query-string) - Data format for the response.
43367    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
43368    /// * *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.
43369    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
43370    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
43371    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
43372    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
43373    pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteContactListCall<'a, C>
43374    where
43375        T: AsRef<str>,
43376    {
43377        self._additional_params
43378            .insert(name.as_ref().to_string(), value.as_ref().to_string());
43379        self
43380    }
43381
43382    /// Identifies the authorization scope for the method you are building.
43383    ///
43384    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
43385    /// [`Scope::Dfatrafficking`].
43386    ///
43387    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
43388    /// tokens for more than one scope.
43389    ///
43390    /// Usually there is more than one suitable scope to authorize an operation, some of which may
43391    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
43392    /// sufficient, a read-write scope will do as well.
43393    pub fn add_scope<St>(mut self, scope: St) -> DirectorySiteContactListCall<'a, C>
43394    where
43395        St: AsRef<str>,
43396    {
43397        self._scopes.insert(String::from(scope.as_ref()));
43398        self
43399    }
43400    /// Identifies the authorization scope(s) for the method you are building.
43401    ///
43402    /// See [`Self::add_scope()`] for details.
43403    pub fn add_scopes<I, St>(mut self, scopes: I) -> DirectorySiteContactListCall<'a, C>
43404    where
43405        I: IntoIterator<Item = St>,
43406        St: AsRef<str>,
43407    {
43408        self._scopes
43409            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
43410        self
43411    }
43412
43413    /// Removes all scopes, and no default scope will be used either.
43414    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
43415    /// for details).
43416    pub fn clear_scopes(mut self) -> DirectorySiteContactListCall<'a, C> {
43417        self._scopes.clear();
43418        self
43419    }
43420}
43421
43422/// Gets one directory site by ID.
43423///
43424/// A builder for the *get* method supported by a *directorySite* resource.
43425/// It is not used directly, but through a [`DirectorySiteMethods`] instance.
43426///
43427/// # Example
43428///
43429/// Instantiate a resource method builder
43430///
43431/// ```test_harness,no_run
43432/// # extern crate hyper;
43433/// # extern crate hyper_rustls;
43434/// # extern crate google_dfareporting3d2 as dfareporting3d2;
43435/// # async fn dox() {
43436/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
43437///
43438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
43439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
43440/// #     secret,
43441/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
43442/// # ).build().await.unwrap();
43443///
43444/// # let client = hyper_util::client::legacy::Client::builder(
43445/// #     hyper_util::rt::TokioExecutor::new()
43446/// # )
43447/// # .build(
43448/// #     hyper_rustls::HttpsConnectorBuilder::new()
43449/// #         .with_native_roots()
43450/// #         .unwrap()
43451/// #         .https_or_http()
43452/// #         .enable_http1()
43453/// #         .build()
43454/// # );
43455/// # let mut hub = Dfareporting::new(client, auth);
43456/// // You can configure optional parameters by calling the respective setters at will, and
43457/// // execute the final call using `doit()`.
43458/// // Values shown here are possibly random and not representative !
43459/// let result = hub.directory_sites().get(-91, -81)
43460///              .doit().await;
43461/// # }
43462/// ```
43463pub struct DirectorySiteGetCall<'a, C>
43464where
43465    C: 'a,
43466{
43467    hub: &'a Dfareporting<C>,
43468    _profile_id: i64,
43469    _id: i64,
43470    _delegate: Option<&'a mut dyn common::Delegate>,
43471    _additional_params: HashMap<String, String>,
43472    _scopes: BTreeSet<String>,
43473}
43474
43475impl<'a, C> common::CallBuilder for DirectorySiteGetCall<'a, C> {}
43476
43477impl<'a, C> DirectorySiteGetCall<'a, C>
43478where
43479    C: common::Connector,
43480{
43481    /// Perform the operation you have build so far.
43482    pub async fn doit(mut self) -> common::Result<(common::Response, DirectorySite)> {
43483        use std::borrow::Cow;
43484        use std::io::{Read, Seek};
43485
43486        use common::{url::Params, ToParts};
43487        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
43488
43489        let mut dd = common::DefaultDelegate;
43490        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
43491        dlg.begin(common::MethodInfo {
43492            id: "dfareporting.directorySites.get",
43493            http_method: hyper::Method::GET,
43494        });
43495
43496        for &field in ["alt", "profileId", "id"].iter() {
43497            if self._additional_params.contains_key(field) {
43498                dlg.finished(false);
43499                return Err(common::Error::FieldClash(field));
43500            }
43501        }
43502
43503        let mut params = Params::with_capacity(4 + self._additional_params.len());
43504        params.push("profileId", self._profile_id.to_string());
43505        params.push("id", self._id.to_string());
43506
43507        params.extend(self._additional_params.iter());
43508
43509        params.push("alt", "json");
43510        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites/{id}";
43511        if self._scopes.is_empty() {
43512            self._scopes
43513                .insert(Scope::Dfatrafficking.as_ref().to_string());
43514        }
43515
43516        #[allow(clippy::single_element_loop)]
43517        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
43518            url = params.uri_replacement(url, param_name, find_this, false);
43519        }
43520        {
43521            let to_remove = ["id", "profileId"];
43522            params.remove_params(&to_remove);
43523        }
43524
43525        let url = params.parse_with_url(&url);
43526
43527        loop {
43528            let token = match self
43529                .hub
43530                .auth
43531                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
43532                .await
43533            {
43534                Ok(token) => token,
43535                Err(e) => match dlg.token(e) {
43536                    Ok(token) => token,
43537                    Err(e) => {
43538                        dlg.finished(false);
43539                        return Err(common::Error::MissingToken(e));
43540                    }
43541                },
43542            };
43543            let mut req_result = {
43544                let client = &self.hub.client;
43545                dlg.pre_request();
43546                let mut req_builder = hyper::Request::builder()
43547                    .method(hyper::Method::GET)
43548                    .uri(url.as_str())
43549                    .header(USER_AGENT, self.hub._user_agent.clone());
43550
43551                if let Some(token) = token.as_ref() {
43552                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
43553                }
43554
43555                let request = req_builder
43556                    .header(CONTENT_LENGTH, 0_u64)
43557                    .body(common::to_body::<String>(None));
43558
43559                client.request(request.unwrap()).await
43560            };
43561
43562            match req_result {
43563                Err(err) => {
43564                    if let common::Retry::After(d) = dlg.http_error(&err) {
43565                        sleep(d).await;
43566                        continue;
43567                    }
43568                    dlg.finished(false);
43569                    return Err(common::Error::HttpError(err));
43570                }
43571                Ok(res) => {
43572                    let (mut parts, body) = res.into_parts();
43573                    let mut body = common::Body::new(body);
43574                    if !parts.status.is_success() {
43575                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43576                        let error = serde_json::from_str(&common::to_string(&bytes));
43577                        let response = common::to_response(parts, bytes.into());
43578
43579                        if let common::Retry::After(d) =
43580                            dlg.http_failure(&response, error.as_ref().ok())
43581                        {
43582                            sleep(d).await;
43583                            continue;
43584                        }
43585
43586                        dlg.finished(false);
43587
43588                        return Err(match error {
43589                            Ok(value) => common::Error::BadRequest(value),
43590                            _ => common::Error::Failure(response),
43591                        });
43592                    }
43593                    let response = {
43594                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43595                        let encoded = common::to_string(&bytes);
43596                        match serde_json::from_str(&encoded) {
43597                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
43598                            Err(error) => {
43599                                dlg.response_json_decode_error(&encoded, &error);
43600                                return Err(common::Error::JsonDecodeError(
43601                                    encoded.to_string(),
43602                                    error,
43603                                ));
43604                            }
43605                        }
43606                    };
43607
43608                    dlg.finished(true);
43609                    return Ok(response);
43610                }
43611            }
43612        }
43613    }
43614
43615    /// User profile ID associated with this request.
43616    ///
43617    /// Sets the *profile id* path property to the given value.
43618    ///
43619    /// Even though the property as already been set when instantiating this call,
43620    /// we provide this method for API completeness.
43621    pub fn profile_id(mut self, new_value: i64) -> DirectorySiteGetCall<'a, C> {
43622        self._profile_id = new_value;
43623        self
43624    }
43625    /// Directory site ID.
43626    ///
43627    /// Sets the *id* path property to the given value.
43628    ///
43629    /// Even though the property as already been set when instantiating this call,
43630    /// we provide this method for API completeness.
43631    pub fn id(mut self, new_value: i64) -> DirectorySiteGetCall<'a, C> {
43632        self._id = new_value;
43633        self
43634    }
43635    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
43636    /// while executing the actual API request.
43637    ///
43638    /// ````text
43639    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
43640    /// ````
43641    ///
43642    /// Sets the *delegate* property to the given value.
43643    pub fn delegate(
43644        mut self,
43645        new_value: &'a mut dyn common::Delegate,
43646    ) -> DirectorySiteGetCall<'a, C> {
43647        self._delegate = Some(new_value);
43648        self
43649    }
43650
43651    /// Set any additional parameter of the query string used in the request.
43652    /// It should be used to set parameters which are not yet available through their own
43653    /// setters.
43654    ///
43655    /// Please note that this method must not be used to set any of the known parameters
43656    /// which have their own setter method. If done anyway, the request will fail.
43657    ///
43658    /// # Additional Parameters
43659    ///
43660    /// * *alt* (query-string) - Data format for the response.
43661    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
43662    /// * *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.
43663    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
43664    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
43665    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
43666    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
43667    pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteGetCall<'a, C>
43668    where
43669        T: AsRef<str>,
43670    {
43671        self._additional_params
43672            .insert(name.as_ref().to_string(), value.as_ref().to_string());
43673        self
43674    }
43675
43676    /// Identifies the authorization scope for the method you are building.
43677    ///
43678    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
43679    /// [`Scope::Dfatrafficking`].
43680    ///
43681    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
43682    /// tokens for more than one scope.
43683    ///
43684    /// Usually there is more than one suitable scope to authorize an operation, some of which may
43685    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
43686    /// sufficient, a read-write scope will do as well.
43687    pub fn add_scope<St>(mut self, scope: St) -> DirectorySiteGetCall<'a, C>
43688    where
43689        St: AsRef<str>,
43690    {
43691        self._scopes.insert(String::from(scope.as_ref()));
43692        self
43693    }
43694    /// Identifies the authorization scope(s) for the method you are building.
43695    ///
43696    /// See [`Self::add_scope()`] for details.
43697    pub fn add_scopes<I, St>(mut self, scopes: I) -> DirectorySiteGetCall<'a, C>
43698    where
43699        I: IntoIterator<Item = St>,
43700        St: AsRef<str>,
43701    {
43702        self._scopes
43703            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
43704        self
43705    }
43706
43707    /// Removes all scopes, and no default scope will be used either.
43708    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
43709    /// for details).
43710    pub fn clear_scopes(mut self) -> DirectorySiteGetCall<'a, C> {
43711        self._scopes.clear();
43712        self
43713    }
43714}
43715
43716/// Inserts a new directory site.
43717///
43718/// A builder for the *insert* method supported by a *directorySite* resource.
43719/// It is not used directly, but through a [`DirectorySiteMethods`] instance.
43720///
43721/// # Example
43722///
43723/// Instantiate a resource method builder
43724///
43725/// ```test_harness,no_run
43726/// # extern crate hyper;
43727/// # extern crate hyper_rustls;
43728/// # extern crate google_dfareporting3d2 as dfareporting3d2;
43729/// use dfareporting3d2::api::DirectorySite;
43730/// # async fn dox() {
43731/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
43732///
43733/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
43734/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
43735/// #     secret,
43736/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
43737/// # ).build().await.unwrap();
43738///
43739/// # let client = hyper_util::client::legacy::Client::builder(
43740/// #     hyper_util::rt::TokioExecutor::new()
43741/// # )
43742/// # .build(
43743/// #     hyper_rustls::HttpsConnectorBuilder::new()
43744/// #         .with_native_roots()
43745/// #         .unwrap()
43746/// #         .https_or_http()
43747/// #         .enable_http1()
43748/// #         .build()
43749/// # );
43750/// # let mut hub = Dfareporting::new(client, auth);
43751/// // As the method needs a request, you would usually fill it with the desired information
43752/// // into the respective structure. Some of the parts shown here might not be applicable !
43753/// // Values shown here are possibly random and not representative !
43754/// let mut req = DirectorySite::default();
43755///
43756/// // You can configure optional parameters by calling the respective setters at will, and
43757/// // execute the final call using `doit()`.
43758/// // Values shown here are possibly random and not representative !
43759/// let result = hub.directory_sites().insert(req, -31)
43760///              .doit().await;
43761/// # }
43762/// ```
43763pub struct DirectorySiteInsertCall<'a, C>
43764where
43765    C: 'a,
43766{
43767    hub: &'a Dfareporting<C>,
43768    _request: DirectorySite,
43769    _profile_id: i64,
43770    _delegate: Option<&'a mut dyn common::Delegate>,
43771    _additional_params: HashMap<String, String>,
43772    _scopes: BTreeSet<String>,
43773}
43774
43775impl<'a, C> common::CallBuilder for DirectorySiteInsertCall<'a, C> {}
43776
43777impl<'a, C> DirectorySiteInsertCall<'a, C>
43778where
43779    C: common::Connector,
43780{
43781    /// Perform the operation you have build so far.
43782    pub async fn doit(mut self) -> common::Result<(common::Response, DirectorySite)> {
43783        use std::borrow::Cow;
43784        use std::io::{Read, Seek};
43785
43786        use common::{url::Params, ToParts};
43787        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
43788
43789        let mut dd = common::DefaultDelegate;
43790        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
43791        dlg.begin(common::MethodInfo {
43792            id: "dfareporting.directorySites.insert",
43793            http_method: hyper::Method::POST,
43794        });
43795
43796        for &field in ["alt", "profileId"].iter() {
43797            if self._additional_params.contains_key(field) {
43798                dlg.finished(false);
43799                return Err(common::Error::FieldClash(field));
43800            }
43801        }
43802
43803        let mut params = Params::with_capacity(4 + self._additional_params.len());
43804        params.push("profileId", self._profile_id.to_string());
43805
43806        params.extend(self._additional_params.iter());
43807
43808        params.push("alt", "json");
43809        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites";
43810        if self._scopes.is_empty() {
43811            self._scopes
43812                .insert(Scope::Dfatrafficking.as_ref().to_string());
43813        }
43814
43815        #[allow(clippy::single_element_loop)]
43816        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
43817            url = params.uri_replacement(url, param_name, find_this, false);
43818        }
43819        {
43820            let to_remove = ["profileId"];
43821            params.remove_params(&to_remove);
43822        }
43823
43824        let url = params.parse_with_url(&url);
43825
43826        let mut json_mime_type = mime::APPLICATION_JSON;
43827        let mut request_value_reader = {
43828            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
43829            common::remove_json_null_values(&mut value);
43830            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
43831            serde_json::to_writer(&mut dst, &value).unwrap();
43832            dst
43833        };
43834        let request_size = request_value_reader
43835            .seek(std::io::SeekFrom::End(0))
43836            .unwrap();
43837        request_value_reader
43838            .seek(std::io::SeekFrom::Start(0))
43839            .unwrap();
43840
43841        loop {
43842            let token = match self
43843                .hub
43844                .auth
43845                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
43846                .await
43847            {
43848                Ok(token) => token,
43849                Err(e) => match dlg.token(e) {
43850                    Ok(token) => token,
43851                    Err(e) => {
43852                        dlg.finished(false);
43853                        return Err(common::Error::MissingToken(e));
43854                    }
43855                },
43856            };
43857            request_value_reader
43858                .seek(std::io::SeekFrom::Start(0))
43859                .unwrap();
43860            let mut req_result = {
43861                let client = &self.hub.client;
43862                dlg.pre_request();
43863                let mut req_builder = hyper::Request::builder()
43864                    .method(hyper::Method::POST)
43865                    .uri(url.as_str())
43866                    .header(USER_AGENT, self.hub._user_agent.clone());
43867
43868                if let Some(token) = token.as_ref() {
43869                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
43870                }
43871
43872                let request = req_builder
43873                    .header(CONTENT_TYPE, json_mime_type.to_string())
43874                    .header(CONTENT_LENGTH, request_size as u64)
43875                    .body(common::to_body(
43876                        request_value_reader.get_ref().clone().into(),
43877                    ));
43878
43879                client.request(request.unwrap()).await
43880            };
43881
43882            match req_result {
43883                Err(err) => {
43884                    if let common::Retry::After(d) = dlg.http_error(&err) {
43885                        sleep(d).await;
43886                        continue;
43887                    }
43888                    dlg.finished(false);
43889                    return Err(common::Error::HttpError(err));
43890                }
43891                Ok(res) => {
43892                    let (mut parts, body) = res.into_parts();
43893                    let mut body = common::Body::new(body);
43894                    if !parts.status.is_success() {
43895                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43896                        let error = serde_json::from_str(&common::to_string(&bytes));
43897                        let response = common::to_response(parts, bytes.into());
43898
43899                        if let common::Retry::After(d) =
43900                            dlg.http_failure(&response, error.as_ref().ok())
43901                        {
43902                            sleep(d).await;
43903                            continue;
43904                        }
43905
43906                        dlg.finished(false);
43907
43908                        return Err(match error {
43909                            Ok(value) => common::Error::BadRequest(value),
43910                            _ => common::Error::Failure(response),
43911                        });
43912                    }
43913                    let response = {
43914                        let bytes = common::to_bytes(body).await.unwrap_or_default();
43915                        let encoded = common::to_string(&bytes);
43916                        match serde_json::from_str(&encoded) {
43917                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
43918                            Err(error) => {
43919                                dlg.response_json_decode_error(&encoded, &error);
43920                                return Err(common::Error::JsonDecodeError(
43921                                    encoded.to_string(),
43922                                    error,
43923                                ));
43924                            }
43925                        }
43926                    };
43927
43928                    dlg.finished(true);
43929                    return Ok(response);
43930                }
43931            }
43932        }
43933    }
43934
43935    ///
43936    /// Sets the *request* property to the given value.
43937    ///
43938    /// Even though the property as already been set when instantiating this call,
43939    /// we provide this method for API completeness.
43940    pub fn request(mut self, new_value: DirectorySite) -> DirectorySiteInsertCall<'a, C> {
43941        self._request = new_value;
43942        self
43943    }
43944    /// User profile ID associated with this request.
43945    ///
43946    /// Sets the *profile id* path property to the given value.
43947    ///
43948    /// Even though the property as already been set when instantiating this call,
43949    /// we provide this method for API completeness.
43950    pub fn profile_id(mut self, new_value: i64) -> DirectorySiteInsertCall<'a, C> {
43951        self._profile_id = new_value;
43952        self
43953    }
43954    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
43955    /// while executing the actual API request.
43956    ///
43957    /// ````text
43958    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
43959    /// ````
43960    ///
43961    /// Sets the *delegate* property to the given value.
43962    pub fn delegate(
43963        mut self,
43964        new_value: &'a mut dyn common::Delegate,
43965    ) -> DirectorySiteInsertCall<'a, C> {
43966        self._delegate = Some(new_value);
43967        self
43968    }
43969
43970    /// Set any additional parameter of the query string used in the request.
43971    /// It should be used to set parameters which are not yet available through their own
43972    /// setters.
43973    ///
43974    /// Please note that this method must not be used to set any of the known parameters
43975    /// which have their own setter method. If done anyway, the request will fail.
43976    ///
43977    /// # Additional Parameters
43978    ///
43979    /// * *alt* (query-string) - Data format for the response.
43980    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
43981    /// * *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.
43982    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
43983    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
43984    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
43985    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
43986    pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteInsertCall<'a, C>
43987    where
43988        T: AsRef<str>,
43989    {
43990        self._additional_params
43991            .insert(name.as_ref().to_string(), value.as_ref().to_string());
43992        self
43993    }
43994
43995    /// Identifies the authorization scope for the method you are building.
43996    ///
43997    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
43998    /// [`Scope::Dfatrafficking`].
43999    ///
44000    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
44001    /// tokens for more than one scope.
44002    ///
44003    /// Usually there is more than one suitable scope to authorize an operation, some of which may
44004    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
44005    /// sufficient, a read-write scope will do as well.
44006    pub fn add_scope<St>(mut self, scope: St) -> DirectorySiteInsertCall<'a, C>
44007    where
44008        St: AsRef<str>,
44009    {
44010        self._scopes.insert(String::from(scope.as_ref()));
44011        self
44012    }
44013    /// Identifies the authorization scope(s) for the method you are building.
44014    ///
44015    /// See [`Self::add_scope()`] for details.
44016    pub fn add_scopes<I, St>(mut self, scopes: I) -> DirectorySiteInsertCall<'a, C>
44017    where
44018        I: IntoIterator<Item = St>,
44019        St: AsRef<str>,
44020    {
44021        self._scopes
44022            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
44023        self
44024    }
44025
44026    /// Removes all scopes, and no default scope will be used either.
44027    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
44028    /// for details).
44029    pub fn clear_scopes(mut self) -> DirectorySiteInsertCall<'a, C> {
44030        self._scopes.clear();
44031        self
44032    }
44033}
44034
44035/// Retrieves a list of directory sites, possibly filtered. This method supports paging.
44036///
44037/// A builder for the *list* method supported by a *directorySite* resource.
44038/// It is not used directly, but through a [`DirectorySiteMethods`] instance.
44039///
44040/// # Example
44041///
44042/// Instantiate a resource method builder
44043///
44044/// ```test_harness,no_run
44045/// # extern crate hyper;
44046/// # extern crate hyper_rustls;
44047/// # extern crate google_dfareporting3d2 as dfareporting3d2;
44048/// # async fn dox() {
44049/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
44050///
44051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
44052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
44053/// #     secret,
44054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
44055/// # ).build().await.unwrap();
44056///
44057/// # let client = hyper_util::client::legacy::Client::builder(
44058/// #     hyper_util::rt::TokioExecutor::new()
44059/// # )
44060/// # .build(
44061/// #     hyper_rustls::HttpsConnectorBuilder::new()
44062/// #         .with_native_roots()
44063/// #         .unwrap()
44064/// #         .https_or_http()
44065/// #         .enable_http1()
44066/// #         .build()
44067/// # );
44068/// # let mut hub = Dfareporting::new(client, auth);
44069/// // You can configure optional parameters by calling the respective setters at will, and
44070/// // execute the final call using `doit()`.
44071/// // Values shown here are possibly random and not representative !
44072/// let result = hub.directory_sites().list(-19)
44073///              .sort_order("ipsum")
44074///              .sort_field("voluptua.")
44075///              .search_string("eos")
44076///              .parent_id(-70)
44077///              .page_token("elitr")
44078///              .max_results(-46)
44079///              .add_ids(-72)
44080///              .dfp_network_code("clita")
44081///              .country_id(-1)
44082///              .active(true)
44083///              .accepts_publisher_paid_placements(true)
44084///              .accepts_interstitial_placements(true)
44085///              .accepts_in_stream_video_placements(true)
44086///              .doit().await;
44087/// # }
44088/// ```
44089pub struct DirectorySiteListCall<'a, C>
44090where
44091    C: 'a,
44092{
44093    hub: &'a Dfareporting<C>,
44094    _profile_id: i64,
44095    _sort_order: Option<String>,
44096    _sort_field: Option<String>,
44097    _search_string: Option<String>,
44098    _parent_id: Option<i64>,
44099    _page_token: Option<String>,
44100    _max_results: Option<i32>,
44101    _ids: Vec<i64>,
44102    _dfp_network_code: Option<String>,
44103    _country_id: Option<i64>,
44104    _active: Option<bool>,
44105    _accepts_publisher_paid_placements: Option<bool>,
44106    _accepts_interstitial_placements: Option<bool>,
44107    _accepts_in_stream_video_placements: Option<bool>,
44108    _delegate: Option<&'a mut dyn common::Delegate>,
44109    _additional_params: HashMap<String, String>,
44110    _scopes: BTreeSet<String>,
44111}
44112
44113impl<'a, C> common::CallBuilder for DirectorySiteListCall<'a, C> {}
44114
44115impl<'a, C> DirectorySiteListCall<'a, C>
44116where
44117    C: common::Connector,
44118{
44119    /// Perform the operation you have build so far.
44120    pub async fn doit(mut self) -> common::Result<(common::Response, DirectorySitesListResponse)> {
44121        use std::borrow::Cow;
44122        use std::io::{Read, Seek};
44123
44124        use common::{url::Params, ToParts};
44125        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
44126
44127        let mut dd = common::DefaultDelegate;
44128        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
44129        dlg.begin(common::MethodInfo {
44130            id: "dfareporting.directorySites.list",
44131            http_method: hyper::Method::GET,
44132        });
44133
44134        for &field in [
44135            "alt",
44136            "profileId",
44137            "sortOrder",
44138            "sortField",
44139            "searchString",
44140            "parentId",
44141            "pageToken",
44142            "maxResults",
44143            "ids",
44144            "dfpNetworkCode",
44145            "countryId",
44146            "active",
44147            "acceptsPublisherPaidPlacements",
44148            "acceptsInterstitialPlacements",
44149            "acceptsInStreamVideoPlacements",
44150        ]
44151        .iter()
44152        {
44153            if self._additional_params.contains_key(field) {
44154                dlg.finished(false);
44155                return Err(common::Error::FieldClash(field));
44156            }
44157        }
44158
44159        let mut params = Params::with_capacity(16 + self._additional_params.len());
44160        params.push("profileId", self._profile_id.to_string());
44161        if let Some(value) = self._sort_order.as_ref() {
44162            params.push("sortOrder", value);
44163        }
44164        if let Some(value) = self._sort_field.as_ref() {
44165            params.push("sortField", value);
44166        }
44167        if let Some(value) = self._search_string.as_ref() {
44168            params.push("searchString", value);
44169        }
44170        if let Some(value) = self._parent_id.as_ref() {
44171            params.push("parentId", value.to_string());
44172        }
44173        if let Some(value) = self._page_token.as_ref() {
44174            params.push("pageToken", value);
44175        }
44176        if let Some(value) = self._max_results.as_ref() {
44177            params.push("maxResults", value.to_string());
44178        }
44179        if !self._ids.is_empty() {
44180            for f in self._ids.iter() {
44181                params.push("ids", f.to_string());
44182            }
44183        }
44184        if let Some(value) = self._dfp_network_code.as_ref() {
44185            params.push("dfpNetworkCode", value);
44186        }
44187        if let Some(value) = self._country_id.as_ref() {
44188            params.push("countryId", value.to_string());
44189        }
44190        if let Some(value) = self._active.as_ref() {
44191            params.push("active", value.to_string());
44192        }
44193        if let Some(value) = self._accepts_publisher_paid_placements.as_ref() {
44194            params.push("acceptsPublisherPaidPlacements", value.to_string());
44195        }
44196        if let Some(value) = self._accepts_interstitial_placements.as_ref() {
44197            params.push("acceptsInterstitialPlacements", value.to_string());
44198        }
44199        if let Some(value) = self._accepts_in_stream_video_placements.as_ref() {
44200            params.push("acceptsInStreamVideoPlacements", value.to_string());
44201        }
44202
44203        params.extend(self._additional_params.iter());
44204
44205        params.push("alt", "json");
44206        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites";
44207        if self._scopes.is_empty() {
44208            self._scopes
44209                .insert(Scope::Dfatrafficking.as_ref().to_string());
44210        }
44211
44212        #[allow(clippy::single_element_loop)]
44213        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
44214            url = params.uri_replacement(url, param_name, find_this, false);
44215        }
44216        {
44217            let to_remove = ["profileId"];
44218            params.remove_params(&to_remove);
44219        }
44220
44221        let url = params.parse_with_url(&url);
44222
44223        loop {
44224            let token = match self
44225                .hub
44226                .auth
44227                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
44228                .await
44229            {
44230                Ok(token) => token,
44231                Err(e) => match dlg.token(e) {
44232                    Ok(token) => token,
44233                    Err(e) => {
44234                        dlg.finished(false);
44235                        return Err(common::Error::MissingToken(e));
44236                    }
44237                },
44238            };
44239            let mut req_result = {
44240                let client = &self.hub.client;
44241                dlg.pre_request();
44242                let mut req_builder = hyper::Request::builder()
44243                    .method(hyper::Method::GET)
44244                    .uri(url.as_str())
44245                    .header(USER_AGENT, self.hub._user_agent.clone());
44246
44247                if let Some(token) = token.as_ref() {
44248                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
44249                }
44250
44251                let request = req_builder
44252                    .header(CONTENT_LENGTH, 0_u64)
44253                    .body(common::to_body::<String>(None));
44254
44255                client.request(request.unwrap()).await
44256            };
44257
44258            match req_result {
44259                Err(err) => {
44260                    if let common::Retry::After(d) = dlg.http_error(&err) {
44261                        sleep(d).await;
44262                        continue;
44263                    }
44264                    dlg.finished(false);
44265                    return Err(common::Error::HttpError(err));
44266                }
44267                Ok(res) => {
44268                    let (mut parts, body) = res.into_parts();
44269                    let mut body = common::Body::new(body);
44270                    if !parts.status.is_success() {
44271                        let bytes = common::to_bytes(body).await.unwrap_or_default();
44272                        let error = serde_json::from_str(&common::to_string(&bytes));
44273                        let response = common::to_response(parts, bytes.into());
44274
44275                        if let common::Retry::After(d) =
44276                            dlg.http_failure(&response, error.as_ref().ok())
44277                        {
44278                            sleep(d).await;
44279                            continue;
44280                        }
44281
44282                        dlg.finished(false);
44283
44284                        return Err(match error {
44285                            Ok(value) => common::Error::BadRequest(value),
44286                            _ => common::Error::Failure(response),
44287                        });
44288                    }
44289                    let response = {
44290                        let bytes = common::to_bytes(body).await.unwrap_or_default();
44291                        let encoded = common::to_string(&bytes);
44292                        match serde_json::from_str(&encoded) {
44293                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
44294                            Err(error) => {
44295                                dlg.response_json_decode_error(&encoded, &error);
44296                                return Err(common::Error::JsonDecodeError(
44297                                    encoded.to_string(),
44298                                    error,
44299                                ));
44300                            }
44301                        }
44302                    };
44303
44304                    dlg.finished(true);
44305                    return Ok(response);
44306                }
44307            }
44308        }
44309    }
44310
44311    /// User profile ID associated with this request.
44312    ///
44313    /// Sets the *profile id* path property to the given value.
44314    ///
44315    /// Even though the property as already been set when instantiating this call,
44316    /// we provide this method for API completeness.
44317    pub fn profile_id(mut self, new_value: i64) -> DirectorySiteListCall<'a, C> {
44318        self._profile_id = new_value;
44319        self
44320    }
44321    /// Order of sorted results.
44322    ///
44323    /// Sets the *sort order* query property to the given value.
44324    pub fn sort_order(mut self, new_value: &str) -> DirectorySiteListCall<'a, C> {
44325        self._sort_order = Some(new_value.to_string());
44326        self
44327    }
44328    /// Field by which to sort the list.
44329    ///
44330    /// Sets the *sort field* query property to the given value.
44331    pub fn sort_field(mut self, new_value: &str) -> DirectorySiteListCall<'a, C> {
44332        self._sort_field = Some(new_value.to_string());
44333        self
44334    }
44335    /// Allows searching for objects by name, ID or URL. Wildcards (*) are allowed. For example, "directory site*2015" will return objects with names like "directory site June 2015", "directory site April 2015", or simply "directory site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "directory site" will match objects with name "my directory site", "directory site 2015" or simply, "directory site".
44336    ///
44337    /// Sets the *search string* query property to the given value.
44338    pub fn search_string(mut self, new_value: &str) -> DirectorySiteListCall<'a, C> {
44339        self._search_string = Some(new_value.to_string());
44340        self
44341    }
44342    /// Select only directory sites with this parent ID.
44343    ///
44344    /// Sets the *parent id* query property to the given value.
44345    pub fn parent_id(mut self, new_value: i64) -> DirectorySiteListCall<'a, C> {
44346        self._parent_id = Some(new_value);
44347        self
44348    }
44349    /// Value of the nextPageToken from the previous result page.
44350    ///
44351    /// Sets the *page token* query property to the given value.
44352    pub fn page_token(mut self, new_value: &str) -> DirectorySiteListCall<'a, C> {
44353        self._page_token = Some(new_value.to_string());
44354        self
44355    }
44356    /// Maximum number of results to return.
44357    ///
44358    /// Sets the *max results* query property to the given value.
44359    pub fn max_results(mut self, new_value: i32) -> DirectorySiteListCall<'a, C> {
44360        self._max_results = Some(new_value);
44361        self
44362    }
44363    /// Select only directory sites with these IDs.
44364    ///
44365    /// Append the given value to the *ids* query property.
44366    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
44367    pub fn add_ids(mut self, new_value: i64) -> DirectorySiteListCall<'a, C> {
44368        self._ids.push(new_value);
44369        self
44370    }
44371    /// Select only directory sites with this Ad Manager network code.
44372    ///
44373    /// Sets the *dfp network code* query property to the given value.
44374    pub fn dfp_network_code(mut self, new_value: &str) -> DirectorySiteListCall<'a, C> {
44375        self._dfp_network_code = Some(new_value.to_string());
44376        self
44377    }
44378    /// Select only directory sites with this country ID.
44379    ///
44380    /// Sets the *country id* query property to the given value.
44381    pub fn country_id(mut self, new_value: i64) -> DirectorySiteListCall<'a, C> {
44382        self._country_id = Some(new_value);
44383        self
44384    }
44385    /// Select only active directory sites. Leave blank to retrieve both active and inactive directory sites.
44386    ///
44387    /// Sets the *active* query property to the given value.
44388    pub fn active(mut self, new_value: bool) -> DirectorySiteListCall<'a, C> {
44389        self._active = Some(new_value);
44390        self
44391    }
44392    /// Select only directory sites that accept publisher paid placements. This field can be left blank.
44393    ///
44394    /// Sets the *accepts publisher paid placements* query property to the given value.
44395    pub fn accepts_publisher_paid_placements(
44396        mut self,
44397        new_value: bool,
44398    ) -> DirectorySiteListCall<'a, C> {
44399        self._accepts_publisher_paid_placements = Some(new_value);
44400        self
44401    }
44402    /// This search filter is no longer supported and will have no effect on the results returned.
44403    ///
44404    /// Sets the *accepts interstitial placements* query property to the given value.
44405    pub fn accepts_interstitial_placements(
44406        mut self,
44407        new_value: bool,
44408    ) -> DirectorySiteListCall<'a, C> {
44409        self._accepts_interstitial_placements = Some(new_value);
44410        self
44411    }
44412    /// This search filter is no longer supported and will have no effect on the results returned.
44413    ///
44414    /// Sets the *accepts in stream video placements* query property to the given value.
44415    pub fn accepts_in_stream_video_placements(
44416        mut self,
44417        new_value: bool,
44418    ) -> DirectorySiteListCall<'a, C> {
44419        self._accepts_in_stream_video_placements = Some(new_value);
44420        self
44421    }
44422    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
44423    /// while executing the actual API request.
44424    ///
44425    /// ````text
44426    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
44427    /// ````
44428    ///
44429    /// Sets the *delegate* property to the given value.
44430    pub fn delegate(
44431        mut self,
44432        new_value: &'a mut dyn common::Delegate,
44433    ) -> DirectorySiteListCall<'a, C> {
44434        self._delegate = Some(new_value);
44435        self
44436    }
44437
44438    /// Set any additional parameter of the query string used in the request.
44439    /// It should be used to set parameters which are not yet available through their own
44440    /// setters.
44441    ///
44442    /// Please note that this method must not be used to set any of the known parameters
44443    /// which have their own setter method. If done anyway, the request will fail.
44444    ///
44445    /// # Additional Parameters
44446    ///
44447    /// * *alt* (query-string) - Data format for the response.
44448    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
44449    /// * *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.
44450    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
44451    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
44452    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
44453    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
44454    pub fn param<T>(mut self, name: T, value: T) -> DirectorySiteListCall<'a, C>
44455    where
44456        T: AsRef<str>,
44457    {
44458        self._additional_params
44459            .insert(name.as_ref().to_string(), value.as_ref().to_string());
44460        self
44461    }
44462
44463    /// Identifies the authorization scope for the method you are building.
44464    ///
44465    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
44466    /// [`Scope::Dfatrafficking`].
44467    ///
44468    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
44469    /// tokens for more than one scope.
44470    ///
44471    /// Usually there is more than one suitable scope to authorize an operation, some of which may
44472    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
44473    /// sufficient, a read-write scope will do as well.
44474    pub fn add_scope<St>(mut self, scope: St) -> DirectorySiteListCall<'a, C>
44475    where
44476        St: AsRef<str>,
44477    {
44478        self._scopes.insert(String::from(scope.as_ref()));
44479        self
44480    }
44481    /// Identifies the authorization scope(s) for the method you are building.
44482    ///
44483    /// See [`Self::add_scope()`] for details.
44484    pub fn add_scopes<I, St>(mut self, scopes: I) -> DirectorySiteListCall<'a, C>
44485    where
44486        I: IntoIterator<Item = St>,
44487        St: AsRef<str>,
44488    {
44489        self._scopes
44490            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
44491        self
44492    }
44493
44494    /// Removes all scopes, and no default scope will be used either.
44495    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
44496    /// for details).
44497    pub fn clear_scopes(mut self) -> DirectorySiteListCall<'a, C> {
44498        self._scopes.clear();
44499        self
44500    }
44501}
44502
44503/// Deletes an existing dynamic targeting key.
44504///
44505/// A builder for the *delete* method supported by a *dynamicTargetingKey* resource.
44506/// It is not used directly, but through a [`DynamicTargetingKeyMethods`] instance.
44507///
44508/// # Example
44509///
44510/// Instantiate a resource method builder
44511///
44512/// ```test_harness,no_run
44513/// # extern crate hyper;
44514/// # extern crate hyper_rustls;
44515/// # extern crate google_dfareporting3d2 as dfareporting3d2;
44516/// # async fn dox() {
44517/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
44518///
44519/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
44520/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
44521/// #     secret,
44522/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
44523/// # ).build().await.unwrap();
44524///
44525/// # let client = hyper_util::client::legacy::Client::builder(
44526/// #     hyper_util::rt::TokioExecutor::new()
44527/// # )
44528/// # .build(
44529/// #     hyper_rustls::HttpsConnectorBuilder::new()
44530/// #         .with_native_roots()
44531/// #         .unwrap()
44532/// #         .https_or_http()
44533/// #         .enable_http1()
44534/// #         .build()
44535/// # );
44536/// # let mut hub = Dfareporting::new(client, auth);
44537/// // You can configure optional parameters by calling the respective setters at will, and
44538/// // execute the final call using `doit()`.
44539/// // Values shown here are possibly random and not representative !
44540/// let result = hub.dynamic_targeting_keys().delete(-6, -77, "name", "objectType")
44541///              .doit().await;
44542/// # }
44543/// ```
44544pub struct DynamicTargetingKeyDeleteCall<'a, C>
44545where
44546    C: 'a,
44547{
44548    hub: &'a Dfareporting<C>,
44549    _profile_id: i64,
44550    _object_id: i64,
44551    _name: String,
44552    _object_type: String,
44553    _delegate: Option<&'a mut dyn common::Delegate>,
44554    _additional_params: HashMap<String, String>,
44555    _scopes: BTreeSet<String>,
44556}
44557
44558impl<'a, C> common::CallBuilder for DynamicTargetingKeyDeleteCall<'a, C> {}
44559
44560impl<'a, C> DynamicTargetingKeyDeleteCall<'a, C>
44561where
44562    C: common::Connector,
44563{
44564    /// Perform the operation you have build so far.
44565    pub async fn doit(mut self) -> common::Result<common::Response> {
44566        use std::borrow::Cow;
44567        use std::io::{Read, Seek};
44568
44569        use common::{url::Params, ToParts};
44570        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
44571
44572        let mut dd = common::DefaultDelegate;
44573        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
44574        dlg.begin(common::MethodInfo {
44575            id: "dfareporting.dynamicTargetingKeys.delete",
44576            http_method: hyper::Method::DELETE,
44577        });
44578
44579        for &field in ["profileId", "objectId", "name", "objectType"].iter() {
44580            if self._additional_params.contains_key(field) {
44581                dlg.finished(false);
44582                return Err(common::Error::FieldClash(field));
44583            }
44584        }
44585
44586        let mut params = Params::with_capacity(5 + self._additional_params.len());
44587        params.push("profileId", self._profile_id.to_string());
44588        params.push("objectId", self._object_id.to_string());
44589        params.push("name", self._name);
44590        params.push("objectType", self._object_type);
44591
44592        params.extend(self._additional_params.iter());
44593
44594        let mut url =
44595            self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys/{objectId}";
44596        if self._scopes.is_empty() {
44597            self._scopes
44598                .insert(Scope::Dfatrafficking.as_ref().to_string());
44599        }
44600
44601        #[allow(clippy::single_element_loop)]
44602        for &(find_this, param_name) in
44603            [("{profileId}", "profileId"), ("{objectId}", "objectId")].iter()
44604        {
44605            url = params.uri_replacement(url, param_name, find_this, false);
44606        }
44607        {
44608            let to_remove = ["objectId", "profileId"];
44609            params.remove_params(&to_remove);
44610        }
44611
44612        let url = params.parse_with_url(&url);
44613
44614        loop {
44615            let token = match self
44616                .hub
44617                .auth
44618                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
44619                .await
44620            {
44621                Ok(token) => token,
44622                Err(e) => match dlg.token(e) {
44623                    Ok(token) => token,
44624                    Err(e) => {
44625                        dlg.finished(false);
44626                        return Err(common::Error::MissingToken(e));
44627                    }
44628                },
44629            };
44630            let mut req_result = {
44631                let client = &self.hub.client;
44632                dlg.pre_request();
44633                let mut req_builder = hyper::Request::builder()
44634                    .method(hyper::Method::DELETE)
44635                    .uri(url.as_str())
44636                    .header(USER_AGENT, self.hub._user_agent.clone());
44637
44638                if let Some(token) = token.as_ref() {
44639                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
44640                }
44641
44642                let request = req_builder
44643                    .header(CONTENT_LENGTH, 0_u64)
44644                    .body(common::to_body::<String>(None));
44645
44646                client.request(request.unwrap()).await
44647            };
44648
44649            match req_result {
44650                Err(err) => {
44651                    if let common::Retry::After(d) = dlg.http_error(&err) {
44652                        sleep(d).await;
44653                        continue;
44654                    }
44655                    dlg.finished(false);
44656                    return Err(common::Error::HttpError(err));
44657                }
44658                Ok(res) => {
44659                    let (mut parts, body) = res.into_parts();
44660                    let mut body = common::Body::new(body);
44661                    if !parts.status.is_success() {
44662                        let bytes = common::to_bytes(body).await.unwrap_or_default();
44663                        let error = serde_json::from_str(&common::to_string(&bytes));
44664                        let response = common::to_response(parts, bytes.into());
44665
44666                        if let common::Retry::After(d) =
44667                            dlg.http_failure(&response, error.as_ref().ok())
44668                        {
44669                            sleep(d).await;
44670                            continue;
44671                        }
44672
44673                        dlg.finished(false);
44674
44675                        return Err(match error {
44676                            Ok(value) => common::Error::BadRequest(value),
44677                            _ => common::Error::Failure(response),
44678                        });
44679                    }
44680                    let response = common::Response::from_parts(parts, body);
44681
44682                    dlg.finished(true);
44683                    return Ok(response);
44684                }
44685            }
44686        }
44687    }
44688
44689    /// User profile ID associated with this request.
44690    ///
44691    /// Sets the *profile id* path property to the given value.
44692    ///
44693    /// Even though the property as already been set when instantiating this call,
44694    /// we provide this method for API completeness.
44695    pub fn profile_id(mut self, new_value: i64) -> DynamicTargetingKeyDeleteCall<'a, C> {
44696        self._profile_id = new_value;
44697        self
44698    }
44699    /// ID of the object of this dynamic targeting key. This is a required field.
44700    ///
44701    /// Sets the *object id* path property to the given value.
44702    ///
44703    /// Even though the property as already been set when instantiating this call,
44704    /// we provide this method for API completeness.
44705    pub fn object_id(mut self, new_value: i64) -> DynamicTargetingKeyDeleteCall<'a, C> {
44706        self._object_id = new_value;
44707        self
44708    }
44709    /// Name of this dynamic targeting key. This is a required field. Must be less than 256 characters long and cannot contain commas. All characters are converted to lowercase.
44710    ///
44711    /// Sets the *name* query property to the given value.
44712    ///
44713    /// Even though the property as already been set when instantiating this call,
44714    /// we provide this method for API completeness.
44715    pub fn name(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C> {
44716        self._name = new_value.to_string();
44717        self
44718    }
44719    /// Type of the object of this dynamic targeting key. This is a required field.
44720    ///
44721    /// Sets the *object type* query property to the given value.
44722    ///
44723    /// Even though the property as already been set when instantiating this call,
44724    /// we provide this method for API completeness.
44725    pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, C> {
44726        self._object_type = new_value.to_string();
44727        self
44728    }
44729    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
44730    /// while executing the actual API request.
44731    ///
44732    /// ````text
44733    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
44734    /// ````
44735    ///
44736    /// Sets the *delegate* property to the given value.
44737    pub fn delegate(
44738        mut self,
44739        new_value: &'a mut dyn common::Delegate,
44740    ) -> DynamicTargetingKeyDeleteCall<'a, C> {
44741        self._delegate = Some(new_value);
44742        self
44743    }
44744
44745    /// Set any additional parameter of the query string used in the request.
44746    /// It should be used to set parameters which are not yet available through their own
44747    /// setters.
44748    ///
44749    /// Please note that this method must not be used to set any of the known parameters
44750    /// which have their own setter method. If done anyway, the request will fail.
44751    ///
44752    /// # Additional Parameters
44753    ///
44754    /// * *alt* (query-string) - Data format for the response.
44755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
44756    /// * *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.
44757    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
44758    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
44759    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
44760    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
44761    pub fn param<T>(mut self, name: T, value: T) -> DynamicTargetingKeyDeleteCall<'a, C>
44762    where
44763        T: AsRef<str>,
44764    {
44765        self._additional_params
44766            .insert(name.as_ref().to_string(), value.as_ref().to_string());
44767        self
44768    }
44769
44770    /// Identifies the authorization scope for the method you are building.
44771    ///
44772    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
44773    /// [`Scope::Dfatrafficking`].
44774    ///
44775    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
44776    /// tokens for more than one scope.
44777    ///
44778    /// Usually there is more than one suitable scope to authorize an operation, some of which may
44779    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
44780    /// sufficient, a read-write scope will do as well.
44781    pub fn add_scope<St>(mut self, scope: St) -> DynamicTargetingKeyDeleteCall<'a, C>
44782    where
44783        St: AsRef<str>,
44784    {
44785        self._scopes.insert(String::from(scope.as_ref()));
44786        self
44787    }
44788    /// Identifies the authorization scope(s) for the method you are building.
44789    ///
44790    /// See [`Self::add_scope()`] for details.
44791    pub fn add_scopes<I, St>(mut self, scopes: I) -> DynamicTargetingKeyDeleteCall<'a, C>
44792    where
44793        I: IntoIterator<Item = St>,
44794        St: AsRef<str>,
44795    {
44796        self._scopes
44797            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
44798        self
44799    }
44800
44801    /// Removes all scopes, and no default scope will be used either.
44802    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
44803    /// for details).
44804    pub fn clear_scopes(mut self) -> DynamicTargetingKeyDeleteCall<'a, C> {
44805        self._scopes.clear();
44806        self
44807    }
44808}
44809
44810/// Inserts a new dynamic targeting key. Keys must be created at the advertiser level before being assigned to the advertiser's ads, creatives, or placements. There is a maximum of 1000 keys per advertiser, out of which a maximum of 20 keys can be assigned per ad, creative, or placement.
44811///
44812/// A builder for the *insert* method supported by a *dynamicTargetingKey* resource.
44813/// It is not used directly, but through a [`DynamicTargetingKeyMethods`] instance.
44814///
44815/// # Example
44816///
44817/// Instantiate a resource method builder
44818///
44819/// ```test_harness,no_run
44820/// # extern crate hyper;
44821/// # extern crate hyper_rustls;
44822/// # extern crate google_dfareporting3d2 as dfareporting3d2;
44823/// use dfareporting3d2::api::DynamicTargetingKey;
44824/// # async fn dox() {
44825/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
44826///
44827/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
44828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
44829/// #     secret,
44830/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
44831/// # ).build().await.unwrap();
44832///
44833/// # let client = hyper_util::client::legacy::Client::builder(
44834/// #     hyper_util::rt::TokioExecutor::new()
44835/// # )
44836/// # .build(
44837/// #     hyper_rustls::HttpsConnectorBuilder::new()
44838/// #         .with_native_roots()
44839/// #         .unwrap()
44840/// #         .https_or_http()
44841/// #         .enable_http1()
44842/// #         .build()
44843/// # );
44844/// # let mut hub = Dfareporting::new(client, auth);
44845/// // As the method needs a request, you would usually fill it with the desired information
44846/// // into the respective structure. Some of the parts shown here might not be applicable !
44847/// // Values shown here are possibly random and not representative !
44848/// let mut req = DynamicTargetingKey::default();
44849///
44850/// // You can configure optional parameters by calling the respective setters at will, and
44851/// // execute the final call using `doit()`.
44852/// // Values shown here are possibly random and not representative !
44853/// let result = hub.dynamic_targeting_keys().insert(req, -93)
44854///              .doit().await;
44855/// # }
44856/// ```
44857pub struct DynamicTargetingKeyInsertCall<'a, C>
44858where
44859    C: 'a,
44860{
44861    hub: &'a Dfareporting<C>,
44862    _request: DynamicTargetingKey,
44863    _profile_id: i64,
44864    _delegate: Option<&'a mut dyn common::Delegate>,
44865    _additional_params: HashMap<String, String>,
44866    _scopes: BTreeSet<String>,
44867}
44868
44869impl<'a, C> common::CallBuilder for DynamicTargetingKeyInsertCall<'a, C> {}
44870
44871impl<'a, C> DynamicTargetingKeyInsertCall<'a, C>
44872where
44873    C: common::Connector,
44874{
44875    /// Perform the operation you have build so far.
44876    pub async fn doit(mut self) -> common::Result<(common::Response, DynamicTargetingKey)> {
44877        use std::borrow::Cow;
44878        use std::io::{Read, Seek};
44879
44880        use common::{url::Params, ToParts};
44881        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
44882
44883        let mut dd = common::DefaultDelegate;
44884        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
44885        dlg.begin(common::MethodInfo {
44886            id: "dfareporting.dynamicTargetingKeys.insert",
44887            http_method: hyper::Method::POST,
44888        });
44889
44890        for &field in ["alt", "profileId"].iter() {
44891            if self._additional_params.contains_key(field) {
44892                dlg.finished(false);
44893                return Err(common::Error::FieldClash(field));
44894            }
44895        }
44896
44897        let mut params = Params::with_capacity(4 + self._additional_params.len());
44898        params.push("profileId", self._profile_id.to_string());
44899
44900        params.extend(self._additional_params.iter());
44901
44902        params.push("alt", "json");
44903        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys";
44904        if self._scopes.is_empty() {
44905            self._scopes
44906                .insert(Scope::Dfatrafficking.as_ref().to_string());
44907        }
44908
44909        #[allow(clippy::single_element_loop)]
44910        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
44911            url = params.uri_replacement(url, param_name, find_this, false);
44912        }
44913        {
44914            let to_remove = ["profileId"];
44915            params.remove_params(&to_remove);
44916        }
44917
44918        let url = params.parse_with_url(&url);
44919
44920        let mut json_mime_type = mime::APPLICATION_JSON;
44921        let mut request_value_reader = {
44922            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
44923            common::remove_json_null_values(&mut value);
44924            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
44925            serde_json::to_writer(&mut dst, &value).unwrap();
44926            dst
44927        };
44928        let request_size = request_value_reader
44929            .seek(std::io::SeekFrom::End(0))
44930            .unwrap();
44931        request_value_reader
44932            .seek(std::io::SeekFrom::Start(0))
44933            .unwrap();
44934
44935        loop {
44936            let token = match self
44937                .hub
44938                .auth
44939                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
44940                .await
44941            {
44942                Ok(token) => token,
44943                Err(e) => match dlg.token(e) {
44944                    Ok(token) => token,
44945                    Err(e) => {
44946                        dlg.finished(false);
44947                        return Err(common::Error::MissingToken(e));
44948                    }
44949                },
44950            };
44951            request_value_reader
44952                .seek(std::io::SeekFrom::Start(0))
44953                .unwrap();
44954            let mut req_result = {
44955                let client = &self.hub.client;
44956                dlg.pre_request();
44957                let mut req_builder = hyper::Request::builder()
44958                    .method(hyper::Method::POST)
44959                    .uri(url.as_str())
44960                    .header(USER_AGENT, self.hub._user_agent.clone());
44961
44962                if let Some(token) = token.as_ref() {
44963                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
44964                }
44965
44966                let request = req_builder
44967                    .header(CONTENT_TYPE, json_mime_type.to_string())
44968                    .header(CONTENT_LENGTH, request_size as u64)
44969                    .body(common::to_body(
44970                        request_value_reader.get_ref().clone().into(),
44971                    ));
44972
44973                client.request(request.unwrap()).await
44974            };
44975
44976            match req_result {
44977                Err(err) => {
44978                    if let common::Retry::After(d) = dlg.http_error(&err) {
44979                        sleep(d).await;
44980                        continue;
44981                    }
44982                    dlg.finished(false);
44983                    return Err(common::Error::HttpError(err));
44984                }
44985                Ok(res) => {
44986                    let (mut parts, body) = res.into_parts();
44987                    let mut body = common::Body::new(body);
44988                    if !parts.status.is_success() {
44989                        let bytes = common::to_bytes(body).await.unwrap_or_default();
44990                        let error = serde_json::from_str(&common::to_string(&bytes));
44991                        let response = common::to_response(parts, bytes.into());
44992
44993                        if let common::Retry::After(d) =
44994                            dlg.http_failure(&response, error.as_ref().ok())
44995                        {
44996                            sleep(d).await;
44997                            continue;
44998                        }
44999
45000                        dlg.finished(false);
45001
45002                        return Err(match error {
45003                            Ok(value) => common::Error::BadRequest(value),
45004                            _ => common::Error::Failure(response),
45005                        });
45006                    }
45007                    let response = {
45008                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45009                        let encoded = common::to_string(&bytes);
45010                        match serde_json::from_str(&encoded) {
45011                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
45012                            Err(error) => {
45013                                dlg.response_json_decode_error(&encoded, &error);
45014                                return Err(common::Error::JsonDecodeError(
45015                                    encoded.to_string(),
45016                                    error,
45017                                ));
45018                            }
45019                        }
45020                    };
45021
45022                    dlg.finished(true);
45023                    return Ok(response);
45024                }
45025            }
45026        }
45027    }
45028
45029    ///
45030    /// Sets the *request* property to the given value.
45031    ///
45032    /// Even though the property as already been set when instantiating this call,
45033    /// we provide this method for API completeness.
45034    pub fn request(
45035        mut self,
45036        new_value: DynamicTargetingKey,
45037    ) -> DynamicTargetingKeyInsertCall<'a, C> {
45038        self._request = new_value;
45039        self
45040    }
45041    /// User profile ID associated with this request.
45042    ///
45043    /// Sets the *profile id* path property to the given value.
45044    ///
45045    /// Even though the property as already been set when instantiating this call,
45046    /// we provide this method for API completeness.
45047    pub fn profile_id(mut self, new_value: i64) -> DynamicTargetingKeyInsertCall<'a, C> {
45048        self._profile_id = new_value;
45049        self
45050    }
45051    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
45052    /// while executing the actual API request.
45053    ///
45054    /// ````text
45055    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
45056    /// ````
45057    ///
45058    /// Sets the *delegate* property to the given value.
45059    pub fn delegate(
45060        mut self,
45061        new_value: &'a mut dyn common::Delegate,
45062    ) -> DynamicTargetingKeyInsertCall<'a, C> {
45063        self._delegate = Some(new_value);
45064        self
45065    }
45066
45067    /// Set any additional parameter of the query string used in the request.
45068    /// It should be used to set parameters which are not yet available through their own
45069    /// setters.
45070    ///
45071    /// Please note that this method must not be used to set any of the known parameters
45072    /// which have their own setter method. If done anyway, the request will fail.
45073    ///
45074    /// # Additional Parameters
45075    ///
45076    /// * *alt* (query-string) - Data format for the response.
45077    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
45078    /// * *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.
45079    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
45080    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
45081    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
45082    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
45083    pub fn param<T>(mut self, name: T, value: T) -> DynamicTargetingKeyInsertCall<'a, C>
45084    where
45085        T: AsRef<str>,
45086    {
45087        self._additional_params
45088            .insert(name.as_ref().to_string(), value.as_ref().to_string());
45089        self
45090    }
45091
45092    /// Identifies the authorization scope for the method you are building.
45093    ///
45094    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
45095    /// [`Scope::Dfatrafficking`].
45096    ///
45097    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
45098    /// tokens for more than one scope.
45099    ///
45100    /// Usually there is more than one suitable scope to authorize an operation, some of which may
45101    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
45102    /// sufficient, a read-write scope will do as well.
45103    pub fn add_scope<St>(mut self, scope: St) -> DynamicTargetingKeyInsertCall<'a, C>
45104    where
45105        St: AsRef<str>,
45106    {
45107        self._scopes.insert(String::from(scope.as_ref()));
45108        self
45109    }
45110    /// Identifies the authorization scope(s) for the method you are building.
45111    ///
45112    /// See [`Self::add_scope()`] for details.
45113    pub fn add_scopes<I, St>(mut self, scopes: I) -> DynamicTargetingKeyInsertCall<'a, C>
45114    where
45115        I: IntoIterator<Item = St>,
45116        St: AsRef<str>,
45117    {
45118        self._scopes
45119            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
45120        self
45121    }
45122
45123    /// Removes all scopes, and no default scope will be used either.
45124    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
45125    /// for details).
45126    pub fn clear_scopes(mut self) -> DynamicTargetingKeyInsertCall<'a, C> {
45127        self._scopes.clear();
45128        self
45129    }
45130}
45131
45132/// Retrieves a list of dynamic targeting keys.
45133///
45134/// A builder for the *list* method supported by a *dynamicTargetingKey* resource.
45135/// It is not used directly, but through a [`DynamicTargetingKeyMethods`] instance.
45136///
45137/// # Example
45138///
45139/// Instantiate a resource method builder
45140///
45141/// ```test_harness,no_run
45142/// # extern crate hyper;
45143/// # extern crate hyper_rustls;
45144/// # extern crate google_dfareporting3d2 as dfareporting3d2;
45145/// # async fn dox() {
45146/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
45147///
45148/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
45149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
45150/// #     secret,
45151/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
45152/// # ).build().await.unwrap();
45153///
45154/// # let client = hyper_util::client::legacy::Client::builder(
45155/// #     hyper_util::rt::TokioExecutor::new()
45156/// # )
45157/// # .build(
45158/// #     hyper_rustls::HttpsConnectorBuilder::new()
45159/// #         .with_native_roots()
45160/// #         .unwrap()
45161/// #         .https_or_http()
45162/// #         .enable_http1()
45163/// #         .build()
45164/// # );
45165/// # let mut hub = Dfareporting::new(client, auth);
45166/// // You can configure optional parameters by calling the respective setters at will, and
45167/// // execute the final call using `doit()`.
45168/// // Values shown here are possibly random and not representative !
45169/// let result = hub.dynamic_targeting_keys().list(-18)
45170///              .object_type("ea")
45171///              .object_id(-84)
45172///              .add_names("ipsum")
45173///              .advertiser_id(-67)
45174///              .doit().await;
45175/// # }
45176/// ```
45177pub struct DynamicTargetingKeyListCall<'a, C>
45178where
45179    C: 'a,
45180{
45181    hub: &'a Dfareporting<C>,
45182    _profile_id: i64,
45183    _object_type: Option<String>,
45184    _object_id: Option<i64>,
45185    _names: Vec<String>,
45186    _advertiser_id: Option<i64>,
45187    _delegate: Option<&'a mut dyn common::Delegate>,
45188    _additional_params: HashMap<String, String>,
45189    _scopes: BTreeSet<String>,
45190}
45191
45192impl<'a, C> common::CallBuilder for DynamicTargetingKeyListCall<'a, C> {}
45193
45194impl<'a, C> DynamicTargetingKeyListCall<'a, C>
45195where
45196    C: common::Connector,
45197{
45198    /// Perform the operation you have build so far.
45199    pub async fn doit(
45200        mut self,
45201    ) -> common::Result<(common::Response, DynamicTargetingKeysListResponse)> {
45202        use std::borrow::Cow;
45203        use std::io::{Read, Seek};
45204
45205        use common::{url::Params, ToParts};
45206        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
45207
45208        let mut dd = common::DefaultDelegate;
45209        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
45210        dlg.begin(common::MethodInfo {
45211            id: "dfareporting.dynamicTargetingKeys.list",
45212            http_method: hyper::Method::GET,
45213        });
45214
45215        for &field in [
45216            "alt",
45217            "profileId",
45218            "objectType",
45219            "objectId",
45220            "names",
45221            "advertiserId",
45222        ]
45223        .iter()
45224        {
45225            if self._additional_params.contains_key(field) {
45226                dlg.finished(false);
45227                return Err(common::Error::FieldClash(field));
45228            }
45229        }
45230
45231        let mut params = Params::with_capacity(7 + self._additional_params.len());
45232        params.push("profileId", self._profile_id.to_string());
45233        if let Some(value) = self._object_type.as_ref() {
45234            params.push("objectType", value);
45235        }
45236        if let Some(value) = self._object_id.as_ref() {
45237            params.push("objectId", value.to_string());
45238        }
45239        if !self._names.is_empty() {
45240            for f in self._names.iter() {
45241                params.push("names", f);
45242            }
45243        }
45244        if let Some(value) = self._advertiser_id.as_ref() {
45245            params.push("advertiserId", value.to_string());
45246        }
45247
45248        params.extend(self._additional_params.iter());
45249
45250        params.push("alt", "json");
45251        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys";
45252        if self._scopes.is_empty() {
45253            self._scopes
45254                .insert(Scope::Dfatrafficking.as_ref().to_string());
45255        }
45256
45257        #[allow(clippy::single_element_loop)]
45258        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
45259            url = params.uri_replacement(url, param_name, find_this, false);
45260        }
45261        {
45262            let to_remove = ["profileId"];
45263            params.remove_params(&to_remove);
45264        }
45265
45266        let url = params.parse_with_url(&url);
45267
45268        loop {
45269            let token = match self
45270                .hub
45271                .auth
45272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
45273                .await
45274            {
45275                Ok(token) => token,
45276                Err(e) => match dlg.token(e) {
45277                    Ok(token) => token,
45278                    Err(e) => {
45279                        dlg.finished(false);
45280                        return Err(common::Error::MissingToken(e));
45281                    }
45282                },
45283            };
45284            let mut req_result = {
45285                let client = &self.hub.client;
45286                dlg.pre_request();
45287                let mut req_builder = hyper::Request::builder()
45288                    .method(hyper::Method::GET)
45289                    .uri(url.as_str())
45290                    .header(USER_AGENT, self.hub._user_agent.clone());
45291
45292                if let Some(token) = token.as_ref() {
45293                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
45294                }
45295
45296                let request = req_builder
45297                    .header(CONTENT_LENGTH, 0_u64)
45298                    .body(common::to_body::<String>(None));
45299
45300                client.request(request.unwrap()).await
45301            };
45302
45303            match req_result {
45304                Err(err) => {
45305                    if let common::Retry::After(d) = dlg.http_error(&err) {
45306                        sleep(d).await;
45307                        continue;
45308                    }
45309                    dlg.finished(false);
45310                    return Err(common::Error::HttpError(err));
45311                }
45312                Ok(res) => {
45313                    let (mut parts, body) = res.into_parts();
45314                    let mut body = common::Body::new(body);
45315                    if !parts.status.is_success() {
45316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45317                        let error = serde_json::from_str(&common::to_string(&bytes));
45318                        let response = common::to_response(parts, bytes.into());
45319
45320                        if let common::Retry::After(d) =
45321                            dlg.http_failure(&response, error.as_ref().ok())
45322                        {
45323                            sleep(d).await;
45324                            continue;
45325                        }
45326
45327                        dlg.finished(false);
45328
45329                        return Err(match error {
45330                            Ok(value) => common::Error::BadRequest(value),
45331                            _ => common::Error::Failure(response),
45332                        });
45333                    }
45334                    let response = {
45335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45336                        let encoded = common::to_string(&bytes);
45337                        match serde_json::from_str(&encoded) {
45338                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
45339                            Err(error) => {
45340                                dlg.response_json_decode_error(&encoded, &error);
45341                                return Err(common::Error::JsonDecodeError(
45342                                    encoded.to_string(),
45343                                    error,
45344                                ));
45345                            }
45346                        }
45347                    };
45348
45349                    dlg.finished(true);
45350                    return Ok(response);
45351                }
45352            }
45353        }
45354    }
45355
45356    /// User profile ID associated with this request.
45357    ///
45358    /// Sets the *profile id* path property to the given value.
45359    ///
45360    /// Even though the property as already been set when instantiating this call,
45361    /// we provide this method for API completeness.
45362    pub fn profile_id(mut self, new_value: i64) -> DynamicTargetingKeyListCall<'a, C> {
45363        self._profile_id = new_value;
45364        self
45365    }
45366    /// Select only dynamic targeting keys with this object type.
45367    ///
45368    /// Sets the *object type* query property to the given value.
45369    pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C> {
45370        self._object_type = Some(new_value.to_string());
45371        self
45372    }
45373    /// Select only dynamic targeting keys with this object ID.
45374    ///
45375    /// Sets the *object id* query property to the given value.
45376    pub fn object_id(mut self, new_value: i64) -> DynamicTargetingKeyListCall<'a, C> {
45377        self._object_id = Some(new_value);
45378        self
45379    }
45380    /// Select only dynamic targeting keys exactly matching these names.
45381    ///
45382    /// Append the given value to the *names* query property.
45383    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
45384    pub fn add_names(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, C> {
45385        self._names.push(new_value.to_string());
45386        self
45387    }
45388    /// Select only dynamic targeting keys whose object has this advertiser ID.
45389    ///
45390    /// Sets the *advertiser id* query property to the given value.
45391    pub fn advertiser_id(mut self, new_value: i64) -> DynamicTargetingKeyListCall<'a, C> {
45392        self._advertiser_id = Some(new_value);
45393        self
45394    }
45395    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
45396    /// while executing the actual API request.
45397    ///
45398    /// ````text
45399    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
45400    /// ````
45401    ///
45402    /// Sets the *delegate* property to the given value.
45403    pub fn delegate(
45404        mut self,
45405        new_value: &'a mut dyn common::Delegate,
45406    ) -> DynamicTargetingKeyListCall<'a, C> {
45407        self._delegate = Some(new_value);
45408        self
45409    }
45410
45411    /// Set any additional parameter of the query string used in the request.
45412    /// It should be used to set parameters which are not yet available through their own
45413    /// setters.
45414    ///
45415    /// Please note that this method must not be used to set any of the known parameters
45416    /// which have their own setter method. If done anyway, the request will fail.
45417    ///
45418    /// # Additional Parameters
45419    ///
45420    /// * *alt* (query-string) - Data format for the response.
45421    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
45422    /// * *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.
45423    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
45424    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
45425    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
45426    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
45427    pub fn param<T>(mut self, name: T, value: T) -> DynamicTargetingKeyListCall<'a, C>
45428    where
45429        T: AsRef<str>,
45430    {
45431        self._additional_params
45432            .insert(name.as_ref().to_string(), value.as_ref().to_string());
45433        self
45434    }
45435
45436    /// Identifies the authorization scope for the method you are building.
45437    ///
45438    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
45439    /// [`Scope::Dfatrafficking`].
45440    ///
45441    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
45442    /// tokens for more than one scope.
45443    ///
45444    /// Usually there is more than one suitable scope to authorize an operation, some of which may
45445    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
45446    /// sufficient, a read-write scope will do as well.
45447    pub fn add_scope<St>(mut self, scope: St) -> DynamicTargetingKeyListCall<'a, C>
45448    where
45449        St: AsRef<str>,
45450    {
45451        self._scopes.insert(String::from(scope.as_ref()));
45452        self
45453    }
45454    /// Identifies the authorization scope(s) for the method you are building.
45455    ///
45456    /// See [`Self::add_scope()`] for details.
45457    pub fn add_scopes<I, St>(mut self, scopes: I) -> DynamicTargetingKeyListCall<'a, C>
45458    where
45459        I: IntoIterator<Item = St>,
45460        St: AsRef<str>,
45461    {
45462        self._scopes
45463            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
45464        self
45465    }
45466
45467    /// Removes all scopes, and no default scope will be used either.
45468    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
45469    /// for details).
45470    pub fn clear_scopes(mut self) -> DynamicTargetingKeyListCall<'a, C> {
45471        self._scopes.clear();
45472        self
45473    }
45474}
45475
45476/// Deletes an existing event tag.
45477///
45478/// A builder for the *delete* method supported by a *eventTag* resource.
45479/// It is not used directly, but through a [`EventTagMethods`] instance.
45480///
45481/// # Example
45482///
45483/// Instantiate a resource method builder
45484///
45485/// ```test_harness,no_run
45486/// # extern crate hyper;
45487/// # extern crate hyper_rustls;
45488/// # extern crate google_dfareporting3d2 as dfareporting3d2;
45489/// # async fn dox() {
45490/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
45491///
45492/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
45493/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
45494/// #     secret,
45495/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
45496/// # ).build().await.unwrap();
45497///
45498/// # let client = hyper_util::client::legacy::Client::builder(
45499/// #     hyper_util::rt::TokioExecutor::new()
45500/// # )
45501/// # .build(
45502/// #     hyper_rustls::HttpsConnectorBuilder::new()
45503/// #         .with_native_roots()
45504/// #         .unwrap()
45505/// #         .https_or_http()
45506/// #         .enable_http1()
45507/// #         .build()
45508/// # );
45509/// # let mut hub = Dfareporting::new(client, auth);
45510/// // You can configure optional parameters by calling the respective setters at will, and
45511/// // execute the final call using `doit()`.
45512/// // Values shown here are possibly random and not representative !
45513/// let result = hub.event_tags().delete(-27, -53)
45514///              .doit().await;
45515/// # }
45516/// ```
45517pub struct EventTagDeleteCall<'a, C>
45518where
45519    C: 'a,
45520{
45521    hub: &'a Dfareporting<C>,
45522    _profile_id: i64,
45523    _id: i64,
45524    _delegate: Option<&'a mut dyn common::Delegate>,
45525    _additional_params: HashMap<String, String>,
45526    _scopes: BTreeSet<String>,
45527}
45528
45529impl<'a, C> common::CallBuilder for EventTagDeleteCall<'a, C> {}
45530
45531impl<'a, C> EventTagDeleteCall<'a, C>
45532where
45533    C: common::Connector,
45534{
45535    /// Perform the operation you have build so far.
45536    pub async fn doit(mut self) -> common::Result<common::Response> {
45537        use std::borrow::Cow;
45538        use std::io::{Read, Seek};
45539
45540        use common::{url::Params, ToParts};
45541        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
45542
45543        let mut dd = common::DefaultDelegate;
45544        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
45545        dlg.begin(common::MethodInfo {
45546            id: "dfareporting.eventTags.delete",
45547            http_method: hyper::Method::DELETE,
45548        });
45549
45550        for &field in ["profileId", "id"].iter() {
45551            if self._additional_params.contains_key(field) {
45552                dlg.finished(false);
45553                return Err(common::Error::FieldClash(field));
45554            }
45555        }
45556
45557        let mut params = Params::with_capacity(3 + self._additional_params.len());
45558        params.push("profileId", self._profile_id.to_string());
45559        params.push("id", self._id.to_string());
45560
45561        params.extend(self._additional_params.iter());
45562
45563        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags/{id}";
45564        if self._scopes.is_empty() {
45565            self._scopes
45566                .insert(Scope::Dfatrafficking.as_ref().to_string());
45567        }
45568
45569        #[allow(clippy::single_element_loop)]
45570        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
45571            url = params.uri_replacement(url, param_name, find_this, false);
45572        }
45573        {
45574            let to_remove = ["id", "profileId"];
45575            params.remove_params(&to_remove);
45576        }
45577
45578        let url = params.parse_with_url(&url);
45579
45580        loop {
45581            let token = match self
45582                .hub
45583                .auth
45584                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
45585                .await
45586            {
45587                Ok(token) => token,
45588                Err(e) => match dlg.token(e) {
45589                    Ok(token) => token,
45590                    Err(e) => {
45591                        dlg.finished(false);
45592                        return Err(common::Error::MissingToken(e));
45593                    }
45594                },
45595            };
45596            let mut req_result = {
45597                let client = &self.hub.client;
45598                dlg.pre_request();
45599                let mut req_builder = hyper::Request::builder()
45600                    .method(hyper::Method::DELETE)
45601                    .uri(url.as_str())
45602                    .header(USER_AGENT, self.hub._user_agent.clone());
45603
45604                if let Some(token) = token.as_ref() {
45605                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
45606                }
45607
45608                let request = req_builder
45609                    .header(CONTENT_LENGTH, 0_u64)
45610                    .body(common::to_body::<String>(None));
45611
45612                client.request(request.unwrap()).await
45613            };
45614
45615            match req_result {
45616                Err(err) => {
45617                    if let common::Retry::After(d) = dlg.http_error(&err) {
45618                        sleep(d).await;
45619                        continue;
45620                    }
45621                    dlg.finished(false);
45622                    return Err(common::Error::HttpError(err));
45623                }
45624                Ok(res) => {
45625                    let (mut parts, body) = res.into_parts();
45626                    let mut body = common::Body::new(body);
45627                    if !parts.status.is_success() {
45628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45629                        let error = serde_json::from_str(&common::to_string(&bytes));
45630                        let response = common::to_response(parts, bytes.into());
45631
45632                        if let common::Retry::After(d) =
45633                            dlg.http_failure(&response, error.as_ref().ok())
45634                        {
45635                            sleep(d).await;
45636                            continue;
45637                        }
45638
45639                        dlg.finished(false);
45640
45641                        return Err(match error {
45642                            Ok(value) => common::Error::BadRequest(value),
45643                            _ => common::Error::Failure(response),
45644                        });
45645                    }
45646                    let response = common::Response::from_parts(parts, body);
45647
45648                    dlg.finished(true);
45649                    return Ok(response);
45650                }
45651            }
45652        }
45653    }
45654
45655    /// User profile ID associated with this request.
45656    ///
45657    /// Sets the *profile id* path property to the given value.
45658    ///
45659    /// Even though the property as already been set when instantiating this call,
45660    /// we provide this method for API completeness.
45661    pub fn profile_id(mut self, new_value: i64) -> EventTagDeleteCall<'a, C> {
45662        self._profile_id = new_value;
45663        self
45664    }
45665    /// Event tag ID.
45666    ///
45667    /// Sets the *id* path property to the given value.
45668    ///
45669    /// Even though the property as already been set when instantiating this call,
45670    /// we provide this method for API completeness.
45671    pub fn id(mut self, new_value: i64) -> EventTagDeleteCall<'a, C> {
45672        self._id = new_value;
45673        self
45674    }
45675    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
45676    /// while executing the actual API request.
45677    ///
45678    /// ````text
45679    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
45680    /// ````
45681    ///
45682    /// Sets the *delegate* property to the given value.
45683    pub fn delegate(
45684        mut self,
45685        new_value: &'a mut dyn common::Delegate,
45686    ) -> EventTagDeleteCall<'a, C> {
45687        self._delegate = Some(new_value);
45688        self
45689    }
45690
45691    /// Set any additional parameter of the query string used in the request.
45692    /// It should be used to set parameters which are not yet available through their own
45693    /// setters.
45694    ///
45695    /// Please note that this method must not be used to set any of the known parameters
45696    /// which have their own setter method. If done anyway, the request will fail.
45697    ///
45698    /// # Additional Parameters
45699    ///
45700    /// * *alt* (query-string) - Data format for the response.
45701    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
45702    /// * *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.
45703    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
45704    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
45705    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
45706    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
45707    pub fn param<T>(mut self, name: T, value: T) -> EventTagDeleteCall<'a, C>
45708    where
45709        T: AsRef<str>,
45710    {
45711        self._additional_params
45712            .insert(name.as_ref().to_string(), value.as_ref().to_string());
45713        self
45714    }
45715
45716    /// Identifies the authorization scope for the method you are building.
45717    ///
45718    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
45719    /// [`Scope::Dfatrafficking`].
45720    ///
45721    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
45722    /// tokens for more than one scope.
45723    ///
45724    /// Usually there is more than one suitable scope to authorize an operation, some of which may
45725    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
45726    /// sufficient, a read-write scope will do as well.
45727    pub fn add_scope<St>(mut self, scope: St) -> EventTagDeleteCall<'a, C>
45728    where
45729        St: AsRef<str>,
45730    {
45731        self._scopes.insert(String::from(scope.as_ref()));
45732        self
45733    }
45734    /// Identifies the authorization scope(s) for the method you are building.
45735    ///
45736    /// See [`Self::add_scope()`] for details.
45737    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagDeleteCall<'a, C>
45738    where
45739        I: IntoIterator<Item = St>,
45740        St: AsRef<str>,
45741    {
45742        self._scopes
45743            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
45744        self
45745    }
45746
45747    /// Removes all scopes, and no default scope will be used either.
45748    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
45749    /// for details).
45750    pub fn clear_scopes(mut self) -> EventTagDeleteCall<'a, C> {
45751        self._scopes.clear();
45752        self
45753    }
45754}
45755
45756/// Gets one event tag by ID.
45757///
45758/// A builder for the *get* method supported by a *eventTag* resource.
45759/// It is not used directly, but through a [`EventTagMethods`] instance.
45760///
45761/// # Example
45762///
45763/// Instantiate a resource method builder
45764///
45765/// ```test_harness,no_run
45766/// # extern crate hyper;
45767/// # extern crate hyper_rustls;
45768/// # extern crate google_dfareporting3d2 as dfareporting3d2;
45769/// # async fn dox() {
45770/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
45771///
45772/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
45773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
45774/// #     secret,
45775/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
45776/// # ).build().await.unwrap();
45777///
45778/// # let client = hyper_util::client::legacy::Client::builder(
45779/// #     hyper_util::rt::TokioExecutor::new()
45780/// # )
45781/// # .build(
45782/// #     hyper_rustls::HttpsConnectorBuilder::new()
45783/// #         .with_native_roots()
45784/// #         .unwrap()
45785/// #         .https_or_http()
45786/// #         .enable_http1()
45787/// #         .build()
45788/// # );
45789/// # let mut hub = Dfareporting::new(client, auth);
45790/// // You can configure optional parameters by calling the respective setters at will, and
45791/// // execute the final call using `doit()`.
45792/// // Values shown here are possibly random and not representative !
45793/// let result = hub.event_tags().get(-98, -101)
45794///              .doit().await;
45795/// # }
45796/// ```
45797pub struct EventTagGetCall<'a, C>
45798where
45799    C: 'a,
45800{
45801    hub: &'a Dfareporting<C>,
45802    _profile_id: i64,
45803    _id: i64,
45804    _delegate: Option<&'a mut dyn common::Delegate>,
45805    _additional_params: HashMap<String, String>,
45806    _scopes: BTreeSet<String>,
45807}
45808
45809impl<'a, C> common::CallBuilder for EventTagGetCall<'a, C> {}
45810
45811impl<'a, C> EventTagGetCall<'a, C>
45812where
45813    C: common::Connector,
45814{
45815    /// Perform the operation you have build so far.
45816    pub async fn doit(mut self) -> common::Result<(common::Response, EventTag)> {
45817        use std::borrow::Cow;
45818        use std::io::{Read, Seek};
45819
45820        use common::{url::Params, ToParts};
45821        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
45822
45823        let mut dd = common::DefaultDelegate;
45824        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
45825        dlg.begin(common::MethodInfo {
45826            id: "dfareporting.eventTags.get",
45827            http_method: hyper::Method::GET,
45828        });
45829
45830        for &field in ["alt", "profileId", "id"].iter() {
45831            if self._additional_params.contains_key(field) {
45832                dlg.finished(false);
45833                return Err(common::Error::FieldClash(field));
45834            }
45835        }
45836
45837        let mut params = Params::with_capacity(4 + self._additional_params.len());
45838        params.push("profileId", self._profile_id.to_string());
45839        params.push("id", self._id.to_string());
45840
45841        params.extend(self._additional_params.iter());
45842
45843        params.push("alt", "json");
45844        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags/{id}";
45845        if self._scopes.is_empty() {
45846            self._scopes
45847                .insert(Scope::Dfatrafficking.as_ref().to_string());
45848        }
45849
45850        #[allow(clippy::single_element_loop)]
45851        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
45852            url = params.uri_replacement(url, param_name, find_this, false);
45853        }
45854        {
45855            let to_remove = ["id", "profileId"];
45856            params.remove_params(&to_remove);
45857        }
45858
45859        let url = params.parse_with_url(&url);
45860
45861        loop {
45862            let token = match self
45863                .hub
45864                .auth
45865                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
45866                .await
45867            {
45868                Ok(token) => token,
45869                Err(e) => match dlg.token(e) {
45870                    Ok(token) => token,
45871                    Err(e) => {
45872                        dlg.finished(false);
45873                        return Err(common::Error::MissingToken(e));
45874                    }
45875                },
45876            };
45877            let mut req_result = {
45878                let client = &self.hub.client;
45879                dlg.pre_request();
45880                let mut req_builder = hyper::Request::builder()
45881                    .method(hyper::Method::GET)
45882                    .uri(url.as_str())
45883                    .header(USER_AGENT, self.hub._user_agent.clone());
45884
45885                if let Some(token) = token.as_ref() {
45886                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
45887                }
45888
45889                let request = req_builder
45890                    .header(CONTENT_LENGTH, 0_u64)
45891                    .body(common::to_body::<String>(None));
45892
45893                client.request(request.unwrap()).await
45894            };
45895
45896            match req_result {
45897                Err(err) => {
45898                    if let common::Retry::After(d) = dlg.http_error(&err) {
45899                        sleep(d).await;
45900                        continue;
45901                    }
45902                    dlg.finished(false);
45903                    return Err(common::Error::HttpError(err));
45904                }
45905                Ok(res) => {
45906                    let (mut parts, body) = res.into_parts();
45907                    let mut body = common::Body::new(body);
45908                    if !parts.status.is_success() {
45909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45910                        let error = serde_json::from_str(&common::to_string(&bytes));
45911                        let response = common::to_response(parts, bytes.into());
45912
45913                        if let common::Retry::After(d) =
45914                            dlg.http_failure(&response, error.as_ref().ok())
45915                        {
45916                            sleep(d).await;
45917                            continue;
45918                        }
45919
45920                        dlg.finished(false);
45921
45922                        return Err(match error {
45923                            Ok(value) => common::Error::BadRequest(value),
45924                            _ => common::Error::Failure(response),
45925                        });
45926                    }
45927                    let response = {
45928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
45929                        let encoded = common::to_string(&bytes);
45930                        match serde_json::from_str(&encoded) {
45931                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
45932                            Err(error) => {
45933                                dlg.response_json_decode_error(&encoded, &error);
45934                                return Err(common::Error::JsonDecodeError(
45935                                    encoded.to_string(),
45936                                    error,
45937                                ));
45938                            }
45939                        }
45940                    };
45941
45942                    dlg.finished(true);
45943                    return Ok(response);
45944                }
45945            }
45946        }
45947    }
45948
45949    /// User profile ID associated with this request.
45950    ///
45951    /// Sets the *profile id* path property to the given value.
45952    ///
45953    /// Even though the property as already been set when instantiating this call,
45954    /// we provide this method for API completeness.
45955    pub fn profile_id(mut self, new_value: i64) -> EventTagGetCall<'a, C> {
45956        self._profile_id = new_value;
45957        self
45958    }
45959    /// Event tag ID.
45960    ///
45961    /// Sets the *id* path property to the given value.
45962    ///
45963    /// Even though the property as already been set when instantiating this call,
45964    /// we provide this method for API completeness.
45965    pub fn id(mut self, new_value: i64) -> EventTagGetCall<'a, C> {
45966        self._id = new_value;
45967        self
45968    }
45969    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
45970    /// while executing the actual API request.
45971    ///
45972    /// ````text
45973    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
45974    /// ````
45975    ///
45976    /// Sets the *delegate* property to the given value.
45977    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventTagGetCall<'a, C> {
45978        self._delegate = Some(new_value);
45979        self
45980    }
45981
45982    /// Set any additional parameter of the query string used in the request.
45983    /// It should be used to set parameters which are not yet available through their own
45984    /// setters.
45985    ///
45986    /// Please note that this method must not be used to set any of the known parameters
45987    /// which have their own setter method. If done anyway, the request will fail.
45988    ///
45989    /// # Additional Parameters
45990    ///
45991    /// * *alt* (query-string) - Data format for the response.
45992    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
45993    /// * *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.
45994    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
45995    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
45996    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
45997    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
45998    pub fn param<T>(mut self, name: T, value: T) -> EventTagGetCall<'a, C>
45999    where
46000        T: AsRef<str>,
46001    {
46002        self._additional_params
46003            .insert(name.as_ref().to_string(), value.as_ref().to_string());
46004        self
46005    }
46006
46007    /// Identifies the authorization scope for the method you are building.
46008    ///
46009    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
46010    /// [`Scope::Dfatrafficking`].
46011    ///
46012    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
46013    /// tokens for more than one scope.
46014    ///
46015    /// Usually there is more than one suitable scope to authorize an operation, some of which may
46016    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
46017    /// sufficient, a read-write scope will do as well.
46018    pub fn add_scope<St>(mut self, scope: St) -> EventTagGetCall<'a, C>
46019    where
46020        St: AsRef<str>,
46021    {
46022        self._scopes.insert(String::from(scope.as_ref()));
46023        self
46024    }
46025    /// Identifies the authorization scope(s) for the method you are building.
46026    ///
46027    /// See [`Self::add_scope()`] for details.
46028    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagGetCall<'a, C>
46029    where
46030        I: IntoIterator<Item = St>,
46031        St: AsRef<str>,
46032    {
46033        self._scopes
46034            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
46035        self
46036    }
46037
46038    /// Removes all scopes, and no default scope will be used either.
46039    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
46040    /// for details).
46041    pub fn clear_scopes(mut self) -> EventTagGetCall<'a, C> {
46042        self._scopes.clear();
46043        self
46044    }
46045}
46046
46047/// Inserts a new event tag.
46048///
46049/// A builder for the *insert* method supported by a *eventTag* resource.
46050/// It is not used directly, but through a [`EventTagMethods`] instance.
46051///
46052/// # Example
46053///
46054/// Instantiate a resource method builder
46055///
46056/// ```test_harness,no_run
46057/// # extern crate hyper;
46058/// # extern crate hyper_rustls;
46059/// # extern crate google_dfareporting3d2 as dfareporting3d2;
46060/// use dfareporting3d2::api::EventTag;
46061/// # async fn dox() {
46062/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
46063///
46064/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
46065/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
46066/// #     secret,
46067/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
46068/// # ).build().await.unwrap();
46069///
46070/// # let client = hyper_util::client::legacy::Client::builder(
46071/// #     hyper_util::rt::TokioExecutor::new()
46072/// # )
46073/// # .build(
46074/// #     hyper_rustls::HttpsConnectorBuilder::new()
46075/// #         .with_native_roots()
46076/// #         .unwrap()
46077/// #         .https_or_http()
46078/// #         .enable_http1()
46079/// #         .build()
46080/// # );
46081/// # let mut hub = Dfareporting::new(client, auth);
46082/// // As the method needs a request, you would usually fill it with the desired information
46083/// // into the respective structure. Some of the parts shown here might not be applicable !
46084/// // Values shown here are possibly random and not representative !
46085/// let mut req = EventTag::default();
46086///
46087/// // You can configure optional parameters by calling the respective setters at will, and
46088/// // execute the final call using `doit()`.
46089/// // Values shown here are possibly random and not representative !
46090/// let result = hub.event_tags().insert(req, -15)
46091///              .doit().await;
46092/// # }
46093/// ```
46094pub struct EventTagInsertCall<'a, C>
46095where
46096    C: 'a,
46097{
46098    hub: &'a Dfareporting<C>,
46099    _request: EventTag,
46100    _profile_id: i64,
46101    _delegate: Option<&'a mut dyn common::Delegate>,
46102    _additional_params: HashMap<String, String>,
46103    _scopes: BTreeSet<String>,
46104}
46105
46106impl<'a, C> common::CallBuilder for EventTagInsertCall<'a, C> {}
46107
46108impl<'a, C> EventTagInsertCall<'a, C>
46109where
46110    C: common::Connector,
46111{
46112    /// Perform the operation you have build so far.
46113    pub async fn doit(mut self) -> common::Result<(common::Response, EventTag)> {
46114        use std::borrow::Cow;
46115        use std::io::{Read, Seek};
46116
46117        use common::{url::Params, ToParts};
46118        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
46119
46120        let mut dd = common::DefaultDelegate;
46121        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
46122        dlg.begin(common::MethodInfo {
46123            id: "dfareporting.eventTags.insert",
46124            http_method: hyper::Method::POST,
46125        });
46126
46127        for &field in ["alt", "profileId"].iter() {
46128            if self._additional_params.contains_key(field) {
46129                dlg.finished(false);
46130                return Err(common::Error::FieldClash(field));
46131            }
46132        }
46133
46134        let mut params = Params::with_capacity(4 + self._additional_params.len());
46135        params.push("profileId", self._profile_id.to_string());
46136
46137        params.extend(self._additional_params.iter());
46138
46139        params.push("alt", "json");
46140        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags";
46141        if self._scopes.is_empty() {
46142            self._scopes
46143                .insert(Scope::Dfatrafficking.as_ref().to_string());
46144        }
46145
46146        #[allow(clippy::single_element_loop)]
46147        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
46148            url = params.uri_replacement(url, param_name, find_this, false);
46149        }
46150        {
46151            let to_remove = ["profileId"];
46152            params.remove_params(&to_remove);
46153        }
46154
46155        let url = params.parse_with_url(&url);
46156
46157        let mut json_mime_type = mime::APPLICATION_JSON;
46158        let mut request_value_reader = {
46159            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
46160            common::remove_json_null_values(&mut value);
46161            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
46162            serde_json::to_writer(&mut dst, &value).unwrap();
46163            dst
46164        };
46165        let request_size = request_value_reader
46166            .seek(std::io::SeekFrom::End(0))
46167            .unwrap();
46168        request_value_reader
46169            .seek(std::io::SeekFrom::Start(0))
46170            .unwrap();
46171
46172        loop {
46173            let token = match self
46174                .hub
46175                .auth
46176                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
46177                .await
46178            {
46179                Ok(token) => token,
46180                Err(e) => match dlg.token(e) {
46181                    Ok(token) => token,
46182                    Err(e) => {
46183                        dlg.finished(false);
46184                        return Err(common::Error::MissingToken(e));
46185                    }
46186                },
46187            };
46188            request_value_reader
46189                .seek(std::io::SeekFrom::Start(0))
46190                .unwrap();
46191            let mut req_result = {
46192                let client = &self.hub.client;
46193                dlg.pre_request();
46194                let mut req_builder = hyper::Request::builder()
46195                    .method(hyper::Method::POST)
46196                    .uri(url.as_str())
46197                    .header(USER_AGENT, self.hub._user_agent.clone());
46198
46199                if let Some(token) = token.as_ref() {
46200                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
46201                }
46202
46203                let request = req_builder
46204                    .header(CONTENT_TYPE, json_mime_type.to_string())
46205                    .header(CONTENT_LENGTH, request_size as u64)
46206                    .body(common::to_body(
46207                        request_value_reader.get_ref().clone().into(),
46208                    ));
46209
46210                client.request(request.unwrap()).await
46211            };
46212
46213            match req_result {
46214                Err(err) => {
46215                    if let common::Retry::After(d) = dlg.http_error(&err) {
46216                        sleep(d).await;
46217                        continue;
46218                    }
46219                    dlg.finished(false);
46220                    return Err(common::Error::HttpError(err));
46221                }
46222                Ok(res) => {
46223                    let (mut parts, body) = res.into_parts();
46224                    let mut body = common::Body::new(body);
46225                    if !parts.status.is_success() {
46226                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46227                        let error = serde_json::from_str(&common::to_string(&bytes));
46228                        let response = common::to_response(parts, bytes.into());
46229
46230                        if let common::Retry::After(d) =
46231                            dlg.http_failure(&response, error.as_ref().ok())
46232                        {
46233                            sleep(d).await;
46234                            continue;
46235                        }
46236
46237                        dlg.finished(false);
46238
46239                        return Err(match error {
46240                            Ok(value) => common::Error::BadRequest(value),
46241                            _ => common::Error::Failure(response),
46242                        });
46243                    }
46244                    let response = {
46245                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46246                        let encoded = common::to_string(&bytes);
46247                        match serde_json::from_str(&encoded) {
46248                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
46249                            Err(error) => {
46250                                dlg.response_json_decode_error(&encoded, &error);
46251                                return Err(common::Error::JsonDecodeError(
46252                                    encoded.to_string(),
46253                                    error,
46254                                ));
46255                            }
46256                        }
46257                    };
46258
46259                    dlg.finished(true);
46260                    return Ok(response);
46261                }
46262            }
46263        }
46264    }
46265
46266    ///
46267    /// Sets the *request* property to the given value.
46268    ///
46269    /// Even though the property as already been set when instantiating this call,
46270    /// we provide this method for API completeness.
46271    pub fn request(mut self, new_value: EventTag) -> EventTagInsertCall<'a, C> {
46272        self._request = new_value;
46273        self
46274    }
46275    /// User profile ID associated with this request.
46276    ///
46277    /// Sets the *profile id* path property to the given value.
46278    ///
46279    /// Even though the property as already been set when instantiating this call,
46280    /// we provide this method for API completeness.
46281    pub fn profile_id(mut self, new_value: i64) -> EventTagInsertCall<'a, C> {
46282        self._profile_id = new_value;
46283        self
46284    }
46285    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
46286    /// while executing the actual API request.
46287    ///
46288    /// ````text
46289    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
46290    /// ````
46291    ///
46292    /// Sets the *delegate* property to the given value.
46293    pub fn delegate(
46294        mut self,
46295        new_value: &'a mut dyn common::Delegate,
46296    ) -> EventTagInsertCall<'a, C> {
46297        self._delegate = Some(new_value);
46298        self
46299    }
46300
46301    /// Set any additional parameter of the query string used in the request.
46302    /// It should be used to set parameters which are not yet available through their own
46303    /// setters.
46304    ///
46305    /// Please note that this method must not be used to set any of the known parameters
46306    /// which have their own setter method. If done anyway, the request will fail.
46307    ///
46308    /// # Additional Parameters
46309    ///
46310    /// * *alt* (query-string) - Data format for the response.
46311    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
46312    /// * *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.
46313    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
46314    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
46315    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
46316    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
46317    pub fn param<T>(mut self, name: T, value: T) -> EventTagInsertCall<'a, C>
46318    where
46319        T: AsRef<str>,
46320    {
46321        self._additional_params
46322            .insert(name.as_ref().to_string(), value.as_ref().to_string());
46323        self
46324    }
46325
46326    /// Identifies the authorization scope for the method you are building.
46327    ///
46328    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
46329    /// [`Scope::Dfatrafficking`].
46330    ///
46331    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
46332    /// tokens for more than one scope.
46333    ///
46334    /// Usually there is more than one suitable scope to authorize an operation, some of which may
46335    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
46336    /// sufficient, a read-write scope will do as well.
46337    pub fn add_scope<St>(mut self, scope: St) -> EventTagInsertCall<'a, C>
46338    where
46339        St: AsRef<str>,
46340    {
46341        self._scopes.insert(String::from(scope.as_ref()));
46342        self
46343    }
46344    /// Identifies the authorization scope(s) for the method you are building.
46345    ///
46346    /// See [`Self::add_scope()`] for details.
46347    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagInsertCall<'a, C>
46348    where
46349        I: IntoIterator<Item = St>,
46350        St: AsRef<str>,
46351    {
46352        self._scopes
46353            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
46354        self
46355    }
46356
46357    /// Removes all scopes, and no default scope will be used either.
46358    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
46359    /// for details).
46360    pub fn clear_scopes(mut self) -> EventTagInsertCall<'a, C> {
46361        self._scopes.clear();
46362        self
46363    }
46364}
46365
46366/// Retrieves a list of event tags, possibly filtered.
46367///
46368/// A builder for the *list* method supported by a *eventTag* resource.
46369/// It is not used directly, but through a [`EventTagMethods`] instance.
46370///
46371/// # Example
46372///
46373/// Instantiate a resource method builder
46374///
46375/// ```test_harness,no_run
46376/// # extern crate hyper;
46377/// # extern crate hyper_rustls;
46378/// # extern crate google_dfareporting3d2 as dfareporting3d2;
46379/// # async fn dox() {
46380/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
46381///
46382/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
46383/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
46384/// #     secret,
46385/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
46386/// # ).build().await.unwrap();
46387///
46388/// # let client = hyper_util::client::legacy::Client::builder(
46389/// #     hyper_util::rt::TokioExecutor::new()
46390/// # )
46391/// # .build(
46392/// #     hyper_rustls::HttpsConnectorBuilder::new()
46393/// #         .with_native_roots()
46394/// #         .unwrap()
46395/// #         .https_or_http()
46396/// #         .enable_http1()
46397/// #         .build()
46398/// # );
46399/// # let mut hub = Dfareporting::new(client, auth);
46400/// // You can configure optional parameters by calling the respective setters at will, and
46401/// // execute the final call using `doit()`.
46402/// // Values shown here are possibly random and not representative !
46403/// let result = hub.event_tags().list(-70)
46404///              .sort_order("elitr")
46405///              .sort_field("aliquyam")
46406///              .search_string("erat")
46407///              .add_ids(-87)
46408///              .add_event_tag_types("et")
46409///              .enabled(true)
46410///              .definitions_only(true)
46411///              .campaign_id(-35)
46412///              .advertiser_id(-30)
46413///              .ad_id(-65)
46414///              .doit().await;
46415/// # }
46416/// ```
46417pub struct EventTagListCall<'a, C>
46418where
46419    C: 'a,
46420{
46421    hub: &'a Dfareporting<C>,
46422    _profile_id: i64,
46423    _sort_order: Option<String>,
46424    _sort_field: Option<String>,
46425    _search_string: Option<String>,
46426    _ids: Vec<i64>,
46427    _event_tag_types: Vec<String>,
46428    _enabled: Option<bool>,
46429    _definitions_only: Option<bool>,
46430    _campaign_id: Option<i64>,
46431    _advertiser_id: Option<i64>,
46432    _ad_id: Option<i64>,
46433    _delegate: Option<&'a mut dyn common::Delegate>,
46434    _additional_params: HashMap<String, String>,
46435    _scopes: BTreeSet<String>,
46436}
46437
46438impl<'a, C> common::CallBuilder for EventTagListCall<'a, C> {}
46439
46440impl<'a, C> EventTagListCall<'a, C>
46441where
46442    C: common::Connector,
46443{
46444    /// Perform the operation you have build so far.
46445    pub async fn doit(mut self) -> common::Result<(common::Response, EventTagsListResponse)> {
46446        use std::borrow::Cow;
46447        use std::io::{Read, Seek};
46448
46449        use common::{url::Params, ToParts};
46450        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
46451
46452        let mut dd = common::DefaultDelegate;
46453        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
46454        dlg.begin(common::MethodInfo {
46455            id: "dfareporting.eventTags.list",
46456            http_method: hyper::Method::GET,
46457        });
46458
46459        for &field in [
46460            "alt",
46461            "profileId",
46462            "sortOrder",
46463            "sortField",
46464            "searchString",
46465            "ids",
46466            "eventTagTypes",
46467            "enabled",
46468            "definitionsOnly",
46469            "campaignId",
46470            "advertiserId",
46471            "adId",
46472        ]
46473        .iter()
46474        {
46475            if self._additional_params.contains_key(field) {
46476                dlg.finished(false);
46477                return Err(common::Error::FieldClash(field));
46478            }
46479        }
46480
46481        let mut params = Params::with_capacity(13 + self._additional_params.len());
46482        params.push("profileId", self._profile_id.to_string());
46483        if let Some(value) = self._sort_order.as_ref() {
46484            params.push("sortOrder", value);
46485        }
46486        if let Some(value) = self._sort_field.as_ref() {
46487            params.push("sortField", value);
46488        }
46489        if let Some(value) = self._search_string.as_ref() {
46490            params.push("searchString", value);
46491        }
46492        if !self._ids.is_empty() {
46493            for f in self._ids.iter() {
46494                params.push("ids", f.to_string());
46495            }
46496        }
46497        if !self._event_tag_types.is_empty() {
46498            for f in self._event_tag_types.iter() {
46499                params.push("eventTagTypes", f);
46500            }
46501        }
46502        if let Some(value) = self._enabled.as_ref() {
46503            params.push("enabled", value.to_string());
46504        }
46505        if let Some(value) = self._definitions_only.as_ref() {
46506            params.push("definitionsOnly", value.to_string());
46507        }
46508        if let Some(value) = self._campaign_id.as_ref() {
46509            params.push("campaignId", value.to_string());
46510        }
46511        if let Some(value) = self._advertiser_id.as_ref() {
46512            params.push("advertiserId", value.to_string());
46513        }
46514        if let Some(value) = self._ad_id.as_ref() {
46515            params.push("adId", value.to_string());
46516        }
46517
46518        params.extend(self._additional_params.iter());
46519
46520        params.push("alt", "json");
46521        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags";
46522        if self._scopes.is_empty() {
46523            self._scopes
46524                .insert(Scope::Dfatrafficking.as_ref().to_string());
46525        }
46526
46527        #[allow(clippy::single_element_loop)]
46528        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
46529            url = params.uri_replacement(url, param_name, find_this, false);
46530        }
46531        {
46532            let to_remove = ["profileId"];
46533            params.remove_params(&to_remove);
46534        }
46535
46536        let url = params.parse_with_url(&url);
46537
46538        loop {
46539            let token = match self
46540                .hub
46541                .auth
46542                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
46543                .await
46544            {
46545                Ok(token) => token,
46546                Err(e) => match dlg.token(e) {
46547                    Ok(token) => token,
46548                    Err(e) => {
46549                        dlg.finished(false);
46550                        return Err(common::Error::MissingToken(e));
46551                    }
46552                },
46553            };
46554            let mut req_result = {
46555                let client = &self.hub.client;
46556                dlg.pre_request();
46557                let mut req_builder = hyper::Request::builder()
46558                    .method(hyper::Method::GET)
46559                    .uri(url.as_str())
46560                    .header(USER_AGENT, self.hub._user_agent.clone());
46561
46562                if let Some(token) = token.as_ref() {
46563                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
46564                }
46565
46566                let request = req_builder
46567                    .header(CONTENT_LENGTH, 0_u64)
46568                    .body(common::to_body::<String>(None));
46569
46570                client.request(request.unwrap()).await
46571            };
46572
46573            match req_result {
46574                Err(err) => {
46575                    if let common::Retry::After(d) = dlg.http_error(&err) {
46576                        sleep(d).await;
46577                        continue;
46578                    }
46579                    dlg.finished(false);
46580                    return Err(common::Error::HttpError(err));
46581                }
46582                Ok(res) => {
46583                    let (mut parts, body) = res.into_parts();
46584                    let mut body = common::Body::new(body);
46585                    if !parts.status.is_success() {
46586                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46587                        let error = serde_json::from_str(&common::to_string(&bytes));
46588                        let response = common::to_response(parts, bytes.into());
46589
46590                        if let common::Retry::After(d) =
46591                            dlg.http_failure(&response, error.as_ref().ok())
46592                        {
46593                            sleep(d).await;
46594                            continue;
46595                        }
46596
46597                        dlg.finished(false);
46598
46599                        return Err(match error {
46600                            Ok(value) => common::Error::BadRequest(value),
46601                            _ => common::Error::Failure(response),
46602                        });
46603                    }
46604                    let response = {
46605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46606                        let encoded = common::to_string(&bytes);
46607                        match serde_json::from_str(&encoded) {
46608                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
46609                            Err(error) => {
46610                                dlg.response_json_decode_error(&encoded, &error);
46611                                return Err(common::Error::JsonDecodeError(
46612                                    encoded.to_string(),
46613                                    error,
46614                                ));
46615                            }
46616                        }
46617                    };
46618
46619                    dlg.finished(true);
46620                    return Ok(response);
46621                }
46622            }
46623        }
46624    }
46625
46626    /// User profile ID associated with this request.
46627    ///
46628    /// Sets the *profile id* path property to the given value.
46629    ///
46630    /// Even though the property as already been set when instantiating this call,
46631    /// we provide this method for API completeness.
46632    pub fn profile_id(mut self, new_value: i64) -> EventTagListCall<'a, C> {
46633        self._profile_id = new_value;
46634        self
46635    }
46636    /// Order of sorted results.
46637    ///
46638    /// Sets the *sort order* query property to the given value.
46639    pub fn sort_order(mut self, new_value: &str) -> EventTagListCall<'a, C> {
46640        self._sort_order = Some(new_value.to_string());
46641        self
46642    }
46643    /// Field by which to sort the list.
46644    ///
46645    /// Sets the *sort field* query property to the given value.
46646    pub fn sort_field(mut self, new_value: &str) -> EventTagListCall<'a, C> {
46647        self._sort_field = Some(new_value.to_string());
46648        self
46649    }
46650    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "eventtag*2015" will return objects with names like "eventtag June 2015", "eventtag April 2015", or simply "eventtag 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "eventtag" will match objects with name "my eventtag", "eventtag 2015", or simply "eventtag".
46651    ///
46652    /// Sets the *search string* query property to the given value.
46653    pub fn search_string(mut self, new_value: &str) -> EventTagListCall<'a, C> {
46654        self._search_string = Some(new_value.to_string());
46655        self
46656    }
46657    /// Select only event tags with these IDs.
46658    ///
46659    /// Append the given value to the *ids* query property.
46660    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
46661    pub fn add_ids(mut self, new_value: i64) -> EventTagListCall<'a, C> {
46662        self._ids.push(new_value);
46663        self
46664    }
46665    /// Select only event tags with the specified event tag types. Event tag types can be used to specify whether to use a third-party pixel, a third-party JavaScript URL, or a third-party click-through URL for either impression or click tracking.
46666    ///
46667    /// Append the given value to the *event tag types* query property.
46668    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
46669    pub fn add_event_tag_types(mut self, new_value: &str) -> EventTagListCall<'a, C> {
46670        self._event_tag_types.push(new_value.to_string());
46671        self
46672    }
46673    /// Select only enabled event tags. What is considered enabled or disabled depends on the definitionsOnly parameter. When definitionsOnly is set to true, only the specified advertiser or campaign's event tags' enabledByDefault field is examined. When definitionsOnly is set to false, the specified ad or specified campaign's parent advertiser's or parent campaign's event tags' enabledByDefault and status fields are examined as well.
46674    ///
46675    /// Sets the *enabled* query property to the given value.
46676    pub fn enabled(mut self, new_value: bool) -> EventTagListCall<'a, C> {
46677        self._enabled = Some(new_value);
46678        self
46679    }
46680    /// Examine only the specified campaign or advertiser's event tags for matching selector criteria. When set to false, the parent advertiser and parent campaign of the specified ad or campaign is examined as well. In addition, when set to false, the status field is examined as well, along with the enabledByDefault field. This parameter can not be set to true when adId is specified as ads do not define their own even tags.
46681    ///
46682    /// Sets the *definitions only* query property to the given value.
46683    pub fn definitions_only(mut self, new_value: bool) -> EventTagListCall<'a, C> {
46684        self._definitions_only = Some(new_value);
46685        self
46686    }
46687    /// Select only event tags that belong to this campaign.
46688    ///
46689    /// Sets the *campaign id* query property to the given value.
46690    pub fn campaign_id(mut self, new_value: i64) -> EventTagListCall<'a, C> {
46691        self._campaign_id = Some(new_value);
46692        self
46693    }
46694    /// Select only event tags that belong to this advertiser.
46695    ///
46696    /// Sets the *advertiser id* query property to the given value.
46697    pub fn advertiser_id(mut self, new_value: i64) -> EventTagListCall<'a, C> {
46698        self._advertiser_id = Some(new_value);
46699        self
46700    }
46701    /// Select only event tags that belong to this ad.
46702    ///
46703    /// Sets the *ad id* query property to the given value.
46704    pub fn ad_id(mut self, new_value: i64) -> EventTagListCall<'a, C> {
46705        self._ad_id = Some(new_value);
46706        self
46707    }
46708    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
46709    /// while executing the actual API request.
46710    ///
46711    /// ````text
46712    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
46713    /// ````
46714    ///
46715    /// Sets the *delegate* property to the given value.
46716    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventTagListCall<'a, C> {
46717        self._delegate = Some(new_value);
46718        self
46719    }
46720
46721    /// Set any additional parameter of the query string used in the request.
46722    /// It should be used to set parameters which are not yet available through their own
46723    /// setters.
46724    ///
46725    /// Please note that this method must not be used to set any of the known parameters
46726    /// which have their own setter method. If done anyway, the request will fail.
46727    ///
46728    /// # Additional Parameters
46729    ///
46730    /// * *alt* (query-string) - Data format for the response.
46731    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
46732    /// * *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.
46733    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
46734    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
46735    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
46736    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
46737    pub fn param<T>(mut self, name: T, value: T) -> EventTagListCall<'a, C>
46738    where
46739        T: AsRef<str>,
46740    {
46741        self._additional_params
46742            .insert(name.as_ref().to_string(), value.as_ref().to_string());
46743        self
46744    }
46745
46746    /// Identifies the authorization scope for the method you are building.
46747    ///
46748    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
46749    /// [`Scope::Dfatrafficking`].
46750    ///
46751    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
46752    /// tokens for more than one scope.
46753    ///
46754    /// Usually there is more than one suitable scope to authorize an operation, some of which may
46755    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
46756    /// sufficient, a read-write scope will do as well.
46757    pub fn add_scope<St>(mut self, scope: St) -> EventTagListCall<'a, C>
46758    where
46759        St: AsRef<str>,
46760    {
46761        self._scopes.insert(String::from(scope.as_ref()));
46762        self
46763    }
46764    /// Identifies the authorization scope(s) for the method you are building.
46765    ///
46766    /// See [`Self::add_scope()`] for details.
46767    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagListCall<'a, C>
46768    where
46769        I: IntoIterator<Item = St>,
46770        St: AsRef<str>,
46771    {
46772        self._scopes
46773            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
46774        self
46775    }
46776
46777    /// Removes all scopes, and no default scope will be used either.
46778    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
46779    /// for details).
46780    pub fn clear_scopes(mut self) -> EventTagListCall<'a, C> {
46781        self._scopes.clear();
46782        self
46783    }
46784}
46785
46786/// Updates an existing event tag. This method supports patch semantics.
46787///
46788/// A builder for the *patch* method supported by a *eventTag* resource.
46789/// It is not used directly, but through a [`EventTagMethods`] instance.
46790///
46791/// # Example
46792///
46793/// Instantiate a resource method builder
46794///
46795/// ```test_harness,no_run
46796/// # extern crate hyper;
46797/// # extern crate hyper_rustls;
46798/// # extern crate google_dfareporting3d2 as dfareporting3d2;
46799/// use dfareporting3d2::api::EventTag;
46800/// # async fn dox() {
46801/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
46802///
46803/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
46804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
46805/// #     secret,
46806/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
46807/// # ).build().await.unwrap();
46808///
46809/// # let client = hyper_util::client::legacy::Client::builder(
46810/// #     hyper_util::rt::TokioExecutor::new()
46811/// # )
46812/// # .build(
46813/// #     hyper_rustls::HttpsConnectorBuilder::new()
46814/// #         .with_native_roots()
46815/// #         .unwrap()
46816/// #         .https_or_http()
46817/// #         .enable_http1()
46818/// #         .build()
46819/// # );
46820/// # let mut hub = Dfareporting::new(client, auth);
46821/// // As the method needs a request, you would usually fill it with the desired information
46822/// // into the respective structure. Some of the parts shown here might not be applicable !
46823/// // Values shown here are possibly random and not representative !
46824/// let mut req = EventTag::default();
46825///
46826/// // You can configure optional parameters by calling the respective setters at will, and
46827/// // execute the final call using `doit()`.
46828/// // Values shown here are possibly random and not representative !
46829/// let result = hub.event_tags().patch(req, -82, -13)
46830///              .doit().await;
46831/// # }
46832/// ```
46833pub struct EventTagPatchCall<'a, C>
46834where
46835    C: 'a,
46836{
46837    hub: &'a Dfareporting<C>,
46838    _request: EventTag,
46839    _profile_id: i64,
46840    _id: i64,
46841    _delegate: Option<&'a mut dyn common::Delegate>,
46842    _additional_params: HashMap<String, String>,
46843    _scopes: BTreeSet<String>,
46844}
46845
46846impl<'a, C> common::CallBuilder for EventTagPatchCall<'a, C> {}
46847
46848impl<'a, C> EventTagPatchCall<'a, C>
46849where
46850    C: common::Connector,
46851{
46852    /// Perform the operation you have build so far.
46853    pub async fn doit(mut self) -> common::Result<(common::Response, EventTag)> {
46854        use std::borrow::Cow;
46855        use std::io::{Read, Seek};
46856
46857        use common::{url::Params, ToParts};
46858        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
46859
46860        let mut dd = common::DefaultDelegate;
46861        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
46862        dlg.begin(common::MethodInfo {
46863            id: "dfareporting.eventTags.patch",
46864            http_method: hyper::Method::PATCH,
46865        });
46866
46867        for &field in ["alt", "profileId", "id"].iter() {
46868            if self._additional_params.contains_key(field) {
46869                dlg.finished(false);
46870                return Err(common::Error::FieldClash(field));
46871            }
46872        }
46873
46874        let mut params = Params::with_capacity(5 + self._additional_params.len());
46875        params.push("profileId", self._profile_id.to_string());
46876        params.push("id", self._id.to_string());
46877
46878        params.extend(self._additional_params.iter());
46879
46880        params.push("alt", "json");
46881        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags";
46882        if self._scopes.is_empty() {
46883            self._scopes
46884                .insert(Scope::Dfatrafficking.as_ref().to_string());
46885        }
46886
46887        #[allow(clippy::single_element_loop)]
46888        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
46889            url = params.uri_replacement(url, param_name, find_this, false);
46890        }
46891        {
46892            let to_remove = ["profileId"];
46893            params.remove_params(&to_remove);
46894        }
46895
46896        let url = params.parse_with_url(&url);
46897
46898        let mut json_mime_type = mime::APPLICATION_JSON;
46899        let mut request_value_reader = {
46900            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
46901            common::remove_json_null_values(&mut value);
46902            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
46903            serde_json::to_writer(&mut dst, &value).unwrap();
46904            dst
46905        };
46906        let request_size = request_value_reader
46907            .seek(std::io::SeekFrom::End(0))
46908            .unwrap();
46909        request_value_reader
46910            .seek(std::io::SeekFrom::Start(0))
46911            .unwrap();
46912
46913        loop {
46914            let token = match self
46915                .hub
46916                .auth
46917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
46918                .await
46919            {
46920                Ok(token) => token,
46921                Err(e) => match dlg.token(e) {
46922                    Ok(token) => token,
46923                    Err(e) => {
46924                        dlg.finished(false);
46925                        return Err(common::Error::MissingToken(e));
46926                    }
46927                },
46928            };
46929            request_value_reader
46930                .seek(std::io::SeekFrom::Start(0))
46931                .unwrap();
46932            let mut req_result = {
46933                let client = &self.hub.client;
46934                dlg.pre_request();
46935                let mut req_builder = hyper::Request::builder()
46936                    .method(hyper::Method::PATCH)
46937                    .uri(url.as_str())
46938                    .header(USER_AGENT, self.hub._user_agent.clone());
46939
46940                if let Some(token) = token.as_ref() {
46941                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
46942                }
46943
46944                let request = req_builder
46945                    .header(CONTENT_TYPE, json_mime_type.to_string())
46946                    .header(CONTENT_LENGTH, request_size as u64)
46947                    .body(common::to_body(
46948                        request_value_reader.get_ref().clone().into(),
46949                    ));
46950
46951                client.request(request.unwrap()).await
46952            };
46953
46954            match req_result {
46955                Err(err) => {
46956                    if let common::Retry::After(d) = dlg.http_error(&err) {
46957                        sleep(d).await;
46958                        continue;
46959                    }
46960                    dlg.finished(false);
46961                    return Err(common::Error::HttpError(err));
46962                }
46963                Ok(res) => {
46964                    let (mut parts, body) = res.into_parts();
46965                    let mut body = common::Body::new(body);
46966                    if !parts.status.is_success() {
46967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46968                        let error = serde_json::from_str(&common::to_string(&bytes));
46969                        let response = common::to_response(parts, bytes.into());
46970
46971                        if let common::Retry::After(d) =
46972                            dlg.http_failure(&response, error.as_ref().ok())
46973                        {
46974                            sleep(d).await;
46975                            continue;
46976                        }
46977
46978                        dlg.finished(false);
46979
46980                        return Err(match error {
46981                            Ok(value) => common::Error::BadRequest(value),
46982                            _ => common::Error::Failure(response),
46983                        });
46984                    }
46985                    let response = {
46986                        let bytes = common::to_bytes(body).await.unwrap_or_default();
46987                        let encoded = common::to_string(&bytes);
46988                        match serde_json::from_str(&encoded) {
46989                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
46990                            Err(error) => {
46991                                dlg.response_json_decode_error(&encoded, &error);
46992                                return Err(common::Error::JsonDecodeError(
46993                                    encoded.to_string(),
46994                                    error,
46995                                ));
46996                            }
46997                        }
46998                    };
46999
47000                    dlg.finished(true);
47001                    return Ok(response);
47002                }
47003            }
47004        }
47005    }
47006
47007    ///
47008    /// Sets the *request* property to the given value.
47009    ///
47010    /// Even though the property as already been set when instantiating this call,
47011    /// we provide this method for API completeness.
47012    pub fn request(mut self, new_value: EventTag) -> EventTagPatchCall<'a, C> {
47013        self._request = new_value;
47014        self
47015    }
47016    /// User profile ID associated with this request.
47017    ///
47018    /// Sets the *profile id* path property to the given value.
47019    ///
47020    /// Even though the property as already been set when instantiating this call,
47021    /// we provide this method for API completeness.
47022    pub fn profile_id(mut self, new_value: i64) -> EventTagPatchCall<'a, C> {
47023        self._profile_id = new_value;
47024        self
47025    }
47026    /// Event tag ID.
47027    ///
47028    /// Sets the *id* query property to the given value.
47029    ///
47030    /// Even though the property as already been set when instantiating this call,
47031    /// we provide this method for API completeness.
47032    pub fn id(mut self, new_value: i64) -> EventTagPatchCall<'a, C> {
47033        self._id = new_value;
47034        self
47035    }
47036    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
47037    /// while executing the actual API request.
47038    ///
47039    /// ````text
47040    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
47041    /// ````
47042    ///
47043    /// Sets the *delegate* property to the given value.
47044    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventTagPatchCall<'a, C> {
47045        self._delegate = Some(new_value);
47046        self
47047    }
47048
47049    /// Set any additional parameter of the query string used in the request.
47050    /// It should be used to set parameters which are not yet available through their own
47051    /// setters.
47052    ///
47053    /// Please note that this method must not be used to set any of the known parameters
47054    /// which have their own setter method. If done anyway, the request will fail.
47055    ///
47056    /// # Additional Parameters
47057    ///
47058    /// * *alt* (query-string) - Data format for the response.
47059    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
47060    /// * *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.
47061    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
47062    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
47063    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
47064    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
47065    pub fn param<T>(mut self, name: T, value: T) -> EventTagPatchCall<'a, C>
47066    where
47067        T: AsRef<str>,
47068    {
47069        self._additional_params
47070            .insert(name.as_ref().to_string(), value.as_ref().to_string());
47071        self
47072    }
47073
47074    /// Identifies the authorization scope for the method you are building.
47075    ///
47076    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
47077    /// [`Scope::Dfatrafficking`].
47078    ///
47079    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
47080    /// tokens for more than one scope.
47081    ///
47082    /// Usually there is more than one suitable scope to authorize an operation, some of which may
47083    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
47084    /// sufficient, a read-write scope will do as well.
47085    pub fn add_scope<St>(mut self, scope: St) -> EventTagPatchCall<'a, C>
47086    where
47087        St: AsRef<str>,
47088    {
47089        self._scopes.insert(String::from(scope.as_ref()));
47090        self
47091    }
47092    /// Identifies the authorization scope(s) for the method you are building.
47093    ///
47094    /// See [`Self::add_scope()`] for details.
47095    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagPatchCall<'a, C>
47096    where
47097        I: IntoIterator<Item = St>,
47098        St: AsRef<str>,
47099    {
47100        self._scopes
47101            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
47102        self
47103    }
47104
47105    /// Removes all scopes, and no default scope will be used either.
47106    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
47107    /// for details).
47108    pub fn clear_scopes(mut self) -> EventTagPatchCall<'a, C> {
47109        self._scopes.clear();
47110        self
47111    }
47112}
47113
47114/// Updates an existing event tag.
47115///
47116/// A builder for the *update* method supported by a *eventTag* resource.
47117/// It is not used directly, but through a [`EventTagMethods`] instance.
47118///
47119/// # Example
47120///
47121/// Instantiate a resource method builder
47122///
47123/// ```test_harness,no_run
47124/// # extern crate hyper;
47125/// # extern crate hyper_rustls;
47126/// # extern crate google_dfareporting3d2 as dfareporting3d2;
47127/// use dfareporting3d2::api::EventTag;
47128/// # async fn dox() {
47129/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
47130///
47131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
47132/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
47133/// #     secret,
47134/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
47135/// # ).build().await.unwrap();
47136///
47137/// # let client = hyper_util::client::legacy::Client::builder(
47138/// #     hyper_util::rt::TokioExecutor::new()
47139/// # )
47140/// # .build(
47141/// #     hyper_rustls::HttpsConnectorBuilder::new()
47142/// #         .with_native_roots()
47143/// #         .unwrap()
47144/// #         .https_or_http()
47145/// #         .enable_http1()
47146/// #         .build()
47147/// # );
47148/// # let mut hub = Dfareporting::new(client, auth);
47149/// // As the method needs a request, you would usually fill it with the desired information
47150/// // into the respective structure. Some of the parts shown here might not be applicable !
47151/// // Values shown here are possibly random and not representative !
47152/// let mut req = EventTag::default();
47153///
47154/// // You can configure optional parameters by calling the respective setters at will, and
47155/// // execute the final call using `doit()`.
47156/// // Values shown here are possibly random and not representative !
47157/// let result = hub.event_tags().update(req, -101)
47158///              .doit().await;
47159/// # }
47160/// ```
47161pub struct EventTagUpdateCall<'a, C>
47162where
47163    C: 'a,
47164{
47165    hub: &'a Dfareporting<C>,
47166    _request: EventTag,
47167    _profile_id: i64,
47168    _delegate: Option<&'a mut dyn common::Delegate>,
47169    _additional_params: HashMap<String, String>,
47170    _scopes: BTreeSet<String>,
47171}
47172
47173impl<'a, C> common::CallBuilder for EventTagUpdateCall<'a, C> {}
47174
47175impl<'a, C> EventTagUpdateCall<'a, C>
47176where
47177    C: common::Connector,
47178{
47179    /// Perform the operation you have build so far.
47180    pub async fn doit(mut self) -> common::Result<(common::Response, EventTag)> {
47181        use std::borrow::Cow;
47182        use std::io::{Read, Seek};
47183
47184        use common::{url::Params, ToParts};
47185        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
47186
47187        let mut dd = common::DefaultDelegate;
47188        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
47189        dlg.begin(common::MethodInfo {
47190            id: "dfareporting.eventTags.update",
47191            http_method: hyper::Method::PUT,
47192        });
47193
47194        for &field in ["alt", "profileId"].iter() {
47195            if self._additional_params.contains_key(field) {
47196                dlg.finished(false);
47197                return Err(common::Error::FieldClash(field));
47198            }
47199        }
47200
47201        let mut params = Params::with_capacity(4 + self._additional_params.len());
47202        params.push("profileId", self._profile_id.to_string());
47203
47204        params.extend(self._additional_params.iter());
47205
47206        params.push("alt", "json");
47207        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags";
47208        if self._scopes.is_empty() {
47209            self._scopes
47210                .insert(Scope::Dfatrafficking.as_ref().to_string());
47211        }
47212
47213        #[allow(clippy::single_element_loop)]
47214        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
47215            url = params.uri_replacement(url, param_name, find_this, false);
47216        }
47217        {
47218            let to_remove = ["profileId"];
47219            params.remove_params(&to_remove);
47220        }
47221
47222        let url = params.parse_with_url(&url);
47223
47224        let mut json_mime_type = mime::APPLICATION_JSON;
47225        let mut request_value_reader = {
47226            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
47227            common::remove_json_null_values(&mut value);
47228            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
47229            serde_json::to_writer(&mut dst, &value).unwrap();
47230            dst
47231        };
47232        let request_size = request_value_reader
47233            .seek(std::io::SeekFrom::End(0))
47234            .unwrap();
47235        request_value_reader
47236            .seek(std::io::SeekFrom::Start(0))
47237            .unwrap();
47238
47239        loop {
47240            let token = match self
47241                .hub
47242                .auth
47243                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
47244                .await
47245            {
47246                Ok(token) => token,
47247                Err(e) => match dlg.token(e) {
47248                    Ok(token) => token,
47249                    Err(e) => {
47250                        dlg.finished(false);
47251                        return Err(common::Error::MissingToken(e));
47252                    }
47253                },
47254            };
47255            request_value_reader
47256                .seek(std::io::SeekFrom::Start(0))
47257                .unwrap();
47258            let mut req_result = {
47259                let client = &self.hub.client;
47260                dlg.pre_request();
47261                let mut req_builder = hyper::Request::builder()
47262                    .method(hyper::Method::PUT)
47263                    .uri(url.as_str())
47264                    .header(USER_AGENT, self.hub._user_agent.clone());
47265
47266                if let Some(token) = token.as_ref() {
47267                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
47268                }
47269
47270                let request = req_builder
47271                    .header(CONTENT_TYPE, json_mime_type.to_string())
47272                    .header(CONTENT_LENGTH, request_size as u64)
47273                    .body(common::to_body(
47274                        request_value_reader.get_ref().clone().into(),
47275                    ));
47276
47277                client.request(request.unwrap()).await
47278            };
47279
47280            match req_result {
47281                Err(err) => {
47282                    if let common::Retry::After(d) = dlg.http_error(&err) {
47283                        sleep(d).await;
47284                        continue;
47285                    }
47286                    dlg.finished(false);
47287                    return Err(common::Error::HttpError(err));
47288                }
47289                Ok(res) => {
47290                    let (mut parts, body) = res.into_parts();
47291                    let mut body = common::Body::new(body);
47292                    if !parts.status.is_success() {
47293                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47294                        let error = serde_json::from_str(&common::to_string(&bytes));
47295                        let response = common::to_response(parts, bytes.into());
47296
47297                        if let common::Retry::After(d) =
47298                            dlg.http_failure(&response, error.as_ref().ok())
47299                        {
47300                            sleep(d).await;
47301                            continue;
47302                        }
47303
47304                        dlg.finished(false);
47305
47306                        return Err(match error {
47307                            Ok(value) => common::Error::BadRequest(value),
47308                            _ => common::Error::Failure(response),
47309                        });
47310                    }
47311                    let response = {
47312                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47313                        let encoded = common::to_string(&bytes);
47314                        match serde_json::from_str(&encoded) {
47315                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
47316                            Err(error) => {
47317                                dlg.response_json_decode_error(&encoded, &error);
47318                                return Err(common::Error::JsonDecodeError(
47319                                    encoded.to_string(),
47320                                    error,
47321                                ));
47322                            }
47323                        }
47324                    };
47325
47326                    dlg.finished(true);
47327                    return Ok(response);
47328                }
47329            }
47330        }
47331    }
47332
47333    ///
47334    /// Sets the *request* property to the given value.
47335    ///
47336    /// Even though the property as already been set when instantiating this call,
47337    /// we provide this method for API completeness.
47338    pub fn request(mut self, new_value: EventTag) -> EventTagUpdateCall<'a, C> {
47339        self._request = new_value;
47340        self
47341    }
47342    /// User profile ID associated with this request.
47343    ///
47344    /// Sets the *profile id* path property to the given value.
47345    ///
47346    /// Even though the property as already been set when instantiating this call,
47347    /// we provide this method for API completeness.
47348    pub fn profile_id(mut self, new_value: i64) -> EventTagUpdateCall<'a, C> {
47349        self._profile_id = new_value;
47350        self
47351    }
47352    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
47353    /// while executing the actual API request.
47354    ///
47355    /// ````text
47356    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
47357    /// ````
47358    ///
47359    /// Sets the *delegate* property to the given value.
47360    pub fn delegate(
47361        mut self,
47362        new_value: &'a mut dyn common::Delegate,
47363    ) -> EventTagUpdateCall<'a, C> {
47364        self._delegate = Some(new_value);
47365        self
47366    }
47367
47368    /// Set any additional parameter of the query string used in the request.
47369    /// It should be used to set parameters which are not yet available through their own
47370    /// setters.
47371    ///
47372    /// Please note that this method must not be used to set any of the known parameters
47373    /// which have their own setter method. If done anyway, the request will fail.
47374    ///
47375    /// # Additional Parameters
47376    ///
47377    /// * *alt* (query-string) - Data format for the response.
47378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
47379    /// * *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.
47380    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
47381    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
47382    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
47383    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
47384    pub fn param<T>(mut self, name: T, value: T) -> EventTagUpdateCall<'a, C>
47385    where
47386        T: AsRef<str>,
47387    {
47388        self._additional_params
47389            .insert(name.as_ref().to_string(), value.as_ref().to_string());
47390        self
47391    }
47392
47393    /// Identifies the authorization scope for the method you are building.
47394    ///
47395    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
47396    /// [`Scope::Dfatrafficking`].
47397    ///
47398    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
47399    /// tokens for more than one scope.
47400    ///
47401    /// Usually there is more than one suitable scope to authorize an operation, some of which may
47402    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
47403    /// sufficient, a read-write scope will do as well.
47404    pub fn add_scope<St>(mut self, scope: St) -> EventTagUpdateCall<'a, C>
47405    where
47406        St: AsRef<str>,
47407    {
47408        self._scopes.insert(String::from(scope.as_ref()));
47409        self
47410    }
47411    /// Identifies the authorization scope(s) for the method you are building.
47412    ///
47413    /// See [`Self::add_scope()`] for details.
47414    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventTagUpdateCall<'a, C>
47415    where
47416        I: IntoIterator<Item = St>,
47417        St: AsRef<str>,
47418    {
47419        self._scopes
47420            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
47421        self
47422    }
47423
47424    /// Removes all scopes, and no default scope will be used either.
47425    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
47426    /// for details).
47427    pub fn clear_scopes(mut self) -> EventTagUpdateCall<'a, C> {
47428        self._scopes.clear();
47429        self
47430    }
47431}
47432
47433/// Retrieves a report file by its report ID and file ID. This method supports media download.
47434///
47435/// This method supports **media download**. To enable it, adjust the builder like this:
47436/// `.param("alt", "media")`.
47437/// Please note that due to missing multi-part support on the server side, you will only receive the media,
47438/// but not the `File` structure that you would usually get. The latter will be a default value.
47439///
47440/// A builder for the *get* method supported by a *file* resource.
47441/// It is not used directly, but through a [`FileMethods`] instance.
47442///
47443/// # Example
47444///
47445/// Instantiate a resource method builder
47446///
47447/// ```test_harness,no_run
47448/// # extern crate hyper;
47449/// # extern crate hyper_rustls;
47450/// # extern crate google_dfareporting3d2 as dfareporting3d2;
47451/// # async fn dox() {
47452/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
47453///
47454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
47455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
47456/// #     secret,
47457/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
47458/// # ).build().await.unwrap();
47459///
47460/// # let client = hyper_util::client::legacy::Client::builder(
47461/// #     hyper_util::rt::TokioExecutor::new()
47462/// # )
47463/// # .build(
47464/// #     hyper_rustls::HttpsConnectorBuilder::new()
47465/// #         .with_native_roots()
47466/// #         .unwrap()
47467/// #         .https_or_http()
47468/// #         .enable_http1()
47469/// #         .build()
47470/// # );
47471/// # let mut hub = Dfareporting::new(client, auth);
47472/// // You can configure optional parameters by calling the respective setters at will, and
47473/// // execute the final call using `doit()`.
47474/// // Values shown here are possibly random and not representative !
47475/// let result = hub.files().get(-48, -63)
47476///              .doit().await;
47477/// # }
47478/// ```
47479pub struct FileGetCall<'a, C>
47480where
47481    C: 'a,
47482{
47483    hub: &'a Dfareporting<C>,
47484    _report_id: i64,
47485    _file_id: i64,
47486    _delegate: Option<&'a mut dyn common::Delegate>,
47487    _additional_params: HashMap<String, String>,
47488    _scopes: BTreeSet<String>,
47489}
47490
47491impl<'a, C> common::CallBuilder for FileGetCall<'a, C> {}
47492
47493impl<'a, C> FileGetCall<'a, C>
47494where
47495    C: common::Connector,
47496{
47497    /// Perform the operation you have build so far.
47498    pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
47499        use std::borrow::Cow;
47500        use std::io::{Read, Seek};
47501
47502        use common::{url::Params, ToParts};
47503        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
47504
47505        let mut dd = common::DefaultDelegate;
47506        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
47507        dlg.begin(common::MethodInfo {
47508            id: "dfareporting.files.get",
47509            http_method: hyper::Method::GET,
47510        });
47511
47512        for &field in ["reportId", "fileId"].iter() {
47513            if self._additional_params.contains_key(field) {
47514                dlg.finished(false);
47515                return Err(common::Error::FieldClash(field));
47516            }
47517        }
47518
47519        let mut params = Params::with_capacity(3 + self._additional_params.len());
47520        params.push("reportId", self._report_id.to_string());
47521        params.push("fileId", self._file_id.to_string());
47522
47523        params.extend(self._additional_params.iter());
47524
47525        let (alt_field_missing, enable_resource_parsing) = {
47526            if let Some(value) = params.get("alt") {
47527                (false, value == "json")
47528            } else {
47529                (true, true)
47530            }
47531        };
47532        if alt_field_missing {
47533            params.push("alt", "json");
47534        }
47535        let mut url = self.hub._base_url.clone() + "reports/{reportId}/files/{fileId}";
47536        if self._scopes.is_empty() {
47537            self._scopes.insert(Scope::Full.as_ref().to_string());
47538        }
47539
47540        #[allow(clippy::single_element_loop)]
47541        for &(find_this, param_name) in [("{reportId}", "reportId"), ("{fileId}", "fileId")].iter()
47542        {
47543            url = params.uri_replacement(url, param_name, find_this, false);
47544        }
47545        {
47546            let to_remove = ["fileId", "reportId"];
47547            params.remove_params(&to_remove);
47548        }
47549
47550        let url = params.parse_with_url(&url);
47551
47552        loop {
47553            let token = match self
47554                .hub
47555                .auth
47556                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
47557                .await
47558            {
47559                Ok(token) => token,
47560                Err(e) => match dlg.token(e) {
47561                    Ok(token) => token,
47562                    Err(e) => {
47563                        dlg.finished(false);
47564                        return Err(common::Error::MissingToken(e));
47565                    }
47566                },
47567            };
47568            let mut req_result = {
47569                let client = &self.hub.client;
47570                dlg.pre_request();
47571                let mut req_builder = hyper::Request::builder()
47572                    .method(hyper::Method::GET)
47573                    .uri(url.as_str())
47574                    .header(USER_AGENT, self.hub._user_agent.clone());
47575
47576                if let Some(token) = token.as_ref() {
47577                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
47578                }
47579
47580                let request = req_builder
47581                    .header(CONTENT_LENGTH, 0_u64)
47582                    .body(common::to_body::<String>(None));
47583
47584                client.request(request.unwrap()).await
47585            };
47586
47587            match req_result {
47588                Err(err) => {
47589                    if let common::Retry::After(d) = dlg.http_error(&err) {
47590                        sleep(d).await;
47591                        continue;
47592                    }
47593                    dlg.finished(false);
47594                    return Err(common::Error::HttpError(err));
47595                }
47596                Ok(res) => {
47597                    let (mut parts, body) = res.into_parts();
47598                    let mut body = common::Body::new(body);
47599                    if !parts.status.is_success() {
47600                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47601                        let error = serde_json::from_str(&common::to_string(&bytes));
47602                        let response = common::to_response(parts, bytes.into());
47603
47604                        if let common::Retry::After(d) =
47605                            dlg.http_failure(&response, error.as_ref().ok())
47606                        {
47607                            sleep(d).await;
47608                            continue;
47609                        }
47610
47611                        dlg.finished(false);
47612
47613                        return Err(match error {
47614                            Ok(value) => common::Error::BadRequest(value),
47615                            _ => common::Error::Failure(response),
47616                        });
47617                    }
47618                    let response = if enable_resource_parsing {
47619                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47620                        let encoded = common::to_string(&bytes);
47621                        match serde_json::from_str(&encoded) {
47622                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
47623                            Err(error) => {
47624                                dlg.response_json_decode_error(&encoded, &error);
47625                                return Err(common::Error::JsonDecodeError(
47626                                    encoded.to_string(),
47627                                    error,
47628                                ));
47629                            }
47630                        }
47631                    } else {
47632                        (
47633                            common::Response::from_parts(parts, body),
47634                            Default::default(),
47635                        )
47636                    };
47637
47638                    dlg.finished(true);
47639                    return Ok(response);
47640                }
47641            }
47642        }
47643    }
47644
47645    /// The ID of the report.
47646    ///
47647    /// Sets the *report id* path property to the given value.
47648    ///
47649    /// Even though the property as already been set when instantiating this call,
47650    /// we provide this method for API completeness.
47651    pub fn report_id(mut self, new_value: i64) -> FileGetCall<'a, C> {
47652        self._report_id = new_value;
47653        self
47654    }
47655    /// The ID of the report file.
47656    ///
47657    /// Sets the *file id* path property to the given value.
47658    ///
47659    /// Even though the property as already been set when instantiating this call,
47660    /// we provide this method for API completeness.
47661    pub fn file_id(mut self, new_value: i64) -> FileGetCall<'a, C> {
47662        self._file_id = new_value;
47663        self
47664    }
47665    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
47666    /// while executing the actual API request.
47667    ///
47668    /// ````text
47669    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
47670    /// ````
47671    ///
47672    /// Sets the *delegate* property to the given value.
47673    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileGetCall<'a, C> {
47674        self._delegate = Some(new_value);
47675        self
47676    }
47677
47678    /// Set any additional parameter of the query string used in the request.
47679    /// It should be used to set parameters which are not yet available through their own
47680    /// setters.
47681    ///
47682    /// Please note that this method must not be used to set any of the known parameters
47683    /// which have their own setter method. If done anyway, the request will fail.
47684    ///
47685    /// # Additional Parameters
47686    ///
47687    /// * *alt* (query-string) - Data format for the response.
47688    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
47689    /// * *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.
47690    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
47691    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
47692    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
47693    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
47694    pub fn param<T>(mut self, name: T, value: T) -> FileGetCall<'a, C>
47695    where
47696        T: AsRef<str>,
47697    {
47698        self._additional_params
47699            .insert(name.as_ref().to_string(), value.as_ref().to_string());
47700        self
47701    }
47702
47703    /// Identifies the authorization scope for the method you are building.
47704    ///
47705    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
47706    /// [`Scope::Full`].
47707    ///
47708    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
47709    /// tokens for more than one scope.
47710    ///
47711    /// Usually there is more than one suitable scope to authorize an operation, some of which may
47712    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
47713    /// sufficient, a read-write scope will do as well.
47714    pub fn add_scope<St>(mut self, scope: St) -> FileGetCall<'a, C>
47715    where
47716        St: AsRef<str>,
47717    {
47718        self._scopes.insert(String::from(scope.as_ref()));
47719        self
47720    }
47721    /// Identifies the authorization scope(s) for the method you are building.
47722    ///
47723    /// See [`Self::add_scope()`] for details.
47724    pub fn add_scopes<I, St>(mut self, scopes: I) -> FileGetCall<'a, C>
47725    where
47726        I: IntoIterator<Item = St>,
47727        St: AsRef<str>,
47728    {
47729        self._scopes
47730            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
47731        self
47732    }
47733
47734    /// Removes all scopes, and no default scope will be used either.
47735    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
47736    /// for details).
47737    pub fn clear_scopes(mut self) -> FileGetCall<'a, C> {
47738        self._scopes.clear();
47739        self
47740    }
47741}
47742
47743/// Lists files for a user profile.
47744///
47745/// A builder for the *list* method supported by a *file* resource.
47746/// It is not used directly, but through a [`FileMethods`] instance.
47747///
47748/// # Example
47749///
47750/// Instantiate a resource method builder
47751///
47752/// ```test_harness,no_run
47753/// # extern crate hyper;
47754/// # extern crate hyper_rustls;
47755/// # extern crate google_dfareporting3d2 as dfareporting3d2;
47756/// # async fn dox() {
47757/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
47758///
47759/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
47760/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
47761/// #     secret,
47762/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
47763/// # ).build().await.unwrap();
47764///
47765/// # let client = hyper_util::client::legacy::Client::builder(
47766/// #     hyper_util::rt::TokioExecutor::new()
47767/// # )
47768/// # .build(
47769/// #     hyper_rustls::HttpsConnectorBuilder::new()
47770/// #         .with_native_roots()
47771/// #         .unwrap()
47772/// #         .https_or_http()
47773/// #         .enable_http1()
47774/// #         .build()
47775/// # );
47776/// # let mut hub = Dfareporting::new(client, auth);
47777/// // You can configure optional parameters by calling the respective setters at will, and
47778/// // execute the final call using `doit()`.
47779/// // Values shown here are possibly random and not representative !
47780/// let result = hub.files().list(-39)
47781///              .sort_order("dolor")
47782///              .sort_field("amet")
47783///              .scope("sit")
47784///              .page_token("rebum.")
47785///              .max_results(-60)
47786///              .doit().await;
47787/// # }
47788/// ```
47789pub struct FileListCall<'a, C>
47790where
47791    C: 'a,
47792{
47793    hub: &'a Dfareporting<C>,
47794    _profile_id: i64,
47795    _sort_order: Option<String>,
47796    _sort_field: Option<String>,
47797    _scope: Option<String>,
47798    _page_token: Option<String>,
47799    _max_results: Option<i32>,
47800    _delegate: Option<&'a mut dyn common::Delegate>,
47801    _additional_params: HashMap<String, String>,
47802    _scopes: BTreeSet<String>,
47803}
47804
47805impl<'a, C> common::CallBuilder for FileListCall<'a, C> {}
47806
47807impl<'a, C> FileListCall<'a, C>
47808where
47809    C: common::Connector,
47810{
47811    /// Perform the operation you have build so far.
47812    pub async fn doit(mut self) -> common::Result<(common::Response, FileList)> {
47813        use std::borrow::Cow;
47814        use std::io::{Read, Seek};
47815
47816        use common::{url::Params, ToParts};
47817        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
47818
47819        let mut dd = common::DefaultDelegate;
47820        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
47821        dlg.begin(common::MethodInfo {
47822            id: "dfareporting.files.list",
47823            http_method: hyper::Method::GET,
47824        });
47825
47826        for &field in [
47827            "alt",
47828            "profileId",
47829            "sortOrder",
47830            "sortField",
47831            "scope",
47832            "pageToken",
47833            "maxResults",
47834        ]
47835        .iter()
47836        {
47837            if self._additional_params.contains_key(field) {
47838                dlg.finished(false);
47839                return Err(common::Error::FieldClash(field));
47840            }
47841        }
47842
47843        let mut params = Params::with_capacity(8 + self._additional_params.len());
47844        params.push("profileId", self._profile_id.to_string());
47845        if let Some(value) = self._sort_order.as_ref() {
47846            params.push("sortOrder", value);
47847        }
47848        if let Some(value) = self._sort_field.as_ref() {
47849            params.push("sortField", value);
47850        }
47851        if let Some(value) = self._scope.as_ref() {
47852            params.push("scope", value);
47853        }
47854        if let Some(value) = self._page_token.as_ref() {
47855            params.push("pageToken", value);
47856        }
47857        if let Some(value) = self._max_results.as_ref() {
47858            params.push("maxResults", value.to_string());
47859        }
47860
47861        params.extend(self._additional_params.iter());
47862
47863        params.push("alt", "json");
47864        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/files";
47865        if self._scopes.is_empty() {
47866            self._scopes.insert(Scope::Full.as_ref().to_string());
47867        }
47868
47869        #[allow(clippy::single_element_loop)]
47870        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
47871            url = params.uri_replacement(url, param_name, find_this, false);
47872        }
47873        {
47874            let to_remove = ["profileId"];
47875            params.remove_params(&to_remove);
47876        }
47877
47878        let url = params.parse_with_url(&url);
47879
47880        loop {
47881            let token = match self
47882                .hub
47883                .auth
47884                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
47885                .await
47886            {
47887                Ok(token) => token,
47888                Err(e) => match dlg.token(e) {
47889                    Ok(token) => token,
47890                    Err(e) => {
47891                        dlg.finished(false);
47892                        return Err(common::Error::MissingToken(e));
47893                    }
47894                },
47895            };
47896            let mut req_result = {
47897                let client = &self.hub.client;
47898                dlg.pre_request();
47899                let mut req_builder = hyper::Request::builder()
47900                    .method(hyper::Method::GET)
47901                    .uri(url.as_str())
47902                    .header(USER_AGENT, self.hub._user_agent.clone());
47903
47904                if let Some(token) = token.as_ref() {
47905                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
47906                }
47907
47908                let request = req_builder
47909                    .header(CONTENT_LENGTH, 0_u64)
47910                    .body(common::to_body::<String>(None));
47911
47912                client.request(request.unwrap()).await
47913            };
47914
47915            match req_result {
47916                Err(err) => {
47917                    if let common::Retry::After(d) = dlg.http_error(&err) {
47918                        sleep(d).await;
47919                        continue;
47920                    }
47921                    dlg.finished(false);
47922                    return Err(common::Error::HttpError(err));
47923                }
47924                Ok(res) => {
47925                    let (mut parts, body) = res.into_parts();
47926                    let mut body = common::Body::new(body);
47927                    if !parts.status.is_success() {
47928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47929                        let error = serde_json::from_str(&common::to_string(&bytes));
47930                        let response = common::to_response(parts, bytes.into());
47931
47932                        if let common::Retry::After(d) =
47933                            dlg.http_failure(&response, error.as_ref().ok())
47934                        {
47935                            sleep(d).await;
47936                            continue;
47937                        }
47938
47939                        dlg.finished(false);
47940
47941                        return Err(match error {
47942                            Ok(value) => common::Error::BadRequest(value),
47943                            _ => common::Error::Failure(response),
47944                        });
47945                    }
47946                    let response = {
47947                        let bytes = common::to_bytes(body).await.unwrap_or_default();
47948                        let encoded = common::to_string(&bytes);
47949                        match serde_json::from_str(&encoded) {
47950                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
47951                            Err(error) => {
47952                                dlg.response_json_decode_error(&encoded, &error);
47953                                return Err(common::Error::JsonDecodeError(
47954                                    encoded.to_string(),
47955                                    error,
47956                                ));
47957                            }
47958                        }
47959                    };
47960
47961                    dlg.finished(true);
47962                    return Ok(response);
47963                }
47964            }
47965        }
47966    }
47967
47968    /// The DFA profile ID.
47969    ///
47970    /// Sets the *profile id* path property to the given value.
47971    ///
47972    /// Even though the property as already been set when instantiating this call,
47973    /// we provide this method for API completeness.
47974    pub fn profile_id(mut self, new_value: i64) -> FileListCall<'a, C> {
47975        self._profile_id = new_value;
47976        self
47977    }
47978    /// Order of sorted results.
47979    ///
47980    /// Sets the *sort order* query property to the given value.
47981    pub fn sort_order(mut self, new_value: &str) -> FileListCall<'a, C> {
47982        self._sort_order = Some(new_value.to_string());
47983        self
47984    }
47985    /// The field by which to sort the list.
47986    ///
47987    /// Sets the *sort field* query property to the given value.
47988    pub fn sort_field(mut self, new_value: &str) -> FileListCall<'a, C> {
47989        self._sort_field = Some(new_value.to_string());
47990        self
47991    }
47992    /// The scope that defines which results are returned.
47993    ///
47994    /// Sets the *scope* query property to the given value.
47995    pub fn scope(mut self, new_value: &str) -> FileListCall<'a, C> {
47996        self._scope = Some(new_value.to_string());
47997        self
47998    }
47999    /// The value of the nextToken from the previous result page.
48000    ///
48001    /// Sets the *page token* query property to the given value.
48002    pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, C> {
48003        self._page_token = Some(new_value.to_string());
48004        self
48005    }
48006    /// Maximum number of results to return.
48007    ///
48008    /// Sets the *max results* query property to the given value.
48009    pub fn max_results(mut self, new_value: i32) -> FileListCall<'a, C> {
48010        self._max_results = Some(new_value);
48011        self
48012    }
48013    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
48014    /// while executing the actual API request.
48015    ///
48016    /// ````text
48017    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
48018    /// ````
48019    ///
48020    /// Sets the *delegate* property to the given value.
48021    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileListCall<'a, C> {
48022        self._delegate = Some(new_value);
48023        self
48024    }
48025
48026    /// Set any additional parameter of the query string used in the request.
48027    /// It should be used to set parameters which are not yet available through their own
48028    /// setters.
48029    ///
48030    /// Please note that this method must not be used to set any of the known parameters
48031    /// which have their own setter method. If done anyway, the request will fail.
48032    ///
48033    /// # Additional Parameters
48034    ///
48035    /// * *alt* (query-string) - Data format for the response.
48036    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
48037    /// * *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.
48038    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
48039    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
48040    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
48041    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
48042    pub fn param<T>(mut self, name: T, value: T) -> FileListCall<'a, C>
48043    where
48044        T: AsRef<str>,
48045    {
48046        self._additional_params
48047            .insert(name.as_ref().to_string(), value.as_ref().to_string());
48048        self
48049    }
48050
48051    /// Identifies the authorization scope for the method you are building.
48052    ///
48053    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
48054    /// [`Scope::Full`].
48055    ///
48056    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
48057    /// tokens for more than one scope.
48058    ///
48059    /// Usually there is more than one suitable scope to authorize an operation, some of which may
48060    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
48061    /// sufficient, a read-write scope will do as well.
48062    pub fn add_scope<St>(mut self, scope: St) -> FileListCall<'a, C>
48063    where
48064        St: AsRef<str>,
48065    {
48066        self._scopes.insert(String::from(scope.as_ref()));
48067        self
48068    }
48069    /// Identifies the authorization scope(s) for the method you are building.
48070    ///
48071    /// See [`Self::add_scope()`] for details.
48072    pub fn add_scopes<I, St>(mut self, scopes: I) -> FileListCall<'a, C>
48073    where
48074        I: IntoIterator<Item = St>,
48075        St: AsRef<str>,
48076    {
48077        self._scopes
48078            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
48079        self
48080    }
48081
48082    /// Removes all scopes, and no default scope will be used either.
48083    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
48084    /// for details).
48085    pub fn clear_scopes(mut self) -> FileListCall<'a, C> {
48086        self._scopes.clear();
48087        self
48088    }
48089}
48090
48091/// Deletes an existing floodlight activity.
48092///
48093/// A builder for the *delete* method supported by a *floodlightActivity* resource.
48094/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
48095///
48096/// # Example
48097///
48098/// Instantiate a resource method builder
48099///
48100/// ```test_harness,no_run
48101/// # extern crate hyper;
48102/// # extern crate hyper_rustls;
48103/// # extern crate google_dfareporting3d2 as dfareporting3d2;
48104/// # async fn dox() {
48105/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
48106///
48107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
48108/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
48109/// #     secret,
48110/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48111/// # ).build().await.unwrap();
48112///
48113/// # let client = hyper_util::client::legacy::Client::builder(
48114/// #     hyper_util::rt::TokioExecutor::new()
48115/// # )
48116/// # .build(
48117/// #     hyper_rustls::HttpsConnectorBuilder::new()
48118/// #         .with_native_roots()
48119/// #         .unwrap()
48120/// #         .https_or_http()
48121/// #         .enable_http1()
48122/// #         .build()
48123/// # );
48124/// # let mut hub = Dfareporting::new(client, auth);
48125/// // You can configure optional parameters by calling the respective setters at will, and
48126/// // execute the final call using `doit()`.
48127/// // Values shown here are possibly random and not representative !
48128/// let result = hub.floodlight_activities().delete(-100, -5)
48129///              .doit().await;
48130/// # }
48131/// ```
48132pub struct FloodlightActivityDeleteCall<'a, C>
48133where
48134    C: 'a,
48135{
48136    hub: &'a Dfareporting<C>,
48137    _profile_id: i64,
48138    _id: i64,
48139    _delegate: Option<&'a mut dyn common::Delegate>,
48140    _additional_params: HashMap<String, String>,
48141    _scopes: BTreeSet<String>,
48142}
48143
48144impl<'a, C> common::CallBuilder for FloodlightActivityDeleteCall<'a, C> {}
48145
48146impl<'a, C> FloodlightActivityDeleteCall<'a, C>
48147where
48148    C: common::Connector,
48149{
48150    /// Perform the operation you have build so far.
48151    pub async fn doit(mut self) -> common::Result<common::Response> {
48152        use std::borrow::Cow;
48153        use std::io::{Read, Seek};
48154
48155        use common::{url::Params, ToParts};
48156        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
48157
48158        let mut dd = common::DefaultDelegate;
48159        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
48160        dlg.begin(common::MethodInfo {
48161            id: "dfareporting.floodlightActivities.delete",
48162            http_method: hyper::Method::DELETE,
48163        });
48164
48165        for &field in ["profileId", "id"].iter() {
48166            if self._additional_params.contains_key(field) {
48167                dlg.finished(false);
48168                return Err(common::Error::FieldClash(field));
48169            }
48170        }
48171
48172        let mut params = Params::with_capacity(3 + self._additional_params.len());
48173        params.push("profileId", self._profile_id.to_string());
48174        params.push("id", self._id.to_string());
48175
48176        params.extend(self._additional_params.iter());
48177
48178        let mut url =
48179            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities/{id}";
48180        if self._scopes.is_empty() {
48181            self._scopes
48182                .insert(Scope::Dfatrafficking.as_ref().to_string());
48183        }
48184
48185        #[allow(clippy::single_element_loop)]
48186        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
48187            url = params.uri_replacement(url, param_name, find_this, false);
48188        }
48189        {
48190            let to_remove = ["id", "profileId"];
48191            params.remove_params(&to_remove);
48192        }
48193
48194        let url = params.parse_with_url(&url);
48195
48196        loop {
48197            let token = match self
48198                .hub
48199                .auth
48200                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
48201                .await
48202            {
48203                Ok(token) => token,
48204                Err(e) => match dlg.token(e) {
48205                    Ok(token) => token,
48206                    Err(e) => {
48207                        dlg.finished(false);
48208                        return Err(common::Error::MissingToken(e));
48209                    }
48210                },
48211            };
48212            let mut req_result = {
48213                let client = &self.hub.client;
48214                dlg.pre_request();
48215                let mut req_builder = hyper::Request::builder()
48216                    .method(hyper::Method::DELETE)
48217                    .uri(url.as_str())
48218                    .header(USER_AGENT, self.hub._user_agent.clone());
48219
48220                if let Some(token) = token.as_ref() {
48221                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
48222                }
48223
48224                let request = req_builder
48225                    .header(CONTENT_LENGTH, 0_u64)
48226                    .body(common::to_body::<String>(None));
48227
48228                client.request(request.unwrap()).await
48229            };
48230
48231            match req_result {
48232                Err(err) => {
48233                    if let common::Retry::After(d) = dlg.http_error(&err) {
48234                        sleep(d).await;
48235                        continue;
48236                    }
48237                    dlg.finished(false);
48238                    return Err(common::Error::HttpError(err));
48239                }
48240                Ok(res) => {
48241                    let (mut parts, body) = res.into_parts();
48242                    let mut body = common::Body::new(body);
48243                    if !parts.status.is_success() {
48244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
48245                        let error = serde_json::from_str(&common::to_string(&bytes));
48246                        let response = common::to_response(parts, bytes.into());
48247
48248                        if let common::Retry::After(d) =
48249                            dlg.http_failure(&response, error.as_ref().ok())
48250                        {
48251                            sleep(d).await;
48252                            continue;
48253                        }
48254
48255                        dlg.finished(false);
48256
48257                        return Err(match error {
48258                            Ok(value) => common::Error::BadRequest(value),
48259                            _ => common::Error::Failure(response),
48260                        });
48261                    }
48262                    let response = common::Response::from_parts(parts, body);
48263
48264                    dlg.finished(true);
48265                    return Ok(response);
48266                }
48267            }
48268        }
48269    }
48270
48271    /// User profile ID associated with this request.
48272    ///
48273    /// Sets the *profile id* path property to the given value.
48274    ///
48275    /// Even though the property as already been set when instantiating this call,
48276    /// we provide this method for API completeness.
48277    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityDeleteCall<'a, C> {
48278        self._profile_id = new_value;
48279        self
48280    }
48281    /// Floodlight activity ID.
48282    ///
48283    /// Sets the *id* path property to the given value.
48284    ///
48285    /// Even though the property as already been set when instantiating this call,
48286    /// we provide this method for API completeness.
48287    pub fn id(mut self, new_value: i64) -> FloodlightActivityDeleteCall<'a, C> {
48288        self._id = new_value;
48289        self
48290    }
48291    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
48292    /// while executing the actual API request.
48293    ///
48294    /// ````text
48295    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
48296    /// ````
48297    ///
48298    /// Sets the *delegate* property to the given value.
48299    pub fn delegate(
48300        mut self,
48301        new_value: &'a mut dyn common::Delegate,
48302    ) -> FloodlightActivityDeleteCall<'a, C> {
48303        self._delegate = Some(new_value);
48304        self
48305    }
48306
48307    /// Set any additional parameter of the query string used in the request.
48308    /// It should be used to set parameters which are not yet available through their own
48309    /// setters.
48310    ///
48311    /// Please note that this method must not be used to set any of the known parameters
48312    /// which have their own setter method. If done anyway, the request will fail.
48313    ///
48314    /// # Additional Parameters
48315    ///
48316    /// * *alt* (query-string) - Data format for the response.
48317    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
48318    /// * *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.
48319    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
48320    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
48321    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
48322    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
48323    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityDeleteCall<'a, C>
48324    where
48325        T: AsRef<str>,
48326    {
48327        self._additional_params
48328            .insert(name.as_ref().to_string(), value.as_ref().to_string());
48329        self
48330    }
48331
48332    /// Identifies the authorization scope for the method you are building.
48333    ///
48334    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
48335    /// [`Scope::Dfatrafficking`].
48336    ///
48337    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
48338    /// tokens for more than one scope.
48339    ///
48340    /// Usually there is more than one suitable scope to authorize an operation, some of which may
48341    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
48342    /// sufficient, a read-write scope will do as well.
48343    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityDeleteCall<'a, C>
48344    where
48345        St: AsRef<str>,
48346    {
48347        self._scopes.insert(String::from(scope.as_ref()));
48348        self
48349    }
48350    /// Identifies the authorization scope(s) for the method you are building.
48351    ///
48352    /// See [`Self::add_scope()`] for details.
48353    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityDeleteCall<'a, C>
48354    where
48355        I: IntoIterator<Item = St>,
48356        St: AsRef<str>,
48357    {
48358        self._scopes
48359            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
48360        self
48361    }
48362
48363    /// Removes all scopes, and no default scope will be used either.
48364    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
48365    /// for details).
48366    pub fn clear_scopes(mut self) -> FloodlightActivityDeleteCall<'a, C> {
48367        self._scopes.clear();
48368        self
48369    }
48370}
48371
48372/// Generates a tag for a floodlight activity.
48373///
48374/// A builder for the *generatetag* method supported by a *floodlightActivity* resource.
48375/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
48376///
48377/// # Example
48378///
48379/// Instantiate a resource method builder
48380///
48381/// ```test_harness,no_run
48382/// # extern crate hyper;
48383/// # extern crate hyper_rustls;
48384/// # extern crate google_dfareporting3d2 as dfareporting3d2;
48385/// # async fn dox() {
48386/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
48387///
48388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
48389/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
48390/// #     secret,
48391/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48392/// # ).build().await.unwrap();
48393///
48394/// # let client = hyper_util::client::legacy::Client::builder(
48395/// #     hyper_util::rt::TokioExecutor::new()
48396/// # )
48397/// # .build(
48398/// #     hyper_rustls::HttpsConnectorBuilder::new()
48399/// #         .with_native_roots()
48400/// #         .unwrap()
48401/// #         .https_or_http()
48402/// #         .enable_http1()
48403/// #         .build()
48404/// # );
48405/// # let mut hub = Dfareporting::new(client, auth);
48406/// // You can configure optional parameters by calling the respective setters at will, and
48407/// // execute the final call using `doit()`.
48408/// // Values shown here are possibly random and not representative !
48409/// let result = hub.floodlight_activities().generatetag(-24)
48410///              .floodlight_activity_id(-94)
48411///              .doit().await;
48412/// # }
48413/// ```
48414pub struct FloodlightActivityGeneratetagCall<'a, C>
48415where
48416    C: 'a,
48417{
48418    hub: &'a Dfareporting<C>,
48419    _profile_id: i64,
48420    _floodlight_activity_id: Option<i64>,
48421    _delegate: Option<&'a mut dyn common::Delegate>,
48422    _additional_params: HashMap<String, String>,
48423    _scopes: BTreeSet<String>,
48424}
48425
48426impl<'a, C> common::CallBuilder for FloodlightActivityGeneratetagCall<'a, C> {}
48427
48428impl<'a, C> FloodlightActivityGeneratetagCall<'a, C>
48429where
48430    C: common::Connector,
48431{
48432    /// Perform the operation you have build so far.
48433    pub async fn doit(
48434        mut self,
48435    ) -> common::Result<(common::Response, FloodlightActivitiesGenerateTagResponse)> {
48436        use std::borrow::Cow;
48437        use std::io::{Read, Seek};
48438
48439        use common::{url::Params, ToParts};
48440        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
48441
48442        let mut dd = common::DefaultDelegate;
48443        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
48444        dlg.begin(common::MethodInfo {
48445            id: "dfareporting.floodlightActivities.generatetag",
48446            http_method: hyper::Method::POST,
48447        });
48448
48449        for &field in ["alt", "profileId", "floodlightActivityId"].iter() {
48450            if self._additional_params.contains_key(field) {
48451                dlg.finished(false);
48452                return Err(common::Error::FieldClash(field));
48453            }
48454        }
48455
48456        let mut params = Params::with_capacity(4 + self._additional_params.len());
48457        params.push("profileId", self._profile_id.to_string());
48458        if let Some(value) = self._floodlight_activity_id.as_ref() {
48459            params.push("floodlightActivityId", value.to_string());
48460        }
48461
48462        params.extend(self._additional_params.iter());
48463
48464        params.push("alt", "json");
48465        let mut url = self.hub._base_url.clone()
48466            + "userprofiles/{profileId}/floodlightActivities/generatetag";
48467        if self._scopes.is_empty() {
48468            self._scopes
48469                .insert(Scope::Dfatrafficking.as_ref().to_string());
48470        }
48471
48472        #[allow(clippy::single_element_loop)]
48473        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
48474            url = params.uri_replacement(url, param_name, find_this, false);
48475        }
48476        {
48477            let to_remove = ["profileId"];
48478            params.remove_params(&to_remove);
48479        }
48480
48481        let url = params.parse_with_url(&url);
48482
48483        loop {
48484            let token = match self
48485                .hub
48486                .auth
48487                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
48488                .await
48489            {
48490                Ok(token) => token,
48491                Err(e) => match dlg.token(e) {
48492                    Ok(token) => token,
48493                    Err(e) => {
48494                        dlg.finished(false);
48495                        return Err(common::Error::MissingToken(e));
48496                    }
48497                },
48498            };
48499            let mut req_result = {
48500                let client = &self.hub.client;
48501                dlg.pre_request();
48502                let mut req_builder = hyper::Request::builder()
48503                    .method(hyper::Method::POST)
48504                    .uri(url.as_str())
48505                    .header(USER_AGENT, self.hub._user_agent.clone());
48506
48507                if let Some(token) = token.as_ref() {
48508                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
48509                }
48510
48511                let request = req_builder
48512                    .header(CONTENT_LENGTH, 0_u64)
48513                    .body(common::to_body::<String>(None));
48514
48515                client.request(request.unwrap()).await
48516            };
48517
48518            match req_result {
48519                Err(err) => {
48520                    if let common::Retry::After(d) = dlg.http_error(&err) {
48521                        sleep(d).await;
48522                        continue;
48523                    }
48524                    dlg.finished(false);
48525                    return Err(common::Error::HttpError(err));
48526                }
48527                Ok(res) => {
48528                    let (mut parts, body) = res.into_parts();
48529                    let mut body = common::Body::new(body);
48530                    if !parts.status.is_success() {
48531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
48532                        let error = serde_json::from_str(&common::to_string(&bytes));
48533                        let response = common::to_response(parts, bytes.into());
48534
48535                        if let common::Retry::After(d) =
48536                            dlg.http_failure(&response, error.as_ref().ok())
48537                        {
48538                            sleep(d).await;
48539                            continue;
48540                        }
48541
48542                        dlg.finished(false);
48543
48544                        return Err(match error {
48545                            Ok(value) => common::Error::BadRequest(value),
48546                            _ => common::Error::Failure(response),
48547                        });
48548                    }
48549                    let response = {
48550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
48551                        let encoded = common::to_string(&bytes);
48552                        match serde_json::from_str(&encoded) {
48553                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
48554                            Err(error) => {
48555                                dlg.response_json_decode_error(&encoded, &error);
48556                                return Err(common::Error::JsonDecodeError(
48557                                    encoded.to_string(),
48558                                    error,
48559                                ));
48560                            }
48561                        }
48562                    };
48563
48564                    dlg.finished(true);
48565                    return Ok(response);
48566                }
48567            }
48568        }
48569    }
48570
48571    /// User profile ID associated with this request.
48572    ///
48573    /// Sets the *profile id* path property to the given value.
48574    ///
48575    /// Even though the property as already been set when instantiating this call,
48576    /// we provide this method for API completeness.
48577    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGeneratetagCall<'a, C> {
48578        self._profile_id = new_value;
48579        self
48580    }
48581    /// Floodlight activity ID for which we want to generate a tag.
48582    ///
48583    /// Sets the *floodlight activity id* query property to the given value.
48584    pub fn floodlight_activity_id(
48585        mut self,
48586        new_value: i64,
48587    ) -> FloodlightActivityGeneratetagCall<'a, C> {
48588        self._floodlight_activity_id = Some(new_value);
48589        self
48590    }
48591    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
48592    /// while executing the actual API request.
48593    ///
48594    /// ````text
48595    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
48596    /// ````
48597    ///
48598    /// Sets the *delegate* property to the given value.
48599    pub fn delegate(
48600        mut self,
48601        new_value: &'a mut dyn common::Delegate,
48602    ) -> FloodlightActivityGeneratetagCall<'a, C> {
48603        self._delegate = Some(new_value);
48604        self
48605    }
48606
48607    /// Set any additional parameter of the query string used in the request.
48608    /// It should be used to set parameters which are not yet available through their own
48609    /// setters.
48610    ///
48611    /// Please note that this method must not be used to set any of the known parameters
48612    /// which have their own setter method. If done anyway, the request will fail.
48613    ///
48614    /// # Additional Parameters
48615    ///
48616    /// * *alt* (query-string) - Data format for the response.
48617    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
48618    /// * *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.
48619    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
48620    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
48621    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
48622    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
48623    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGeneratetagCall<'a, C>
48624    where
48625        T: AsRef<str>,
48626    {
48627        self._additional_params
48628            .insert(name.as_ref().to_string(), value.as_ref().to_string());
48629        self
48630    }
48631
48632    /// Identifies the authorization scope for the method you are building.
48633    ///
48634    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
48635    /// [`Scope::Dfatrafficking`].
48636    ///
48637    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
48638    /// tokens for more than one scope.
48639    ///
48640    /// Usually there is more than one suitable scope to authorize an operation, some of which may
48641    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
48642    /// sufficient, a read-write scope will do as well.
48643    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGeneratetagCall<'a, C>
48644    where
48645        St: AsRef<str>,
48646    {
48647        self._scopes.insert(String::from(scope.as_ref()));
48648        self
48649    }
48650    /// Identifies the authorization scope(s) for the method you are building.
48651    ///
48652    /// See [`Self::add_scope()`] for details.
48653    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGeneratetagCall<'a, C>
48654    where
48655        I: IntoIterator<Item = St>,
48656        St: AsRef<str>,
48657    {
48658        self._scopes
48659            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
48660        self
48661    }
48662
48663    /// Removes all scopes, and no default scope will be used either.
48664    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
48665    /// for details).
48666    pub fn clear_scopes(mut self) -> FloodlightActivityGeneratetagCall<'a, C> {
48667        self._scopes.clear();
48668        self
48669    }
48670}
48671
48672/// Gets one floodlight activity by ID.
48673///
48674/// A builder for the *get* method supported by a *floodlightActivity* resource.
48675/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
48676///
48677/// # Example
48678///
48679/// Instantiate a resource method builder
48680///
48681/// ```test_harness,no_run
48682/// # extern crate hyper;
48683/// # extern crate hyper_rustls;
48684/// # extern crate google_dfareporting3d2 as dfareporting3d2;
48685/// # async fn dox() {
48686/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
48687///
48688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
48689/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
48690/// #     secret,
48691/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48692/// # ).build().await.unwrap();
48693///
48694/// # let client = hyper_util::client::legacy::Client::builder(
48695/// #     hyper_util::rt::TokioExecutor::new()
48696/// # )
48697/// # .build(
48698/// #     hyper_rustls::HttpsConnectorBuilder::new()
48699/// #         .with_native_roots()
48700/// #         .unwrap()
48701/// #         .https_or_http()
48702/// #         .enable_http1()
48703/// #         .build()
48704/// # );
48705/// # let mut hub = Dfareporting::new(client, auth);
48706/// // You can configure optional parameters by calling the respective setters at will, and
48707/// // execute the final call using `doit()`.
48708/// // Values shown here are possibly random and not representative !
48709/// let result = hub.floodlight_activities().get(-90, -4)
48710///              .doit().await;
48711/// # }
48712/// ```
48713pub struct FloodlightActivityGetCall<'a, C>
48714where
48715    C: 'a,
48716{
48717    hub: &'a Dfareporting<C>,
48718    _profile_id: i64,
48719    _id: i64,
48720    _delegate: Option<&'a mut dyn common::Delegate>,
48721    _additional_params: HashMap<String, String>,
48722    _scopes: BTreeSet<String>,
48723}
48724
48725impl<'a, C> common::CallBuilder for FloodlightActivityGetCall<'a, C> {}
48726
48727impl<'a, C> FloodlightActivityGetCall<'a, C>
48728where
48729    C: common::Connector,
48730{
48731    /// Perform the operation you have build so far.
48732    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivity)> {
48733        use std::borrow::Cow;
48734        use std::io::{Read, Seek};
48735
48736        use common::{url::Params, ToParts};
48737        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
48738
48739        let mut dd = common::DefaultDelegate;
48740        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
48741        dlg.begin(common::MethodInfo {
48742            id: "dfareporting.floodlightActivities.get",
48743            http_method: hyper::Method::GET,
48744        });
48745
48746        for &field in ["alt", "profileId", "id"].iter() {
48747            if self._additional_params.contains_key(field) {
48748                dlg.finished(false);
48749                return Err(common::Error::FieldClash(field));
48750            }
48751        }
48752
48753        let mut params = Params::with_capacity(4 + self._additional_params.len());
48754        params.push("profileId", self._profile_id.to_string());
48755        params.push("id", self._id.to_string());
48756
48757        params.extend(self._additional_params.iter());
48758
48759        params.push("alt", "json");
48760        let mut url =
48761            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities/{id}";
48762        if self._scopes.is_empty() {
48763            self._scopes
48764                .insert(Scope::Dfatrafficking.as_ref().to_string());
48765        }
48766
48767        #[allow(clippy::single_element_loop)]
48768        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
48769            url = params.uri_replacement(url, param_name, find_this, false);
48770        }
48771        {
48772            let to_remove = ["id", "profileId"];
48773            params.remove_params(&to_remove);
48774        }
48775
48776        let url = params.parse_with_url(&url);
48777
48778        loop {
48779            let token = match self
48780                .hub
48781                .auth
48782                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
48783                .await
48784            {
48785                Ok(token) => token,
48786                Err(e) => match dlg.token(e) {
48787                    Ok(token) => token,
48788                    Err(e) => {
48789                        dlg.finished(false);
48790                        return Err(common::Error::MissingToken(e));
48791                    }
48792                },
48793            };
48794            let mut req_result = {
48795                let client = &self.hub.client;
48796                dlg.pre_request();
48797                let mut req_builder = hyper::Request::builder()
48798                    .method(hyper::Method::GET)
48799                    .uri(url.as_str())
48800                    .header(USER_AGENT, self.hub._user_agent.clone());
48801
48802                if let Some(token) = token.as_ref() {
48803                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
48804                }
48805
48806                let request = req_builder
48807                    .header(CONTENT_LENGTH, 0_u64)
48808                    .body(common::to_body::<String>(None));
48809
48810                client.request(request.unwrap()).await
48811            };
48812
48813            match req_result {
48814                Err(err) => {
48815                    if let common::Retry::After(d) = dlg.http_error(&err) {
48816                        sleep(d).await;
48817                        continue;
48818                    }
48819                    dlg.finished(false);
48820                    return Err(common::Error::HttpError(err));
48821                }
48822                Ok(res) => {
48823                    let (mut parts, body) = res.into_parts();
48824                    let mut body = common::Body::new(body);
48825                    if !parts.status.is_success() {
48826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
48827                        let error = serde_json::from_str(&common::to_string(&bytes));
48828                        let response = common::to_response(parts, bytes.into());
48829
48830                        if let common::Retry::After(d) =
48831                            dlg.http_failure(&response, error.as_ref().ok())
48832                        {
48833                            sleep(d).await;
48834                            continue;
48835                        }
48836
48837                        dlg.finished(false);
48838
48839                        return Err(match error {
48840                            Ok(value) => common::Error::BadRequest(value),
48841                            _ => common::Error::Failure(response),
48842                        });
48843                    }
48844                    let response = {
48845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
48846                        let encoded = common::to_string(&bytes);
48847                        match serde_json::from_str(&encoded) {
48848                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
48849                            Err(error) => {
48850                                dlg.response_json_decode_error(&encoded, &error);
48851                                return Err(common::Error::JsonDecodeError(
48852                                    encoded.to_string(),
48853                                    error,
48854                                ));
48855                            }
48856                        }
48857                    };
48858
48859                    dlg.finished(true);
48860                    return Ok(response);
48861                }
48862            }
48863        }
48864    }
48865
48866    /// User profile ID associated with this request.
48867    ///
48868    /// Sets the *profile id* path property to the given value.
48869    ///
48870    /// Even though the property as already been set when instantiating this call,
48871    /// we provide this method for API completeness.
48872    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGetCall<'a, C> {
48873        self._profile_id = new_value;
48874        self
48875    }
48876    /// Floodlight activity ID.
48877    ///
48878    /// Sets the *id* path property to the given value.
48879    ///
48880    /// Even though the property as already been set when instantiating this call,
48881    /// we provide this method for API completeness.
48882    pub fn id(mut self, new_value: i64) -> FloodlightActivityGetCall<'a, C> {
48883        self._id = new_value;
48884        self
48885    }
48886    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
48887    /// while executing the actual API request.
48888    ///
48889    /// ````text
48890    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
48891    /// ````
48892    ///
48893    /// Sets the *delegate* property to the given value.
48894    pub fn delegate(
48895        mut self,
48896        new_value: &'a mut dyn common::Delegate,
48897    ) -> FloodlightActivityGetCall<'a, C> {
48898        self._delegate = Some(new_value);
48899        self
48900    }
48901
48902    /// Set any additional parameter of the query string used in the request.
48903    /// It should be used to set parameters which are not yet available through their own
48904    /// setters.
48905    ///
48906    /// Please note that this method must not be used to set any of the known parameters
48907    /// which have their own setter method. If done anyway, the request will fail.
48908    ///
48909    /// # Additional Parameters
48910    ///
48911    /// * *alt* (query-string) - Data format for the response.
48912    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
48913    /// * *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.
48914    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
48915    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
48916    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
48917    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
48918    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGetCall<'a, C>
48919    where
48920        T: AsRef<str>,
48921    {
48922        self._additional_params
48923            .insert(name.as_ref().to_string(), value.as_ref().to_string());
48924        self
48925    }
48926
48927    /// Identifies the authorization scope for the method you are building.
48928    ///
48929    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
48930    /// [`Scope::Dfatrafficking`].
48931    ///
48932    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
48933    /// tokens for more than one scope.
48934    ///
48935    /// Usually there is more than one suitable scope to authorize an operation, some of which may
48936    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
48937    /// sufficient, a read-write scope will do as well.
48938    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGetCall<'a, C>
48939    where
48940        St: AsRef<str>,
48941    {
48942        self._scopes.insert(String::from(scope.as_ref()));
48943        self
48944    }
48945    /// Identifies the authorization scope(s) for the method you are building.
48946    ///
48947    /// See [`Self::add_scope()`] for details.
48948    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGetCall<'a, C>
48949    where
48950        I: IntoIterator<Item = St>,
48951        St: AsRef<str>,
48952    {
48953        self._scopes
48954            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
48955        self
48956    }
48957
48958    /// Removes all scopes, and no default scope will be used either.
48959    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
48960    /// for details).
48961    pub fn clear_scopes(mut self) -> FloodlightActivityGetCall<'a, C> {
48962        self._scopes.clear();
48963        self
48964    }
48965}
48966
48967/// Inserts a new floodlight activity.
48968///
48969/// A builder for the *insert* method supported by a *floodlightActivity* resource.
48970/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
48971///
48972/// # Example
48973///
48974/// Instantiate a resource method builder
48975///
48976/// ```test_harness,no_run
48977/// # extern crate hyper;
48978/// # extern crate hyper_rustls;
48979/// # extern crate google_dfareporting3d2 as dfareporting3d2;
48980/// use dfareporting3d2::api::FloodlightActivity;
48981/// # async fn dox() {
48982/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
48983///
48984/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
48985/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
48986/// #     secret,
48987/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
48988/// # ).build().await.unwrap();
48989///
48990/// # let client = hyper_util::client::legacy::Client::builder(
48991/// #     hyper_util::rt::TokioExecutor::new()
48992/// # )
48993/// # .build(
48994/// #     hyper_rustls::HttpsConnectorBuilder::new()
48995/// #         .with_native_roots()
48996/// #         .unwrap()
48997/// #         .https_or_http()
48998/// #         .enable_http1()
48999/// #         .build()
49000/// # );
49001/// # let mut hub = Dfareporting::new(client, auth);
49002/// // As the method needs a request, you would usually fill it with the desired information
49003/// // into the respective structure. Some of the parts shown here might not be applicable !
49004/// // Values shown here are possibly random and not representative !
49005/// let mut req = FloodlightActivity::default();
49006///
49007/// // You can configure optional parameters by calling the respective setters at will, and
49008/// // execute the final call using `doit()`.
49009/// // Values shown here are possibly random and not representative !
49010/// let result = hub.floodlight_activities().insert(req, -95)
49011///              .doit().await;
49012/// # }
49013/// ```
49014pub struct FloodlightActivityInsertCall<'a, C>
49015where
49016    C: 'a,
49017{
49018    hub: &'a Dfareporting<C>,
49019    _request: FloodlightActivity,
49020    _profile_id: i64,
49021    _delegate: Option<&'a mut dyn common::Delegate>,
49022    _additional_params: HashMap<String, String>,
49023    _scopes: BTreeSet<String>,
49024}
49025
49026impl<'a, C> common::CallBuilder for FloodlightActivityInsertCall<'a, C> {}
49027
49028impl<'a, C> FloodlightActivityInsertCall<'a, C>
49029where
49030    C: common::Connector,
49031{
49032    /// Perform the operation you have build so far.
49033    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivity)> {
49034        use std::borrow::Cow;
49035        use std::io::{Read, Seek};
49036
49037        use common::{url::Params, ToParts};
49038        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
49039
49040        let mut dd = common::DefaultDelegate;
49041        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
49042        dlg.begin(common::MethodInfo {
49043            id: "dfareporting.floodlightActivities.insert",
49044            http_method: hyper::Method::POST,
49045        });
49046
49047        for &field in ["alt", "profileId"].iter() {
49048            if self._additional_params.contains_key(field) {
49049                dlg.finished(false);
49050                return Err(common::Error::FieldClash(field));
49051            }
49052        }
49053
49054        let mut params = Params::with_capacity(4 + self._additional_params.len());
49055        params.push("profileId", self._profile_id.to_string());
49056
49057        params.extend(self._additional_params.iter());
49058
49059        params.push("alt", "json");
49060        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities";
49061        if self._scopes.is_empty() {
49062            self._scopes
49063                .insert(Scope::Dfatrafficking.as_ref().to_string());
49064        }
49065
49066        #[allow(clippy::single_element_loop)]
49067        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
49068            url = params.uri_replacement(url, param_name, find_this, false);
49069        }
49070        {
49071            let to_remove = ["profileId"];
49072            params.remove_params(&to_remove);
49073        }
49074
49075        let url = params.parse_with_url(&url);
49076
49077        let mut json_mime_type = mime::APPLICATION_JSON;
49078        let mut request_value_reader = {
49079            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
49080            common::remove_json_null_values(&mut value);
49081            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
49082            serde_json::to_writer(&mut dst, &value).unwrap();
49083            dst
49084        };
49085        let request_size = request_value_reader
49086            .seek(std::io::SeekFrom::End(0))
49087            .unwrap();
49088        request_value_reader
49089            .seek(std::io::SeekFrom::Start(0))
49090            .unwrap();
49091
49092        loop {
49093            let token = match self
49094                .hub
49095                .auth
49096                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
49097                .await
49098            {
49099                Ok(token) => token,
49100                Err(e) => match dlg.token(e) {
49101                    Ok(token) => token,
49102                    Err(e) => {
49103                        dlg.finished(false);
49104                        return Err(common::Error::MissingToken(e));
49105                    }
49106                },
49107            };
49108            request_value_reader
49109                .seek(std::io::SeekFrom::Start(0))
49110                .unwrap();
49111            let mut req_result = {
49112                let client = &self.hub.client;
49113                dlg.pre_request();
49114                let mut req_builder = hyper::Request::builder()
49115                    .method(hyper::Method::POST)
49116                    .uri(url.as_str())
49117                    .header(USER_AGENT, self.hub._user_agent.clone());
49118
49119                if let Some(token) = token.as_ref() {
49120                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
49121                }
49122
49123                let request = req_builder
49124                    .header(CONTENT_TYPE, json_mime_type.to_string())
49125                    .header(CONTENT_LENGTH, request_size as u64)
49126                    .body(common::to_body(
49127                        request_value_reader.get_ref().clone().into(),
49128                    ));
49129
49130                client.request(request.unwrap()).await
49131            };
49132
49133            match req_result {
49134                Err(err) => {
49135                    if let common::Retry::After(d) = dlg.http_error(&err) {
49136                        sleep(d).await;
49137                        continue;
49138                    }
49139                    dlg.finished(false);
49140                    return Err(common::Error::HttpError(err));
49141                }
49142                Ok(res) => {
49143                    let (mut parts, body) = res.into_parts();
49144                    let mut body = common::Body::new(body);
49145                    if !parts.status.is_success() {
49146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49147                        let error = serde_json::from_str(&common::to_string(&bytes));
49148                        let response = common::to_response(parts, bytes.into());
49149
49150                        if let common::Retry::After(d) =
49151                            dlg.http_failure(&response, error.as_ref().ok())
49152                        {
49153                            sleep(d).await;
49154                            continue;
49155                        }
49156
49157                        dlg.finished(false);
49158
49159                        return Err(match error {
49160                            Ok(value) => common::Error::BadRequest(value),
49161                            _ => common::Error::Failure(response),
49162                        });
49163                    }
49164                    let response = {
49165                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49166                        let encoded = common::to_string(&bytes);
49167                        match serde_json::from_str(&encoded) {
49168                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
49169                            Err(error) => {
49170                                dlg.response_json_decode_error(&encoded, &error);
49171                                return Err(common::Error::JsonDecodeError(
49172                                    encoded.to_string(),
49173                                    error,
49174                                ));
49175                            }
49176                        }
49177                    };
49178
49179                    dlg.finished(true);
49180                    return Ok(response);
49181                }
49182            }
49183        }
49184    }
49185
49186    ///
49187    /// Sets the *request* property to the given value.
49188    ///
49189    /// Even though the property as already been set when instantiating this call,
49190    /// we provide this method for API completeness.
49191    pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityInsertCall<'a, C> {
49192        self._request = new_value;
49193        self
49194    }
49195    /// User profile ID associated with this request.
49196    ///
49197    /// Sets the *profile id* path property to the given value.
49198    ///
49199    /// Even though the property as already been set when instantiating this call,
49200    /// we provide this method for API completeness.
49201    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityInsertCall<'a, C> {
49202        self._profile_id = new_value;
49203        self
49204    }
49205    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
49206    /// while executing the actual API request.
49207    ///
49208    /// ````text
49209    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
49210    /// ````
49211    ///
49212    /// Sets the *delegate* property to the given value.
49213    pub fn delegate(
49214        mut self,
49215        new_value: &'a mut dyn common::Delegate,
49216    ) -> FloodlightActivityInsertCall<'a, C> {
49217        self._delegate = Some(new_value);
49218        self
49219    }
49220
49221    /// Set any additional parameter of the query string used in the request.
49222    /// It should be used to set parameters which are not yet available through their own
49223    /// setters.
49224    ///
49225    /// Please note that this method must not be used to set any of the known parameters
49226    /// which have their own setter method. If done anyway, the request will fail.
49227    ///
49228    /// # Additional Parameters
49229    ///
49230    /// * *alt* (query-string) - Data format for the response.
49231    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
49232    /// * *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.
49233    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
49234    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
49235    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
49236    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
49237    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityInsertCall<'a, C>
49238    where
49239        T: AsRef<str>,
49240    {
49241        self._additional_params
49242            .insert(name.as_ref().to_string(), value.as_ref().to_string());
49243        self
49244    }
49245
49246    /// Identifies the authorization scope for the method you are building.
49247    ///
49248    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
49249    /// [`Scope::Dfatrafficking`].
49250    ///
49251    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
49252    /// tokens for more than one scope.
49253    ///
49254    /// Usually there is more than one suitable scope to authorize an operation, some of which may
49255    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
49256    /// sufficient, a read-write scope will do as well.
49257    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityInsertCall<'a, C>
49258    where
49259        St: AsRef<str>,
49260    {
49261        self._scopes.insert(String::from(scope.as_ref()));
49262        self
49263    }
49264    /// Identifies the authorization scope(s) for the method you are building.
49265    ///
49266    /// See [`Self::add_scope()`] for details.
49267    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityInsertCall<'a, C>
49268    where
49269        I: IntoIterator<Item = St>,
49270        St: AsRef<str>,
49271    {
49272        self._scopes
49273            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
49274        self
49275    }
49276
49277    /// Removes all scopes, and no default scope will be used either.
49278    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
49279    /// for details).
49280    pub fn clear_scopes(mut self) -> FloodlightActivityInsertCall<'a, C> {
49281        self._scopes.clear();
49282        self
49283    }
49284}
49285
49286/// Retrieves a list of floodlight activities, possibly filtered. This method supports paging.
49287///
49288/// A builder for the *list* method supported by a *floodlightActivity* resource.
49289/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
49290///
49291/// # Example
49292///
49293/// Instantiate a resource method builder
49294///
49295/// ```test_harness,no_run
49296/// # extern crate hyper;
49297/// # extern crate hyper_rustls;
49298/// # extern crate google_dfareporting3d2 as dfareporting3d2;
49299/// # async fn dox() {
49300/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
49301///
49302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
49303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
49304/// #     secret,
49305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
49306/// # ).build().await.unwrap();
49307///
49308/// # let client = hyper_util::client::legacy::Client::builder(
49309/// #     hyper_util::rt::TokioExecutor::new()
49310/// # )
49311/// # .build(
49312/// #     hyper_rustls::HttpsConnectorBuilder::new()
49313/// #         .with_native_roots()
49314/// #         .unwrap()
49315/// #         .https_or_http()
49316/// #         .enable_http1()
49317/// #         .build()
49318/// # );
49319/// # let mut hub = Dfareporting::new(client, auth);
49320/// // You can configure optional parameters by calling the respective setters at will, and
49321/// // execute the final call using `doit()`.
49322/// // Values shown here are possibly random and not representative !
49323/// let result = hub.floodlight_activities().list(-4)
49324///              .tag_string("dolor")
49325///              .sort_order("consetetur")
49326///              .sort_field("et")
49327///              .search_string("sit")
49328///              .page_token("Lorem")
49329///              .max_results(-41)
49330///              .add_ids(-79)
49331///              .floodlight_configuration_id(-100)
49332///              .floodlight_activity_group_type("invidunt")
49333///              .floodlight_activity_group_tag_string("Stet")
49334///              .floodlight_activity_group_name("voluptua.")
49335///              .add_floodlight_activity_group_ids(-77)
49336///              .advertiser_id(-92)
49337///              .doit().await;
49338/// # }
49339/// ```
49340pub struct FloodlightActivityListCall<'a, C>
49341where
49342    C: 'a,
49343{
49344    hub: &'a Dfareporting<C>,
49345    _profile_id: i64,
49346    _tag_string: Option<String>,
49347    _sort_order: Option<String>,
49348    _sort_field: Option<String>,
49349    _search_string: Option<String>,
49350    _page_token: Option<String>,
49351    _max_results: Option<i32>,
49352    _ids: Vec<i64>,
49353    _floodlight_configuration_id: Option<i64>,
49354    _floodlight_activity_group_type: Option<String>,
49355    _floodlight_activity_group_tag_string: Option<String>,
49356    _floodlight_activity_group_name: Option<String>,
49357    _floodlight_activity_group_ids: Vec<i64>,
49358    _advertiser_id: Option<i64>,
49359    _delegate: Option<&'a mut dyn common::Delegate>,
49360    _additional_params: HashMap<String, String>,
49361    _scopes: BTreeSet<String>,
49362}
49363
49364impl<'a, C> common::CallBuilder for FloodlightActivityListCall<'a, C> {}
49365
49366impl<'a, C> FloodlightActivityListCall<'a, C>
49367where
49368    C: common::Connector,
49369{
49370    /// Perform the operation you have build so far.
49371    pub async fn doit(
49372        mut self,
49373    ) -> common::Result<(common::Response, FloodlightActivitiesListResponse)> {
49374        use std::borrow::Cow;
49375        use std::io::{Read, Seek};
49376
49377        use common::{url::Params, ToParts};
49378        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
49379
49380        let mut dd = common::DefaultDelegate;
49381        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
49382        dlg.begin(common::MethodInfo {
49383            id: "dfareporting.floodlightActivities.list",
49384            http_method: hyper::Method::GET,
49385        });
49386
49387        for &field in [
49388            "alt",
49389            "profileId",
49390            "tagString",
49391            "sortOrder",
49392            "sortField",
49393            "searchString",
49394            "pageToken",
49395            "maxResults",
49396            "ids",
49397            "floodlightConfigurationId",
49398            "floodlightActivityGroupType",
49399            "floodlightActivityGroupTagString",
49400            "floodlightActivityGroupName",
49401            "floodlightActivityGroupIds",
49402            "advertiserId",
49403        ]
49404        .iter()
49405        {
49406            if self._additional_params.contains_key(field) {
49407                dlg.finished(false);
49408                return Err(common::Error::FieldClash(field));
49409            }
49410        }
49411
49412        let mut params = Params::with_capacity(16 + self._additional_params.len());
49413        params.push("profileId", self._profile_id.to_string());
49414        if let Some(value) = self._tag_string.as_ref() {
49415            params.push("tagString", value);
49416        }
49417        if let Some(value) = self._sort_order.as_ref() {
49418            params.push("sortOrder", value);
49419        }
49420        if let Some(value) = self._sort_field.as_ref() {
49421            params.push("sortField", value);
49422        }
49423        if let Some(value) = self._search_string.as_ref() {
49424            params.push("searchString", value);
49425        }
49426        if let Some(value) = self._page_token.as_ref() {
49427            params.push("pageToken", value);
49428        }
49429        if let Some(value) = self._max_results.as_ref() {
49430            params.push("maxResults", value.to_string());
49431        }
49432        if !self._ids.is_empty() {
49433            for f in self._ids.iter() {
49434                params.push("ids", f.to_string());
49435            }
49436        }
49437        if let Some(value) = self._floodlight_configuration_id.as_ref() {
49438            params.push("floodlightConfigurationId", value.to_string());
49439        }
49440        if let Some(value) = self._floodlight_activity_group_type.as_ref() {
49441            params.push("floodlightActivityGroupType", value);
49442        }
49443        if let Some(value) = self._floodlight_activity_group_tag_string.as_ref() {
49444            params.push("floodlightActivityGroupTagString", value);
49445        }
49446        if let Some(value) = self._floodlight_activity_group_name.as_ref() {
49447            params.push("floodlightActivityGroupName", value);
49448        }
49449        if !self._floodlight_activity_group_ids.is_empty() {
49450            for f in self._floodlight_activity_group_ids.iter() {
49451                params.push("floodlightActivityGroupIds", f.to_string());
49452            }
49453        }
49454        if let Some(value) = self._advertiser_id.as_ref() {
49455            params.push("advertiserId", value.to_string());
49456        }
49457
49458        params.extend(self._additional_params.iter());
49459
49460        params.push("alt", "json");
49461        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities";
49462        if self._scopes.is_empty() {
49463            self._scopes
49464                .insert(Scope::Dfatrafficking.as_ref().to_string());
49465        }
49466
49467        #[allow(clippy::single_element_loop)]
49468        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
49469            url = params.uri_replacement(url, param_name, find_this, false);
49470        }
49471        {
49472            let to_remove = ["profileId"];
49473            params.remove_params(&to_remove);
49474        }
49475
49476        let url = params.parse_with_url(&url);
49477
49478        loop {
49479            let token = match self
49480                .hub
49481                .auth
49482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
49483                .await
49484            {
49485                Ok(token) => token,
49486                Err(e) => match dlg.token(e) {
49487                    Ok(token) => token,
49488                    Err(e) => {
49489                        dlg.finished(false);
49490                        return Err(common::Error::MissingToken(e));
49491                    }
49492                },
49493            };
49494            let mut req_result = {
49495                let client = &self.hub.client;
49496                dlg.pre_request();
49497                let mut req_builder = hyper::Request::builder()
49498                    .method(hyper::Method::GET)
49499                    .uri(url.as_str())
49500                    .header(USER_AGENT, self.hub._user_agent.clone());
49501
49502                if let Some(token) = token.as_ref() {
49503                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
49504                }
49505
49506                let request = req_builder
49507                    .header(CONTENT_LENGTH, 0_u64)
49508                    .body(common::to_body::<String>(None));
49509
49510                client.request(request.unwrap()).await
49511            };
49512
49513            match req_result {
49514                Err(err) => {
49515                    if let common::Retry::After(d) = dlg.http_error(&err) {
49516                        sleep(d).await;
49517                        continue;
49518                    }
49519                    dlg.finished(false);
49520                    return Err(common::Error::HttpError(err));
49521                }
49522                Ok(res) => {
49523                    let (mut parts, body) = res.into_parts();
49524                    let mut body = common::Body::new(body);
49525                    if !parts.status.is_success() {
49526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49527                        let error = serde_json::from_str(&common::to_string(&bytes));
49528                        let response = common::to_response(parts, bytes.into());
49529
49530                        if let common::Retry::After(d) =
49531                            dlg.http_failure(&response, error.as_ref().ok())
49532                        {
49533                            sleep(d).await;
49534                            continue;
49535                        }
49536
49537                        dlg.finished(false);
49538
49539                        return Err(match error {
49540                            Ok(value) => common::Error::BadRequest(value),
49541                            _ => common::Error::Failure(response),
49542                        });
49543                    }
49544                    let response = {
49545                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49546                        let encoded = common::to_string(&bytes);
49547                        match serde_json::from_str(&encoded) {
49548                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
49549                            Err(error) => {
49550                                dlg.response_json_decode_error(&encoded, &error);
49551                                return Err(common::Error::JsonDecodeError(
49552                                    encoded.to_string(),
49553                                    error,
49554                                ));
49555                            }
49556                        }
49557                    };
49558
49559                    dlg.finished(true);
49560                    return Ok(response);
49561                }
49562            }
49563        }
49564    }
49565
49566    /// User profile ID associated with this request.
49567    ///
49568    /// Sets the *profile id* path property to the given value.
49569    ///
49570    /// Even though the property as already been set when instantiating this call,
49571    /// we provide this method for API completeness.
49572    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityListCall<'a, C> {
49573        self._profile_id = new_value;
49574        self
49575    }
49576    /// Select only floodlight activities with the specified tag string.
49577    ///
49578    /// Sets the *tag string* query property to the given value.
49579    pub fn tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C> {
49580        self._tag_string = Some(new_value.to_string());
49581        self
49582    }
49583    /// Order of sorted results.
49584    ///
49585    /// Sets the *sort order* query property to the given value.
49586    pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C> {
49587        self._sort_order = Some(new_value.to_string());
49588        self
49589    }
49590    /// Field by which to sort the list.
49591    ///
49592    /// Sets the *sort field* query property to the given value.
49593    pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C> {
49594        self._sort_field = Some(new_value.to_string());
49595        self
49596    }
49597    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivity*2015" will return objects with names like "floodlightactivity June 2015", "floodlightactivity April 2015", or simply "floodlightactivity 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivity" will match objects with name "my floodlightactivity activity", "floodlightactivity 2015", or simply "floodlightactivity".
49598    ///
49599    /// Sets the *search string* query property to the given value.
49600    pub fn search_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C> {
49601        self._search_string = Some(new_value.to_string());
49602        self
49603    }
49604    /// Value of the nextPageToken from the previous result page.
49605    ///
49606    /// Sets the *page token* query property to the given value.
49607    pub fn page_token(mut self, new_value: &str) -> FloodlightActivityListCall<'a, C> {
49608        self._page_token = Some(new_value.to_string());
49609        self
49610    }
49611    /// Maximum number of results to return.
49612    ///
49613    /// Sets the *max results* query property to the given value.
49614    pub fn max_results(mut self, new_value: i32) -> FloodlightActivityListCall<'a, C> {
49615        self._max_results = Some(new_value);
49616        self
49617    }
49618    /// Select only floodlight activities with the specified IDs. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result.
49619    ///
49620    /// Append the given value to the *ids* query property.
49621    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
49622    pub fn add_ids(mut self, new_value: i64) -> FloodlightActivityListCall<'a, C> {
49623        self._ids.push(new_value);
49624        self
49625    }
49626    /// Select only floodlight activities for the specified floodlight configuration ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result.
49627    ///
49628    /// Sets the *floodlight configuration id* query property to the given value.
49629    pub fn floodlight_configuration_id(
49630        mut self,
49631        new_value: i64,
49632    ) -> FloodlightActivityListCall<'a, C> {
49633        self._floodlight_configuration_id = Some(new_value);
49634        self
49635    }
49636    /// Select only floodlight activities with the specified floodlight activity group type.
49637    ///
49638    /// Sets the *floodlight activity group type* query property to the given value.
49639    pub fn floodlight_activity_group_type(
49640        mut self,
49641        new_value: &str,
49642    ) -> FloodlightActivityListCall<'a, C> {
49643        self._floodlight_activity_group_type = Some(new_value.to_string());
49644        self
49645    }
49646    /// Select only floodlight activities with the specified floodlight activity group tag string.
49647    ///
49648    /// Sets the *floodlight activity group tag string* query property to the given value.
49649    pub fn floodlight_activity_group_tag_string(
49650        mut self,
49651        new_value: &str,
49652    ) -> FloodlightActivityListCall<'a, C> {
49653        self._floodlight_activity_group_tag_string = Some(new_value.to_string());
49654        self
49655    }
49656    /// Select only floodlight activities with the specified floodlight activity group name.
49657    ///
49658    /// Sets the *floodlight activity group name* query property to the given value.
49659    pub fn floodlight_activity_group_name(
49660        mut self,
49661        new_value: &str,
49662    ) -> FloodlightActivityListCall<'a, C> {
49663        self._floodlight_activity_group_name = Some(new_value.to_string());
49664        self
49665    }
49666    /// Select only floodlight activities with the specified floodlight activity group IDs.
49667    ///
49668    /// Append the given value to the *floodlight activity group ids* query property.
49669    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
49670    pub fn add_floodlight_activity_group_ids(
49671        mut self,
49672        new_value: i64,
49673    ) -> FloodlightActivityListCall<'a, C> {
49674        self._floodlight_activity_group_ids.push(new_value);
49675        self
49676    }
49677    /// Select only floodlight activities for the specified advertiser ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result.
49678    ///
49679    /// Sets the *advertiser id* query property to the given value.
49680    pub fn advertiser_id(mut self, new_value: i64) -> FloodlightActivityListCall<'a, C> {
49681        self._advertiser_id = Some(new_value);
49682        self
49683    }
49684    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
49685    /// while executing the actual API request.
49686    ///
49687    /// ````text
49688    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
49689    /// ````
49690    ///
49691    /// Sets the *delegate* property to the given value.
49692    pub fn delegate(
49693        mut self,
49694        new_value: &'a mut dyn common::Delegate,
49695    ) -> FloodlightActivityListCall<'a, C> {
49696        self._delegate = Some(new_value);
49697        self
49698    }
49699
49700    /// Set any additional parameter of the query string used in the request.
49701    /// It should be used to set parameters which are not yet available through their own
49702    /// setters.
49703    ///
49704    /// Please note that this method must not be used to set any of the known parameters
49705    /// which have their own setter method. If done anyway, the request will fail.
49706    ///
49707    /// # Additional Parameters
49708    ///
49709    /// * *alt* (query-string) - Data format for the response.
49710    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
49711    /// * *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.
49712    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
49713    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
49714    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
49715    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
49716    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityListCall<'a, C>
49717    where
49718        T: AsRef<str>,
49719    {
49720        self._additional_params
49721            .insert(name.as_ref().to_string(), value.as_ref().to_string());
49722        self
49723    }
49724
49725    /// Identifies the authorization scope for the method you are building.
49726    ///
49727    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
49728    /// [`Scope::Dfatrafficking`].
49729    ///
49730    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
49731    /// tokens for more than one scope.
49732    ///
49733    /// Usually there is more than one suitable scope to authorize an operation, some of which may
49734    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
49735    /// sufficient, a read-write scope will do as well.
49736    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityListCall<'a, C>
49737    where
49738        St: AsRef<str>,
49739    {
49740        self._scopes.insert(String::from(scope.as_ref()));
49741        self
49742    }
49743    /// Identifies the authorization scope(s) for the method you are building.
49744    ///
49745    /// See [`Self::add_scope()`] for details.
49746    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityListCall<'a, C>
49747    where
49748        I: IntoIterator<Item = St>,
49749        St: AsRef<str>,
49750    {
49751        self._scopes
49752            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
49753        self
49754    }
49755
49756    /// Removes all scopes, and no default scope will be used either.
49757    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
49758    /// for details).
49759    pub fn clear_scopes(mut self) -> FloodlightActivityListCall<'a, C> {
49760        self._scopes.clear();
49761        self
49762    }
49763}
49764
49765/// Updates an existing floodlight activity. This method supports patch semantics.
49766///
49767/// A builder for the *patch* method supported by a *floodlightActivity* resource.
49768/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
49769///
49770/// # Example
49771///
49772/// Instantiate a resource method builder
49773///
49774/// ```test_harness,no_run
49775/// # extern crate hyper;
49776/// # extern crate hyper_rustls;
49777/// # extern crate google_dfareporting3d2 as dfareporting3d2;
49778/// use dfareporting3d2::api::FloodlightActivity;
49779/// # async fn dox() {
49780/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
49781///
49782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
49783/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
49784/// #     secret,
49785/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
49786/// # ).build().await.unwrap();
49787///
49788/// # let client = hyper_util::client::legacy::Client::builder(
49789/// #     hyper_util::rt::TokioExecutor::new()
49790/// # )
49791/// # .build(
49792/// #     hyper_rustls::HttpsConnectorBuilder::new()
49793/// #         .with_native_roots()
49794/// #         .unwrap()
49795/// #         .https_or_http()
49796/// #         .enable_http1()
49797/// #         .build()
49798/// # );
49799/// # let mut hub = Dfareporting::new(client, auth);
49800/// // As the method needs a request, you would usually fill it with the desired information
49801/// // into the respective structure. Some of the parts shown here might not be applicable !
49802/// // Values shown here are possibly random and not representative !
49803/// let mut req = FloodlightActivity::default();
49804///
49805/// // You can configure optional parameters by calling the respective setters at will, and
49806/// // execute the final call using `doit()`.
49807/// // Values shown here are possibly random and not representative !
49808/// let result = hub.floodlight_activities().patch(req, -47, -77)
49809///              .doit().await;
49810/// # }
49811/// ```
49812pub struct FloodlightActivityPatchCall<'a, C>
49813where
49814    C: 'a,
49815{
49816    hub: &'a Dfareporting<C>,
49817    _request: FloodlightActivity,
49818    _profile_id: i64,
49819    _id: i64,
49820    _delegate: Option<&'a mut dyn common::Delegate>,
49821    _additional_params: HashMap<String, String>,
49822    _scopes: BTreeSet<String>,
49823}
49824
49825impl<'a, C> common::CallBuilder for FloodlightActivityPatchCall<'a, C> {}
49826
49827impl<'a, C> FloodlightActivityPatchCall<'a, C>
49828where
49829    C: common::Connector,
49830{
49831    /// Perform the operation you have build so far.
49832    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivity)> {
49833        use std::borrow::Cow;
49834        use std::io::{Read, Seek};
49835
49836        use common::{url::Params, ToParts};
49837        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
49838
49839        let mut dd = common::DefaultDelegate;
49840        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
49841        dlg.begin(common::MethodInfo {
49842            id: "dfareporting.floodlightActivities.patch",
49843            http_method: hyper::Method::PATCH,
49844        });
49845
49846        for &field in ["alt", "profileId", "id"].iter() {
49847            if self._additional_params.contains_key(field) {
49848                dlg.finished(false);
49849                return Err(common::Error::FieldClash(field));
49850            }
49851        }
49852
49853        let mut params = Params::with_capacity(5 + self._additional_params.len());
49854        params.push("profileId", self._profile_id.to_string());
49855        params.push("id", self._id.to_string());
49856
49857        params.extend(self._additional_params.iter());
49858
49859        params.push("alt", "json");
49860        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities";
49861        if self._scopes.is_empty() {
49862            self._scopes
49863                .insert(Scope::Dfatrafficking.as_ref().to_string());
49864        }
49865
49866        #[allow(clippy::single_element_loop)]
49867        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
49868            url = params.uri_replacement(url, param_name, find_this, false);
49869        }
49870        {
49871            let to_remove = ["profileId"];
49872            params.remove_params(&to_remove);
49873        }
49874
49875        let url = params.parse_with_url(&url);
49876
49877        let mut json_mime_type = mime::APPLICATION_JSON;
49878        let mut request_value_reader = {
49879            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
49880            common::remove_json_null_values(&mut value);
49881            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
49882            serde_json::to_writer(&mut dst, &value).unwrap();
49883            dst
49884        };
49885        let request_size = request_value_reader
49886            .seek(std::io::SeekFrom::End(0))
49887            .unwrap();
49888        request_value_reader
49889            .seek(std::io::SeekFrom::Start(0))
49890            .unwrap();
49891
49892        loop {
49893            let token = match self
49894                .hub
49895                .auth
49896                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
49897                .await
49898            {
49899                Ok(token) => token,
49900                Err(e) => match dlg.token(e) {
49901                    Ok(token) => token,
49902                    Err(e) => {
49903                        dlg.finished(false);
49904                        return Err(common::Error::MissingToken(e));
49905                    }
49906                },
49907            };
49908            request_value_reader
49909                .seek(std::io::SeekFrom::Start(0))
49910                .unwrap();
49911            let mut req_result = {
49912                let client = &self.hub.client;
49913                dlg.pre_request();
49914                let mut req_builder = hyper::Request::builder()
49915                    .method(hyper::Method::PATCH)
49916                    .uri(url.as_str())
49917                    .header(USER_AGENT, self.hub._user_agent.clone());
49918
49919                if let Some(token) = token.as_ref() {
49920                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
49921                }
49922
49923                let request = req_builder
49924                    .header(CONTENT_TYPE, json_mime_type.to_string())
49925                    .header(CONTENT_LENGTH, request_size as u64)
49926                    .body(common::to_body(
49927                        request_value_reader.get_ref().clone().into(),
49928                    ));
49929
49930                client.request(request.unwrap()).await
49931            };
49932
49933            match req_result {
49934                Err(err) => {
49935                    if let common::Retry::After(d) = dlg.http_error(&err) {
49936                        sleep(d).await;
49937                        continue;
49938                    }
49939                    dlg.finished(false);
49940                    return Err(common::Error::HttpError(err));
49941                }
49942                Ok(res) => {
49943                    let (mut parts, body) = res.into_parts();
49944                    let mut body = common::Body::new(body);
49945                    if !parts.status.is_success() {
49946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49947                        let error = serde_json::from_str(&common::to_string(&bytes));
49948                        let response = common::to_response(parts, bytes.into());
49949
49950                        if let common::Retry::After(d) =
49951                            dlg.http_failure(&response, error.as_ref().ok())
49952                        {
49953                            sleep(d).await;
49954                            continue;
49955                        }
49956
49957                        dlg.finished(false);
49958
49959                        return Err(match error {
49960                            Ok(value) => common::Error::BadRequest(value),
49961                            _ => common::Error::Failure(response),
49962                        });
49963                    }
49964                    let response = {
49965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
49966                        let encoded = common::to_string(&bytes);
49967                        match serde_json::from_str(&encoded) {
49968                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
49969                            Err(error) => {
49970                                dlg.response_json_decode_error(&encoded, &error);
49971                                return Err(common::Error::JsonDecodeError(
49972                                    encoded.to_string(),
49973                                    error,
49974                                ));
49975                            }
49976                        }
49977                    };
49978
49979                    dlg.finished(true);
49980                    return Ok(response);
49981                }
49982            }
49983        }
49984    }
49985
49986    ///
49987    /// Sets the *request* property to the given value.
49988    ///
49989    /// Even though the property as already been set when instantiating this call,
49990    /// we provide this method for API completeness.
49991    pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityPatchCall<'a, C> {
49992        self._request = new_value;
49993        self
49994    }
49995    /// User profile ID associated with this request.
49996    ///
49997    /// Sets the *profile id* path property to the given value.
49998    ///
49999    /// Even though the property as already been set when instantiating this call,
50000    /// we provide this method for API completeness.
50001    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityPatchCall<'a, C> {
50002        self._profile_id = new_value;
50003        self
50004    }
50005    /// Floodlight activity ID.
50006    ///
50007    /// Sets the *id* query property to the given value.
50008    ///
50009    /// Even though the property as already been set when instantiating this call,
50010    /// we provide this method for API completeness.
50011    pub fn id(mut self, new_value: i64) -> FloodlightActivityPatchCall<'a, C> {
50012        self._id = new_value;
50013        self
50014    }
50015    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
50016    /// while executing the actual API request.
50017    ///
50018    /// ````text
50019    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
50020    /// ````
50021    ///
50022    /// Sets the *delegate* property to the given value.
50023    pub fn delegate(
50024        mut self,
50025        new_value: &'a mut dyn common::Delegate,
50026    ) -> FloodlightActivityPatchCall<'a, C> {
50027        self._delegate = Some(new_value);
50028        self
50029    }
50030
50031    /// Set any additional parameter of the query string used in the request.
50032    /// It should be used to set parameters which are not yet available through their own
50033    /// setters.
50034    ///
50035    /// Please note that this method must not be used to set any of the known parameters
50036    /// which have their own setter method. If done anyway, the request will fail.
50037    ///
50038    /// # Additional Parameters
50039    ///
50040    /// * *alt* (query-string) - Data format for the response.
50041    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
50042    /// * *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.
50043    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
50044    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
50045    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
50046    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
50047    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityPatchCall<'a, C>
50048    where
50049        T: AsRef<str>,
50050    {
50051        self._additional_params
50052            .insert(name.as_ref().to_string(), value.as_ref().to_string());
50053        self
50054    }
50055
50056    /// Identifies the authorization scope for the method you are building.
50057    ///
50058    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
50059    /// [`Scope::Dfatrafficking`].
50060    ///
50061    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
50062    /// tokens for more than one scope.
50063    ///
50064    /// Usually there is more than one suitable scope to authorize an operation, some of which may
50065    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
50066    /// sufficient, a read-write scope will do as well.
50067    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityPatchCall<'a, C>
50068    where
50069        St: AsRef<str>,
50070    {
50071        self._scopes.insert(String::from(scope.as_ref()));
50072        self
50073    }
50074    /// Identifies the authorization scope(s) for the method you are building.
50075    ///
50076    /// See [`Self::add_scope()`] for details.
50077    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityPatchCall<'a, C>
50078    where
50079        I: IntoIterator<Item = St>,
50080        St: AsRef<str>,
50081    {
50082        self._scopes
50083            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
50084        self
50085    }
50086
50087    /// Removes all scopes, and no default scope will be used either.
50088    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
50089    /// for details).
50090    pub fn clear_scopes(mut self) -> FloodlightActivityPatchCall<'a, C> {
50091        self._scopes.clear();
50092        self
50093    }
50094}
50095
50096/// Updates an existing floodlight activity.
50097///
50098/// A builder for the *update* method supported by a *floodlightActivity* resource.
50099/// It is not used directly, but through a [`FloodlightActivityMethods`] instance.
50100///
50101/// # Example
50102///
50103/// Instantiate a resource method builder
50104///
50105/// ```test_harness,no_run
50106/// # extern crate hyper;
50107/// # extern crate hyper_rustls;
50108/// # extern crate google_dfareporting3d2 as dfareporting3d2;
50109/// use dfareporting3d2::api::FloodlightActivity;
50110/// # async fn dox() {
50111/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
50112///
50113/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
50114/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
50115/// #     secret,
50116/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
50117/// # ).build().await.unwrap();
50118///
50119/// # let client = hyper_util::client::legacy::Client::builder(
50120/// #     hyper_util::rt::TokioExecutor::new()
50121/// # )
50122/// # .build(
50123/// #     hyper_rustls::HttpsConnectorBuilder::new()
50124/// #         .with_native_roots()
50125/// #         .unwrap()
50126/// #         .https_or_http()
50127/// #         .enable_http1()
50128/// #         .build()
50129/// # );
50130/// # let mut hub = Dfareporting::new(client, auth);
50131/// // As the method needs a request, you would usually fill it with the desired information
50132/// // into the respective structure. Some of the parts shown here might not be applicable !
50133/// // Values shown here are possibly random and not representative !
50134/// let mut req = FloodlightActivity::default();
50135///
50136/// // You can configure optional parameters by calling the respective setters at will, and
50137/// // execute the final call using `doit()`.
50138/// // Values shown here are possibly random and not representative !
50139/// let result = hub.floodlight_activities().update(req, -90)
50140///              .doit().await;
50141/// # }
50142/// ```
50143pub struct FloodlightActivityUpdateCall<'a, C>
50144where
50145    C: 'a,
50146{
50147    hub: &'a Dfareporting<C>,
50148    _request: FloodlightActivity,
50149    _profile_id: i64,
50150    _delegate: Option<&'a mut dyn common::Delegate>,
50151    _additional_params: HashMap<String, String>,
50152    _scopes: BTreeSet<String>,
50153}
50154
50155impl<'a, C> common::CallBuilder for FloodlightActivityUpdateCall<'a, C> {}
50156
50157impl<'a, C> FloodlightActivityUpdateCall<'a, C>
50158where
50159    C: common::Connector,
50160{
50161    /// Perform the operation you have build so far.
50162    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivity)> {
50163        use std::borrow::Cow;
50164        use std::io::{Read, Seek};
50165
50166        use common::{url::Params, ToParts};
50167        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
50168
50169        let mut dd = common::DefaultDelegate;
50170        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
50171        dlg.begin(common::MethodInfo {
50172            id: "dfareporting.floodlightActivities.update",
50173            http_method: hyper::Method::PUT,
50174        });
50175
50176        for &field in ["alt", "profileId"].iter() {
50177            if self._additional_params.contains_key(field) {
50178                dlg.finished(false);
50179                return Err(common::Error::FieldClash(field));
50180            }
50181        }
50182
50183        let mut params = Params::with_capacity(4 + self._additional_params.len());
50184        params.push("profileId", self._profile_id.to_string());
50185
50186        params.extend(self._additional_params.iter());
50187
50188        params.push("alt", "json");
50189        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities";
50190        if self._scopes.is_empty() {
50191            self._scopes
50192                .insert(Scope::Dfatrafficking.as_ref().to_string());
50193        }
50194
50195        #[allow(clippy::single_element_loop)]
50196        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
50197            url = params.uri_replacement(url, param_name, find_this, false);
50198        }
50199        {
50200            let to_remove = ["profileId"];
50201            params.remove_params(&to_remove);
50202        }
50203
50204        let url = params.parse_with_url(&url);
50205
50206        let mut json_mime_type = mime::APPLICATION_JSON;
50207        let mut request_value_reader = {
50208            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
50209            common::remove_json_null_values(&mut value);
50210            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
50211            serde_json::to_writer(&mut dst, &value).unwrap();
50212            dst
50213        };
50214        let request_size = request_value_reader
50215            .seek(std::io::SeekFrom::End(0))
50216            .unwrap();
50217        request_value_reader
50218            .seek(std::io::SeekFrom::Start(0))
50219            .unwrap();
50220
50221        loop {
50222            let token = match self
50223                .hub
50224                .auth
50225                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
50226                .await
50227            {
50228                Ok(token) => token,
50229                Err(e) => match dlg.token(e) {
50230                    Ok(token) => token,
50231                    Err(e) => {
50232                        dlg.finished(false);
50233                        return Err(common::Error::MissingToken(e));
50234                    }
50235                },
50236            };
50237            request_value_reader
50238                .seek(std::io::SeekFrom::Start(0))
50239                .unwrap();
50240            let mut req_result = {
50241                let client = &self.hub.client;
50242                dlg.pre_request();
50243                let mut req_builder = hyper::Request::builder()
50244                    .method(hyper::Method::PUT)
50245                    .uri(url.as_str())
50246                    .header(USER_AGENT, self.hub._user_agent.clone());
50247
50248                if let Some(token) = token.as_ref() {
50249                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
50250                }
50251
50252                let request = req_builder
50253                    .header(CONTENT_TYPE, json_mime_type.to_string())
50254                    .header(CONTENT_LENGTH, request_size as u64)
50255                    .body(common::to_body(
50256                        request_value_reader.get_ref().clone().into(),
50257                    ));
50258
50259                client.request(request.unwrap()).await
50260            };
50261
50262            match req_result {
50263                Err(err) => {
50264                    if let common::Retry::After(d) = dlg.http_error(&err) {
50265                        sleep(d).await;
50266                        continue;
50267                    }
50268                    dlg.finished(false);
50269                    return Err(common::Error::HttpError(err));
50270                }
50271                Ok(res) => {
50272                    let (mut parts, body) = res.into_parts();
50273                    let mut body = common::Body::new(body);
50274                    if !parts.status.is_success() {
50275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50276                        let error = serde_json::from_str(&common::to_string(&bytes));
50277                        let response = common::to_response(parts, bytes.into());
50278
50279                        if let common::Retry::After(d) =
50280                            dlg.http_failure(&response, error.as_ref().ok())
50281                        {
50282                            sleep(d).await;
50283                            continue;
50284                        }
50285
50286                        dlg.finished(false);
50287
50288                        return Err(match error {
50289                            Ok(value) => common::Error::BadRequest(value),
50290                            _ => common::Error::Failure(response),
50291                        });
50292                    }
50293                    let response = {
50294                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50295                        let encoded = common::to_string(&bytes);
50296                        match serde_json::from_str(&encoded) {
50297                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
50298                            Err(error) => {
50299                                dlg.response_json_decode_error(&encoded, &error);
50300                                return Err(common::Error::JsonDecodeError(
50301                                    encoded.to_string(),
50302                                    error,
50303                                ));
50304                            }
50305                        }
50306                    };
50307
50308                    dlg.finished(true);
50309                    return Ok(response);
50310                }
50311            }
50312        }
50313    }
50314
50315    ///
50316    /// Sets the *request* property to the given value.
50317    ///
50318    /// Even though the property as already been set when instantiating this call,
50319    /// we provide this method for API completeness.
50320    pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityUpdateCall<'a, C> {
50321        self._request = new_value;
50322        self
50323    }
50324    /// User profile ID associated with this request.
50325    ///
50326    /// Sets the *profile id* path property to the given value.
50327    ///
50328    /// Even though the property as already been set when instantiating this call,
50329    /// we provide this method for API completeness.
50330    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityUpdateCall<'a, C> {
50331        self._profile_id = new_value;
50332        self
50333    }
50334    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
50335    /// while executing the actual API request.
50336    ///
50337    /// ````text
50338    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
50339    /// ````
50340    ///
50341    /// Sets the *delegate* property to the given value.
50342    pub fn delegate(
50343        mut self,
50344        new_value: &'a mut dyn common::Delegate,
50345    ) -> FloodlightActivityUpdateCall<'a, C> {
50346        self._delegate = Some(new_value);
50347        self
50348    }
50349
50350    /// Set any additional parameter of the query string used in the request.
50351    /// It should be used to set parameters which are not yet available through their own
50352    /// setters.
50353    ///
50354    /// Please note that this method must not be used to set any of the known parameters
50355    /// which have their own setter method. If done anyway, the request will fail.
50356    ///
50357    /// # Additional Parameters
50358    ///
50359    /// * *alt* (query-string) - Data format for the response.
50360    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
50361    /// * *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.
50362    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
50363    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
50364    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
50365    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
50366    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityUpdateCall<'a, C>
50367    where
50368        T: AsRef<str>,
50369    {
50370        self._additional_params
50371            .insert(name.as_ref().to_string(), value.as_ref().to_string());
50372        self
50373    }
50374
50375    /// Identifies the authorization scope for the method you are building.
50376    ///
50377    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
50378    /// [`Scope::Dfatrafficking`].
50379    ///
50380    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
50381    /// tokens for more than one scope.
50382    ///
50383    /// Usually there is more than one suitable scope to authorize an operation, some of which may
50384    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
50385    /// sufficient, a read-write scope will do as well.
50386    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityUpdateCall<'a, C>
50387    where
50388        St: AsRef<str>,
50389    {
50390        self._scopes.insert(String::from(scope.as_ref()));
50391        self
50392    }
50393    /// Identifies the authorization scope(s) for the method you are building.
50394    ///
50395    /// See [`Self::add_scope()`] for details.
50396    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityUpdateCall<'a, C>
50397    where
50398        I: IntoIterator<Item = St>,
50399        St: AsRef<str>,
50400    {
50401        self._scopes
50402            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
50403        self
50404    }
50405
50406    /// Removes all scopes, and no default scope will be used either.
50407    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
50408    /// for details).
50409    pub fn clear_scopes(mut self) -> FloodlightActivityUpdateCall<'a, C> {
50410        self._scopes.clear();
50411        self
50412    }
50413}
50414
50415/// Gets one floodlight activity group by ID.
50416///
50417/// A builder for the *get* method supported by a *floodlightActivityGroup* resource.
50418/// It is not used directly, but through a [`FloodlightActivityGroupMethods`] instance.
50419///
50420/// # Example
50421///
50422/// Instantiate a resource method builder
50423///
50424/// ```test_harness,no_run
50425/// # extern crate hyper;
50426/// # extern crate hyper_rustls;
50427/// # extern crate google_dfareporting3d2 as dfareporting3d2;
50428/// # async fn dox() {
50429/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
50430///
50431/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
50432/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
50433/// #     secret,
50434/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
50435/// # ).build().await.unwrap();
50436///
50437/// # let client = hyper_util::client::legacy::Client::builder(
50438/// #     hyper_util::rt::TokioExecutor::new()
50439/// # )
50440/// # .build(
50441/// #     hyper_rustls::HttpsConnectorBuilder::new()
50442/// #         .with_native_roots()
50443/// #         .unwrap()
50444/// #         .https_or_http()
50445/// #         .enable_http1()
50446/// #         .build()
50447/// # );
50448/// # let mut hub = Dfareporting::new(client, auth);
50449/// // You can configure optional parameters by calling the respective setters at will, and
50450/// // execute the final call using `doit()`.
50451/// // Values shown here are possibly random and not representative !
50452/// let result = hub.floodlight_activity_groups().get(-31, -20)
50453///              .doit().await;
50454/// # }
50455/// ```
50456pub struct FloodlightActivityGroupGetCall<'a, C>
50457where
50458    C: 'a,
50459{
50460    hub: &'a Dfareporting<C>,
50461    _profile_id: i64,
50462    _id: i64,
50463    _delegate: Option<&'a mut dyn common::Delegate>,
50464    _additional_params: HashMap<String, String>,
50465    _scopes: BTreeSet<String>,
50466}
50467
50468impl<'a, C> common::CallBuilder for FloodlightActivityGroupGetCall<'a, C> {}
50469
50470impl<'a, C> FloodlightActivityGroupGetCall<'a, C>
50471where
50472    C: common::Connector,
50473{
50474    /// Perform the operation you have build so far.
50475    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivityGroup)> {
50476        use std::borrow::Cow;
50477        use std::io::{Read, Seek};
50478
50479        use common::{url::Params, ToParts};
50480        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
50481
50482        let mut dd = common::DefaultDelegate;
50483        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
50484        dlg.begin(common::MethodInfo {
50485            id: "dfareporting.floodlightActivityGroups.get",
50486            http_method: hyper::Method::GET,
50487        });
50488
50489        for &field in ["alt", "profileId", "id"].iter() {
50490            if self._additional_params.contains_key(field) {
50491                dlg.finished(false);
50492                return Err(common::Error::FieldClash(field));
50493            }
50494        }
50495
50496        let mut params = Params::with_capacity(4 + self._additional_params.len());
50497        params.push("profileId", self._profile_id.to_string());
50498        params.push("id", self._id.to_string());
50499
50500        params.extend(self._additional_params.iter());
50501
50502        params.push("alt", "json");
50503        let mut url =
50504            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups/{id}";
50505        if self._scopes.is_empty() {
50506            self._scopes
50507                .insert(Scope::Dfatrafficking.as_ref().to_string());
50508        }
50509
50510        #[allow(clippy::single_element_loop)]
50511        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
50512            url = params.uri_replacement(url, param_name, find_this, false);
50513        }
50514        {
50515            let to_remove = ["id", "profileId"];
50516            params.remove_params(&to_remove);
50517        }
50518
50519        let url = params.parse_with_url(&url);
50520
50521        loop {
50522            let token = match self
50523                .hub
50524                .auth
50525                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
50526                .await
50527            {
50528                Ok(token) => token,
50529                Err(e) => match dlg.token(e) {
50530                    Ok(token) => token,
50531                    Err(e) => {
50532                        dlg.finished(false);
50533                        return Err(common::Error::MissingToken(e));
50534                    }
50535                },
50536            };
50537            let mut req_result = {
50538                let client = &self.hub.client;
50539                dlg.pre_request();
50540                let mut req_builder = hyper::Request::builder()
50541                    .method(hyper::Method::GET)
50542                    .uri(url.as_str())
50543                    .header(USER_AGENT, self.hub._user_agent.clone());
50544
50545                if let Some(token) = token.as_ref() {
50546                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
50547                }
50548
50549                let request = req_builder
50550                    .header(CONTENT_LENGTH, 0_u64)
50551                    .body(common::to_body::<String>(None));
50552
50553                client.request(request.unwrap()).await
50554            };
50555
50556            match req_result {
50557                Err(err) => {
50558                    if let common::Retry::After(d) = dlg.http_error(&err) {
50559                        sleep(d).await;
50560                        continue;
50561                    }
50562                    dlg.finished(false);
50563                    return Err(common::Error::HttpError(err));
50564                }
50565                Ok(res) => {
50566                    let (mut parts, body) = res.into_parts();
50567                    let mut body = common::Body::new(body);
50568                    if !parts.status.is_success() {
50569                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50570                        let error = serde_json::from_str(&common::to_string(&bytes));
50571                        let response = common::to_response(parts, bytes.into());
50572
50573                        if let common::Retry::After(d) =
50574                            dlg.http_failure(&response, error.as_ref().ok())
50575                        {
50576                            sleep(d).await;
50577                            continue;
50578                        }
50579
50580                        dlg.finished(false);
50581
50582                        return Err(match error {
50583                            Ok(value) => common::Error::BadRequest(value),
50584                            _ => common::Error::Failure(response),
50585                        });
50586                    }
50587                    let response = {
50588                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50589                        let encoded = common::to_string(&bytes);
50590                        match serde_json::from_str(&encoded) {
50591                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
50592                            Err(error) => {
50593                                dlg.response_json_decode_error(&encoded, &error);
50594                                return Err(common::Error::JsonDecodeError(
50595                                    encoded.to_string(),
50596                                    error,
50597                                ));
50598                            }
50599                        }
50600                    };
50601
50602                    dlg.finished(true);
50603                    return Ok(response);
50604                }
50605            }
50606        }
50607    }
50608
50609    /// User profile ID associated with this request.
50610    ///
50611    /// Sets the *profile id* path property to the given value.
50612    ///
50613    /// Even though the property as already been set when instantiating this call,
50614    /// we provide this method for API completeness.
50615    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGroupGetCall<'a, C> {
50616        self._profile_id = new_value;
50617        self
50618    }
50619    /// Floodlight activity Group ID.
50620    ///
50621    /// Sets the *id* path property to the given value.
50622    ///
50623    /// Even though the property as already been set when instantiating this call,
50624    /// we provide this method for API completeness.
50625    pub fn id(mut self, new_value: i64) -> FloodlightActivityGroupGetCall<'a, C> {
50626        self._id = new_value;
50627        self
50628    }
50629    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
50630    /// while executing the actual API request.
50631    ///
50632    /// ````text
50633    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
50634    /// ````
50635    ///
50636    /// Sets the *delegate* property to the given value.
50637    pub fn delegate(
50638        mut self,
50639        new_value: &'a mut dyn common::Delegate,
50640    ) -> FloodlightActivityGroupGetCall<'a, C> {
50641        self._delegate = Some(new_value);
50642        self
50643    }
50644
50645    /// Set any additional parameter of the query string used in the request.
50646    /// It should be used to set parameters which are not yet available through their own
50647    /// setters.
50648    ///
50649    /// Please note that this method must not be used to set any of the known parameters
50650    /// which have their own setter method. If done anyway, the request will fail.
50651    ///
50652    /// # Additional Parameters
50653    ///
50654    /// * *alt* (query-string) - Data format for the response.
50655    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
50656    /// * *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.
50657    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
50658    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
50659    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
50660    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
50661    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGroupGetCall<'a, C>
50662    where
50663        T: AsRef<str>,
50664    {
50665        self._additional_params
50666            .insert(name.as_ref().to_string(), value.as_ref().to_string());
50667        self
50668    }
50669
50670    /// Identifies the authorization scope for the method you are building.
50671    ///
50672    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
50673    /// [`Scope::Dfatrafficking`].
50674    ///
50675    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
50676    /// tokens for more than one scope.
50677    ///
50678    /// Usually there is more than one suitable scope to authorize an operation, some of which may
50679    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
50680    /// sufficient, a read-write scope will do as well.
50681    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGroupGetCall<'a, C>
50682    where
50683        St: AsRef<str>,
50684    {
50685        self._scopes.insert(String::from(scope.as_ref()));
50686        self
50687    }
50688    /// Identifies the authorization scope(s) for the method you are building.
50689    ///
50690    /// See [`Self::add_scope()`] for details.
50691    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGroupGetCall<'a, C>
50692    where
50693        I: IntoIterator<Item = St>,
50694        St: AsRef<str>,
50695    {
50696        self._scopes
50697            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
50698        self
50699    }
50700
50701    /// Removes all scopes, and no default scope will be used either.
50702    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
50703    /// for details).
50704    pub fn clear_scopes(mut self) -> FloodlightActivityGroupGetCall<'a, C> {
50705        self._scopes.clear();
50706        self
50707    }
50708}
50709
50710/// Inserts a new floodlight activity group.
50711///
50712/// A builder for the *insert* method supported by a *floodlightActivityGroup* resource.
50713/// It is not used directly, but through a [`FloodlightActivityGroupMethods`] instance.
50714///
50715/// # Example
50716///
50717/// Instantiate a resource method builder
50718///
50719/// ```test_harness,no_run
50720/// # extern crate hyper;
50721/// # extern crate hyper_rustls;
50722/// # extern crate google_dfareporting3d2 as dfareporting3d2;
50723/// use dfareporting3d2::api::FloodlightActivityGroup;
50724/// # async fn dox() {
50725/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
50726///
50727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
50728/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
50729/// #     secret,
50730/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
50731/// # ).build().await.unwrap();
50732///
50733/// # let client = hyper_util::client::legacy::Client::builder(
50734/// #     hyper_util::rt::TokioExecutor::new()
50735/// # )
50736/// # .build(
50737/// #     hyper_rustls::HttpsConnectorBuilder::new()
50738/// #         .with_native_roots()
50739/// #         .unwrap()
50740/// #         .https_or_http()
50741/// #         .enable_http1()
50742/// #         .build()
50743/// # );
50744/// # let mut hub = Dfareporting::new(client, auth);
50745/// // As the method needs a request, you would usually fill it with the desired information
50746/// // into the respective structure. Some of the parts shown here might not be applicable !
50747/// // Values shown here are possibly random and not representative !
50748/// let mut req = FloodlightActivityGroup::default();
50749///
50750/// // You can configure optional parameters by calling the respective setters at will, and
50751/// // execute the final call using `doit()`.
50752/// // Values shown here are possibly random and not representative !
50753/// let result = hub.floodlight_activity_groups().insert(req, -35)
50754///              .doit().await;
50755/// # }
50756/// ```
50757pub struct FloodlightActivityGroupInsertCall<'a, C>
50758where
50759    C: 'a,
50760{
50761    hub: &'a Dfareporting<C>,
50762    _request: FloodlightActivityGroup,
50763    _profile_id: i64,
50764    _delegate: Option<&'a mut dyn common::Delegate>,
50765    _additional_params: HashMap<String, String>,
50766    _scopes: BTreeSet<String>,
50767}
50768
50769impl<'a, C> common::CallBuilder for FloodlightActivityGroupInsertCall<'a, C> {}
50770
50771impl<'a, C> FloodlightActivityGroupInsertCall<'a, C>
50772where
50773    C: common::Connector,
50774{
50775    /// Perform the operation you have build so far.
50776    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivityGroup)> {
50777        use std::borrow::Cow;
50778        use std::io::{Read, Seek};
50779
50780        use common::{url::Params, ToParts};
50781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
50782
50783        let mut dd = common::DefaultDelegate;
50784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
50785        dlg.begin(common::MethodInfo {
50786            id: "dfareporting.floodlightActivityGroups.insert",
50787            http_method: hyper::Method::POST,
50788        });
50789
50790        for &field in ["alt", "profileId"].iter() {
50791            if self._additional_params.contains_key(field) {
50792                dlg.finished(false);
50793                return Err(common::Error::FieldClash(field));
50794            }
50795        }
50796
50797        let mut params = Params::with_capacity(4 + self._additional_params.len());
50798        params.push("profileId", self._profile_id.to_string());
50799
50800        params.extend(self._additional_params.iter());
50801
50802        params.push("alt", "json");
50803        let mut url =
50804            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups";
50805        if self._scopes.is_empty() {
50806            self._scopes
50807                .insert(Scope::Dfatrafficking.as_ref().to_string());
50808        }
50809
50810        #[allow(clippy::single_element_loop)]
50811        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
50812            url = params.uri_replacement(url, param_name, find_this, false);
50813        }
50814        {
50815            let to_remove = ["profileId"];
50816            params.remove_params(&to_remove);
50817        }
50818
50819        let url = params.parse_with_url(&url);
50820
50821        let mut json_mime_type = mime::APPLICATION_JSON;
50822        let mut request_value_reader = {
50823            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
50824            common::remove_json_null_values(&mut value);
50825            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
50826            serde_json::to_writer(&mut dst, &value).unwrap();
50827            dst
50828        };
50829        let request_size = request_value_reader
50830            .seek(std::io::SeekFrom::End(0))
50831            .unwrap();
50832        request_value_reader
50833            .seek(std::io::SeekFrom::Start(0))
50834            .unwrap();
50835
50836        loop {
50837            let token = match self
50838                .hub
50839                .auth
50840                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
50841                .await
50842            {
50843                Ok(token) => token,
50844                Err(e) => match dlg.token(e) {
50845                    Ok(token) => token,
50846                    Err(e) => {
50847                        dlg.finished(false);
50848                        return Err(common::Error::MissingToken(e));
50849                    }
50850                },
50851            };
50852            request_value_reader
50853                .seek(std::io::SeekFrom::Start(0))
50854                .unwrap();
50855            let mut req_result = {
50856                let client = &self.hub.client;
50857                dlg.pre_request();
50858                let mut req_builder = hyper::Request::builder()
50859                    .method(hyper::Method::POST)
50860                    .uri(url.as_str())
50861                    .header(USER_AGENT, self.hub._user_agent.clone());
50862
50863                if let Some(token) = token.as_ref() {
50864                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
50865                }
50866
50867                let request = req_builder
50868                    .header(CONTENT_TYPE, json_mime_type.to_string())
50869                    .header(CONTENT_LENGTH, request_size as u64)
50870                    .body(common::to_body(
50871                        request_value_reader.get_ref().clone().into(),
50872                    ));
50873
50874                client.request(request.unwrap()).await
50875            };
50876
50877            match req_result {
50878                Err(err) => {
50879                    if let common::Retry::After(d) = dlg.http_error(&err) {
50880                        sleep(d).await;
50881                        continue;
50882                    }
50883                    dlg.finished(false);
50884                    return Err(common::Error::HttpError(err));
50885                }
50886                Ok(res) => {
50887                    let (mut parts, body) = res.into_parts();
50888                    let mut body = common::Body::new(body);
50889                    if !parts.status.is_success() {
50890                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50891                        let error = serde_json::from_str(&common::to_string(&bytes));
50892                        let response = common::to_response(parts, bytes.into());
50893
50894                        if let common::Retry::After(d) =
50895                            dlg.http_failure(&response, error.as_ref().ok())
50896                        {
50897                            sleep(d).await;
50898                            continue;
50899                        }
50900
50901                        dlg.finished(false);
50902
50903                        return Err(match error {
50904                            Ok(value) => common::Error::BadRequest(value),
50905                            _ => common::Error::Failure(response),
50906                        });
50907                    }
50908                    let response = {
50909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
50910                        let encoded = common::to_string(&bytes);
50911                        match serde_json::from_str(&encoded) {
50912                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
50913                            Err(error) => {
50914                                dlg.response_json_decode_error(&encoded, &error);
50915                                return Err(common::Error::JsonDecodeError(
50916                                    encoded.to_string(),
50917                                    error,
50918                                ));
50919                            }
50920                        }
50921                    };
50922
50923                    dlg.finished(true);
50924                    return Ok(response);
50925                }
50926            }
50927        }
50928    }
50929
50930    ///
50931    /// Sets the *request* property to the given value.
50932    ///
50933    /// Even though the property as already been set when instantiating this call,
50934    /// we provide this method for API completeness.
50935    pub fn request(
50936        mut self,
50937        new_value: FloodlightActivityGroup,
50938    ) -> FloodlightActivityGroupInsertCall<'a, C> {
50939        self._request = new_value;
50940        self
50941    }
50942    /// User profile ID associated with this request.
50943    ///
50944    /// Sets the *profile id* path property to the given value.
50945    ///
50946    /// Even though the property as already been set when instantiating this call,
50947    /// we provide this method for API completeness.
50948    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGroupInsertCall<'a, C> {
50949        self._profile_id = new_value;
50950        self
50951    }
50952    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
50953    /// while executing the actual API request.
50954    ///
50955    /// ````text
50956    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
50957    /// ````
50958    ///
50959    /// Sets the *delegate* property to the given value.
50960    pub fn delegate(
50961        mut self,
50962        new_value: &'a mut dyn common::Delegate,
50963    ) -> FloodlightActivityGroupInsertCall<'a, C> {
50964        self._delegate = Some(new_value);
50965        self
50966    }
50967
50968    /// Set any additional parameter of the query string used in the request.
50969    /// It should be used to set parameters which are not yet available through their own
50970    /// setters.
50971    ///
50972    /// Please note that this method must not be used to set any of the known parameters
50973    /// which have their own setter method. If done anyway, the request will fail.
50974    ///
50975    /// # Additional Parameters
50976    ///
50977    /// * *alt* (query-string) - Data format for the response.
50978    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
50979    /// * *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.
50980    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
50981    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
50982    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
50983    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
50984    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGroupInsertCall<'a, C>
50985    where
50986        T: AsRef<str>,
50987    {
50988        self._additional_params
50989            .insert(name.as_ref().to_string(), value.as_ref().to_string());
50990        self
50991    }
50992
50993    /// Identifies the authorization scope for the method you are building.
50994    ///
50995    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
50996    /// [`Scope::Dfatrafficking`].
50997    ///
50998    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
50999    /// tokens for more than one scope.
51000    ///
51001    /// Usually there is more than one suitable scope to authorize an operation, some of which may
51002    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
51003    /// sufficient, a read-write scope will do as well.
51004    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGroupInsertCall<'a, C>
51005    where
51006        St: AsRef<str>,
51007    {
51008        self._scopes.insert(String::from(scope.as_ref()));
51009        self
51010    }
51011    /// Identifies the authorization scope(s) for the method you are building.
51012    ///
51013    /// See [`Self::add_scope()`] for details.
51014    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGroupInsertCall<'a, C>
51015    where
51016        I: IntoIterator<Item = St>,
51017        St: AsRef<str>,
51018    {
51019        self._scopes
51020            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
51021        self
51022    }
51023
51024    /// Removes all scopes, and no default scope will be used either.
51025    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
51026    /// for details).
51027    pub fn clear_scopes(mut self) -> FloodlightActivityGroupInsertCall<'a, C> {
51028        self._scopes.clear();
51029        self
51030    }
51031}
51032
51033/// Retrieves a list of floodlight activity groups, possibly filtered. This method supports paging.
51034///
51035/// A builder for the *list* method supported by a *floodlightActivityGroup* resource.
51036/// It is not used directly, but through a [`FloodlightActivityGroupMethods`] instance.
51037///
51038/// # Example
51039///
51040/// Instantiate a resource method builder
51041///
51042/// ```test_harness,no_run
51043/// # extern crate hyper;
51044/// # extern crate hyper_rustls;
51045/// # extern crate google_dfareporting3d2 as dfareporting3d2;
51046/// # async fn dox() {
51047/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
51048///
51049/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
51050/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
51051/// #     secret,
51052/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
51053/// # ).build().await.unwrap();
51054///
51055/// # let client = hyper_util::client::legacy::Client::builder(
51056/// #     hyper_util::rt::TokioExecutor::new()
51057/// # )
51058/// # .build(
51059/// #     hyper_rustls::HttpsConnectorBuilder::new()
51060/// #         .with_native_roots()
51061/// #         .unwrap()
51062/// #         .https_or_http()
51063/// #         .enable_http1()
51064/// #         .build()
51065/// # );
51066/// # let mut hub = Dfareporting::new(client, auth);
51067/// // You can configure optional parameters by calling the respective setters at will, and
51068/// // execute the final call using `doit()`.
51069/// // Values shown here are possibly random and not representative !
51070/// let result = hub.floodlight_activity_groups().list(-1)
51071///              .type_("erat")
51072///              .sort_order("sit")
51073///              .sort_field("accusam")
51074///              .search_string("et")
51075///              .page_token("nonumy")
51076///              .max_results(-73)
51077///              .add_ids(-37)
51078///              .floodlight_configuration_id(-78)
51079///              .advertiser_id(-46)
51080///              .doit().await;
51081/// # }
51082/// ```
51083pub struct FloodlightActivityGroupListCall<'a, C>
51084where
51085    C: 'a,
51086{
51087    hub: &'a Dfareporting<C>,
51088    _profile_id: i64,
51089    _type_: Option<String>,
51090    _sort_order: Option<String>,
51091    _sort_field: Option<String>,
51092    _search_string: Option<String>,
51093    _page_token: Option<String>,
51094    _max_results: Option<i32>,
51095    _ids: Vec<i64>,
51096    _floodlight_configuration_id: Option<i64>,
51097    _advertiser_id: Option<i64>,
51098    _delegate: Option<&'a mut dyn common::Delegate>,
51099    _additional_params: HashMap<String, String>,
51100    _scopes: BTreeSet<String>,
51101}
51102
51103impl<'a, C> common::CallBuilder for FloodlightActivityGroupListCall<'a, C> {}
51104
51105impl<'a, C> FloodlightActivityGroupListCall<'a, C>
51106where
51107    C: common::Connector,
51108{
51109    /// Perform the operation you have build so far.
51110    pub async fn doit(
51111        mut self,
51112    ) -> common::Result<(common::Response, FloodlightActivityGroupsListResponse)> {
51113        use std::borrow::Cow;
51114        use std::io::{Read, Seek};
51115
51116        use common::{url::Params, ToParts};
51117        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
51118
51119        let mut dd = common::DefaultDelegate;
51120        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
51121        dlg.begin(common::MethodInfo {
51122            id: "dfareporting.floodlightActivityGroups.list",
51123            http_method: hyper::Method::GET,
51124        });
51125
51126        for &field in [
51127            "alt",
51128            "profileId",
51129            "type",
51130            "sortOrder",
51131            "sortField",
51132            "searchString",
51133            "pageToken",
51134            "maxResults",
51135            "ids",
51136            "floodlightConfigurationId",
51137            "advertiserId",
51138        ]
51139        .iter()
51140        {
51141            if self._additional_params.contains_key(field) {
51142                dlg.finished(false);
51143                return Err(common::Error::FieldClash(field));
51144            }
51145        }
51146
51147        let mut params = Params::with_capacity(12 + self._additional_params.len());
51148        params.push("profileId", self._profile_id.to_string());
51149        if let Some(value) = self._type_.as_ref() {
51150            params.push("type", value);
51151        }
51152        if let Some(value) = self._sort_order.as_ref() {
51153            params.push("sortOrder", value);
51154        }
51155        if let Some(value) = self._sort_field.as_ref() {
51156            params.push("sortField", value);
51157        }
51158        if let Some(value) = self._search_string.as_ref() {
51159            params.push("searchString", value);
51160        }
51161        if let Some(value) = self._page_token.as_ref() {
51162            params.push("pageToken", value);
51163        }
51164        if let Some(value) = self._max_results.as_ref() {
51165            params.push("maxResults", value.to_string());
51166        }
51167        if !self._ids.is_empty() {
51168            for f in self._ids.iter() {
51169                params.push("ids", f.to_string());
51170            }
51171        }
51172        if let Some(value) = self._floodlight_configuration_id.as_ref() {
51173            params.push("floodlightConfigurationId", value.to_string());
51174        }
51175        if let Some(value) = self._advertiser_id.as_ref() {
51176            params.push("advertiserId", value.to_string());
51177        }
51178
51179        params.extend(self._additional_params.iter());
51180
51181        params.push("alt", "json");
51182        let mut url =
51183            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups";
51184        if self._scopes.is_empty() {
51185            self._scopes
51186                .insert(Scope::Dfatrafficking.as_ref().to_string());
51187        }
51188
51189        #[allow(clippy::single_element_loop)]
51190        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
51191            url = params.uri_replacement(url, param_name, find_this, false);
51192        }
51193        {
51194            let to_remove = ["profileId"];
51195            params.remove_params(&to_remove);
51196        }
51197
51198        let url = params.parse_with_url(&url);
51199
51200        loop {
51201            let token = match self
51202                .hub
51203                .auth
51204                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
51205                .await
51206            {
51207                Ok(token) => token,
51208                Err(e) => match dlg.token(e) {
51209                    Ok(token) => token,
51210                    Err(e) => {
51211                        dlg.finished(false);
51212                        return Err(common::Error::MissingToken(e));
51213                    }
51214                },
51215            };
51216            let mut req_result = {
51217                let client = &self.hub.client;
51218                dlg.pre_request();
51219                let mut req_builder = hyper::Request::builder()
51220                    .method(hyper::Method::GET)
51221                    .uri(url.as_str())
51222                    .header(USER_AGENT, self.hub._user_agent.clone());
51223
51224                if let Some(token) = token.as_ref() {
51225                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
51226                }
51227
51228                let request = req_builder
51229                    .header(CONTENT_LENGTH, 0_u64)
51230                    .body(common::to_body::<String>(None));
51231
51232                client.request(request.unwrap()).await
51233            };
51234
51235            match req_result {
51236                Err(err) => {
51237                    if let common::Retry::After(d) = dlg.http_error(&err) {
51238                        sleep(d).await;
51239                        continue;
51240                    }
51241                    dlg.finished(false);
51242                    return Err(common::Error::HttpError(err));
51243                }
51244                Ok(res) => {
51245                    let (mut parts, body) = res.into_parts();
51246                    let mut body = common::Body::new(body);
51247                    if !parts.status.is_success() {
51248                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51249                        let error = serde_json::from_str(&common::to_string(&bytes));
51250                        let response = common::to_response(parts, bytes.into());
51251
51252                        if let common::Retry::After(d) =
51253                            dlg.http_failure(&response, error.as_ref().ok())
51254                        {
51255                            sleep(d).await;
51256                            continue;
51257                        }
51258
51259                        dlg.finished(false);
51260
51261                        return Err(match error {
51262                            Ok(value) => common::Error::BadRequest(value),
51263                            _ => common::Error::Failure(response),
51264                        });
51265                    }
51266                    let response = {
51267                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51268                        let encoded = common::to_string(&bytes);
51269                        match serde_json::from_str(&encoded) {
51270                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
51271                            Err(error) => {
51272                                dlg.response_json_decode_error(&encoded, &error);
51273                                return Err(common::Error::JsonDecodeError(
51274                                    encoded.to_string(),
51275                                    error,
51276                                ));
51277                            }
51278                        }
51279                    };
51280
51281                    dlg.finished(true);
51282                    return Ok(response);
51283                }
51284            }
51285        }
51286    }
51287
51288    /// User profile ID associated with this request.
51289    ///
51290    /// Sets the *profile id* path property to the given value.
51291    ///
51292    /// Even though the property as already been set when instantiating this call,
51293    /// we provide this method for API completeness.
51294    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGroupListCall<'a, C> {
51295        self._profile_id = new_value;
51296        self
51297    }
51298    /// Select only floodlight activity groups with the specified floodlight activity group type.
51299    ///
51300    /// Sets the *type* query property to the given value.
51301    pub fn type_(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C> {
51302        self._type_ = Some(new_value.to_string());
51303        self
51304    }
51305    /// Order of sorted results.
51306    ///
51307    /// Sets the *sort order* query property to the given value.
51308    pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C> {
51309        self._sort_order = Some(new_value.to_string());
51310        self
51311    }
51312    /// Field by which to sort the list.
51313    ///
51314    /// Sets the *sort field* query property to the given value.
51315    pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C> {
51316        self._sort_field = Some(new_value.to_string());
51317        self
51318    }
51319    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "floodlightactivitygroup*2015" will return objects with names like "floodlightactivitygroup June 2015", "floodlightactivitygroup April 2015", or simply "floodlightactivitygroup 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "floodlightactivitygroup" will match objects with name "my floodlightactivitygroup activity", "floodlightactivitygroup 2015", or simply "floodlightactivitygroup".
51320    ///
51321    /// Sets the *search string* query property to the given value.
51322    pub fn search_string(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C> {
51323        self._search_string = Some(new_value.to_string());
51324        self
51325    }
51326    /// Value of the nextPageToken from the previous result page.
51327    ///
51328    /// Sets the *page token* query property to the given value.
51329    pub fn page_token(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, C> {
51330        self._page_token = Some(new_value.to_string());
51331        self
51332    }
51333    /// Maximum number of results to return.
51334    ///
51335    /// Sets the *max results* query property to the given value.
51336    pub fn max_results(mut self, new_value: i32) -> FloodlightActivityGroupListCall<'a, C> {
51337        self._max_results = Some(new_value);
51338        self
51339    }
51340    /// Select only floodlight activity groups with the specified IDs. Must specify either advertiserId or floodlightConfigurationId for a non-empty result.
51341    ///
51342    /// Append the given value to the *ids* query property.
51343    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
51344    pub fn add_ids(mut self, new_value: i64) -> FloodlightActivityGroupListCall<'a, C> {
51345        self._ids.push(new_value);
51346        self
51347    }
51348    /// Select only floodlight activity groups with the specified floodlight configuration ID. Must specify either advertiserId, or floodlightConfigurationId for a non-empty result.
51349    ///
51350    /// Sets the *floodlight configuration id* query property to the given value.
51351    pub fn floodlight_configuration_id(
51352        mut self,
51353        new_value: i64,
51354    ) -> FloodlightActivityGroupListCall<'a, C> {
51355        self._floodlight_configuration_id = Some(new_value);
51356        self
51357    }
51358    /// Select only floodlight activity groups with the specified advertiser ID. Must specify either advertiserId or floodlightConfigurationId for a non-empty result.
51359    ///
51360    /// Sets the *advertiser id* query property to the given value.
51361    pub fn advertiser_id(mut self, new_value: i64) -> FloodlightActivityGroupListCall<'a, C> {
51362        self._advertiser_id = Some(new_value);
51363        self
51364    }
51365    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
51366    /// while executing the actual API request.
51367    ///
51368    /// ````text
51369    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
51370    /// ````
51371    ///
51372    /// Sets the *delegate* property to the given value.
51373    pub fn delegate(
51374        mut self,
51375        new_value: &'a mut dyn common::Delegate,
51376    ) -> FloodlightActivityGroupListCall<'a, C> {
51377        self._delegate = Some(new_value);
51378        self
51379    }
51380
51381    /// Set any additional parameter of the query string used in the request.
51382    /// It should be used to set parameters which are not yet available through their own
51383    /// setters.
51384    ///
51385    /// Please note that this method must not be used to set any of the known parameters
51386    /// which have their own setter method. If done anyway, the request will fail.
51387    ///
51388    /// # Additional Parameters
51389    ///
51390    /// * *alt* (query-string) - Data format for the response.
51391    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
51392    /// * *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.
51393    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
51394    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
51395    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
51396    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
51397    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGroupListCall<'a, C>
51398    where
51399        T: AsRef<str>,
51400    {
51401        self._additional_params
51402            .insert(name.as_ref().to_string(), value.as_ref().to_string());
51403        self
51404    }
51405
51406    /// Identifies the authorization scope for the method you are building.
51407    ///
51408    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
51409    /// [`Scope::Dfatrafficking`].
51410    ///
51411    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
51412    /// tokens for more than one scope.
51413    ///
51414    /// Usually there is more than one suitable scope to authorize an operation, some of which may
51415    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
51416    /// sufficient, a read-write scope will do as well.
51417    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGroupListCall<'a, C>
51418    where
51419        St: AsRef<str>,
51420    {
51421        self._scopes.insert(String::from(scope.as_ref()));
51422        self
51423    }
51424    /// Identifies the authorization scope(s) for the method you are building.
51425    ///
51426    /// See [`Self::add_scope()`] for details.
51427    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGroupListCall<'a, C>
51428    where
51429        I: IntoIterator<Item = St>,
51430        St: AsRef<str>,
51431    {
51432        self._scopes
51433            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
51434        self
51435    }
51436
51437    /// Removes all scopes, and no default scope will be used either.
51438    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
51439    /// for details).
51440    pub fn clear_scopes(mut self) -> FloodlightActivityGroupListCall<'a, C> {
51441        self._scopes.clear();
51442        self
51443    }
51444}
51445
51446/// Updates an existing floodlight activity group. This method supports patch semantics.
51447///
51448/// A builder for the *patch* method supported by a *floodlightActivityGroup* resource.
51449/// It is not used directly, but through a [`FloodlightActivityGroupMethods`] instance.
51450///
51451/// # Example
51452///
51453/// Instantiate a resource method builder
51454///
51455/// ```test_harness,no_run
51456/// # extern crate hyper;
51457/// # extern crate hyper_rustls;
51458/// # extern crate google_dfareporting3d2 as dfareporting3d2;
51459/// use dfareporting3d2::api::FloodlightActivityGroup;
51460/// # async fn dox() {
51461/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
51462///
51463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
51464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
51465/// #     secret,
51466/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
51467/// # ).build().await.unwrap();
51468///
51469/// # let client = hyper_util::client::legacy::Client::builder(
51470/// #     hyper_util::rt::TokioExecutor::new()
51471/// # )
51472/// # .build(
51473/// #     hyper_rustls::HttpsConnectorBuilder::new()
51474/// #         .with_native_roots()
51475/// #         .unwrap()
51476/// #         .https_or_http()
51477/// #         .enable_http1()
51478/// #         .build()
51479/// # );
51480/// # let mut hub = Dfareporting::new(client, auth);
51481/// // As the method needs a request, you would usually fill it with the desired information
51482/// // into the respective structure. Some of the parts shown here might not be applicable !
51483/// // Values shown here are possibly random and not representative !
51484/// let mut req = FloodlightActivityGroup::default();
51485///
51486/// // You can configure optional parameters by calling the respective setters at will, and
51487/// // execute the final call using `doit()`.
51488/// // Values shown here are possibly random and not representative !
51489/// let result = hub.floodlight_activity_groups().patch(req, -99, -47)
51490///              .doit().await;
51491/// # }
51492/// ```
51493pub struct FloodlightActivityGroupPatchCall<'a, C>
51494where
51495    C: 'a,
51496{
51497    hub: &'a Dfareporting<C>,
51498    _request: FloodlightActivityGroup,
51499    _profile_id: i64,
51500    _id: i64,
51501    _delegate: Option<&'a mut dyn common::Delegate>,
51502    _additional_params: HashMap<String, String>,
51503    _scopes: BTreeSet<String>,
51504}
51505
51506impl<'a, C> common::CallBuilder for FloodlightActivityGroupPatchCall<'a, C> {}
51507
51508impl<'a, C> FloodlightActivityGroupPatchCall<'a, C>
51509where
51510    C: common::Connector,
51511{
51512    /// Perform the operation you have build so far.
51513    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivityGroup)> {
51514        use std::borrow::Cow;
51515        use std::io::{Read, Seek};
51516
51517        use common::{url::Params, ToParts};
51518        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
51519
51520        let mut dd = common::DefaultDelegate;
51521        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
51522        dlg.begin(common::MethodInfo {
51523            id: "dfareporting.floodlightActivityGroups.patch",
51524            http_method: hyper::Method::PATCH,
51525        });
51526
51527        for &field in ["alt", "profileId", "id"].iter() {
51528            if self._additional_params.contains_key(field) {
51529                dlg.finished(false);
51530                return Err(common::Error::FieldClash(field));
51531            }
51532        }
51533
51534        let mut params = Params::with_capacity(5 + self._additional_params.len());
51535        params.push("profileId", self._profile_id.to_string());
51536        params.push("id", self._id.to_string());
51537
51538        params.extend(self._additional_params.iter());
51539
51540        params.push("alt", "json");
51541        let mut url =
51542            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups";
51543        if self._scopes.is_empty() {
51544            self._scopes
51545                .insert(Scope::Dfatrafficking.as_ref().to_string());
51546        }
51547
51548        #[allow(clippy::single_element_loop)]
51549        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
51550            url = params.uri_replacement(url, param_name, find_this, false);
51551        }
51552        {
51553            let to_remove = ["profileId"];
51554            params.remove_params(&to_remove);
51555        }
51556
51557        let url = params.parse_with_url(&url);
51558
51559        let mut json_mime_type = mime::APPLICATION_JSON;
51560        let mut request_value_reader = {
51561            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
51562            common::remove_json_null_values(&mut value);
51563            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
51564            serde_json::to_writer(&mut dst, &value).unwrap();
51565            dst
51566        };
51567        let request_size = request_value_reader
51568            .seek(std::io::SeekFrom::End(0))
51569            .unwrap();
51570        request_value_reader
51571            .seek(std::io::SeekFrom::Start(0))
51572            .unwrap();
51573
51574        loop {
51575            let token = match self
51576                .hub
51577                .auth
51578                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
51579                .await
51580            {
51581                Ok(token) => token,
51582                Err(e) => match dlg.token(e) {
51583                    Ok(token) => token,
51584                    Err(e) => {
51585                        dlg.finished(false);
51586                        return Err(common::Error::MissingToken(e));
51587                    }
51588                },
51589            };
51590            request_value_reader
51591                .seek(std::io::SeekFrom::Start(0))
51592                .unwrap();
51593            let mut req_result = {
51594                let client = &self.hub.client;
51595                dlg.pre_request();
51596                let mut req_builder = hyper::Request::builder()
51597                    .method(hyper::Method::PATCH)
51598                    .uri(url.as_str())
51599                    .header(USER_AGENT, self.hub._user_agent.clone());
51600
51601                if let Some(token) = token.as_ref() {
51602                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
51603                }
51604
51605                let request = req_builder
51606                    .header(CONTENT_TYPE, json_mime_type.to_string())
51607                    .header(CONTENT_LENGTH, request_size as u64)
51608                    .body(common::to_body(
51609                        request_value_reader.get_ref().clone().into(),
51610                    ));
51611
51612                client.request(request.unwrap()).await
51613            };
51614
51615            match req_result {
51616                Err(err) => {
51617                    if let common::Retry::After(d) = dlg.http_error(&err) {
51618                        sleep(d).await;
51619                        continue;
51620                    }
51621                    dlg.finished(false);
51622                    return Err(common::Error::HttpError(err));
51623                }
51624                Ok(res) => {
51625                    let (mut parts, body) = res.into_parts();
51626                    let mut body = common::Body::new(body);
51627                    if !parts.status.is_success() {
51628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51629                        let error = serde_json::from_str(&common::to_string(&bytes));
51630                        let response = common::to_response(parts, bytes.into());
51631
51632                        if let common::Retry::After(d) =
51633                            dlg.http_failure(&response, error.as_ref().ok())
51634                        {
51635                            sleep(d).await;
51636                            continue;
51637                        }
51638
51639                        dlg.finished(false);
51640
51641                        return Err(match error {
51642                            Ok(value) => common::Error::BadRequest(value),
51643                            _ => common::Error::Failure(response),
51644                        });
51645                    }
51646                    let response = {
51647                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51648                        let encoded = common::to_string(&bytes);
51649                        match serde_json::from_str(&encoded) {
51650                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
51651                            Err(error) => {
51652                                dlg.response_json_decode_error(&encoded, &error);
51653                                return Err(common::Error::JsonDecodeError(
51654                                    encoded.to_string(),
51655                                    error,
51656                                ));
51657                            }
51658                        }
51659                    };
51660
51661                    dlg.finished(true);
51662                    return Ok(response);
51663                }
51664            }
51665        }
51666    }
51667
51668    ///
51669    /// Sets the *request* property to the given value.
51670    ///
51671    /// Even though the property as already been set when instantiating this call,
51672    /// we provide this method for API completeness.
51673    pub fn request(
51674        mut self,
51675        new_value: FloodlightActivityGroup,
51676    ) -> FloodlightActivityGroupPatchCall<'a, C> {
51677        self._request = new_value;
51678        self
51679    }
51680    /// User profile ID associated with this request.
51681    ///
51682    /// Sets the *profile id* path property to the given value.
51683    ///
51684    /// Even though the property as already been set when instantiating this call,
51685    /// we provide this method for API completeness.
51686    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGroupPatchCall<'a, C> {
51687        self._profile_id = new_value;
51688        self
51689    }
51690    /// Floodlight activity Group ID.
51691    ///
51692    /// Sets the *id* query property to the given value.
51693    ///
51694    /// Even though the property as already been set when instantiating this call,
51695    /// we provide this method for API completeness.
51696    pub fn id(mut self, new_value: i64) -> FloodlightActivityGroupPatchCall<'a, C> {
51697        self._id = new_value;
51698        self
51699    }
51700    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
51701    /// while executing the actual API request.
51702    ///
51703    /// ````text
51704    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
51705    /// ````
51706    ///
51707    /// Sets the *delegate* property to the given value.
51708    pub fn delegate(
51709        mut self,
51710        new_value: &'a mut dyn common::Delegate,
51711    ) -> FloodlightActivityGroupPatchCall<'a, C> {
51712        self._delegate = Some(new_value);
51713        self
51714    }
51715
51716    /// Set any additional parameter of the query string used in the request.
51717    /// It should be used to set parameters which are not yet available through their own
51718    /// setters.
51719    ///
51720    /// Please note that this method must not be used to set any of the known parameters
51721    /// which have their own setter method. If done anyway, the request will fail.
51722    ///
51723    /// # Additional Parameters
51724    ///
51725    /// * *alt* (query-string) - Data format for the response.
51726    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
51727    /// * *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.
51728    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
51729    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
51730    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
51731    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
51732    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGroupPatchCall<'a, C>
51733    where
51734        T: AsRef<str>,
51735    {
51736        self._additional_params
51737            .insert(name.as_ref().to_string(), value.as_ref().to_string());
51738        self
51739    }
51740
51741    /// Identifies the authorization scope for the method you are building.
51742    ///
51743    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
51744    /// [`Scope::Dfatrafficking`].
51745    ///
51746    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
51747    /// tokens for more than one scope.
51748    ///
51749    /// Usually there is more than one suitable scope to authorize an operation, some of which may
51750    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
51751    /// sufficient, a read-write scope will do as well.
51752    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGroupPatchCall<'a, C>
51753    where
51754        St: AsRef<str>,
51755    {
51756        self._scopes.insert(String::from(scope.as_ref()));
51757        self
51758    }
51759    /// Identifies the authorization scope(s) for the method you are building.
51760    ///
51761    /// See [`Self::add_scope()`] for details.
51762    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGroupPatchCall<'a, C>
51763    where
51764        I: IntoIterator<Item = St>,
51765        St: AsRef<str>,
51766    {
51767        self._scopes
51768            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
51769        self
51770    }
51771
51772    /// Removes all scopes, and no default scope will be used either.
51773    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
51774    /// for details).
51775    pub fn clear_scopes(mut self) -> FloodlightActivityGroupPatchCall<'a, C> {
51776        self._scopes.clear();
51777        self
51778    }
51779}
51780
51781/// Updates an existing floodlight activity group.
51782///
51783/// A builder for the *update* method supported by a *floodlightActivityGroup* resource.
51784/// It is not used directly, but through a [`FloodlightActivityGroupMethods`] instance.
51785///
51786/// # Example
51787///
51788/// Instantiate a resource method builder
51789///
51790/// ```test_harness,no_run
51791/// # extern crate hyper;
51792/// # extern crate hyper_rustls;
51793/// # extern crate google_dfareporting3d2 as dfareporting3d2;
51794/// use dfareporting3d2::api::FloodlightActivityGroup;
51795/// # async fn dox() {
51796/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
51797///
51798/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
51799/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
51800/// #     secret,
51801/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
51802/// # ).build().await.unwrap();
51803///
51804/// # let client = hyper_util::client::legacy::Client::builder(
51805/// #     hyper_util::rt::TokioExecutor::new()
51806/// # )
51807/// # .build(
51808/// #     hyper_rustls::HttpsConnectorBuilder::new()
51809/// #         .with_native_roots()
51810/// #         .unwrap()
51811/// #         .https_or_http()
51812/// #         .enable_http1()
51813/// #         .build()
51814/// # );
51815/// # let mut hub = Dfareporting::new(client, auth);
51816/// // As the method needs a request, you would usually fill it with the desired information
51817/// // into the respective structure. Some of the parts shown here might not be applicable !
51818/// // Values shown here are possibly random and not representative !
51819/// let mut req = FloodlightActivityGroup::default();
51820///
51821/// // You can configure optional parameters by calling the respective setters at will, and
51822/// // execute the final call using `doit()`.
51823/// // Values shown here are possibly random and not representative !
51824/// let result = hub.floodlight_activity_groups().update(req, -35)
51825///              .doit().await;
51826/// # }
51827/// ```
51828pub struct FloodlightActivityGroupUpdateCall<'a, C>
51829where
51830    C: 'a,
51831{
51832    hub: &'a Dfareporting<C>,
51833    _request: FloodlightActivityGroup,
51834    _profile_id: i64,
51835    _delegate: Option<&'a mut dyn common::Delegate>,
51836    _additional_params: HashMap<String, String>,
51837    _scopes: BTreeSet<String>,
51838}
51839
51840impl<'a, C> common::CallBuilder for FloodlightActivityGroupUpdateCall<'a, C> {}
51841
51842impl<'a, C> FloodlightActivityGroupUpdateCall<'a, C>
51843where
51844    C: common::Connector,
51845{
51846    /// Perform the operation you have build so far.
51847    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightActivityGroup)> {
51848        use std::borrow::Cow;
51849        use std::io::{Read, Seek};
51850
51851        use common::{url::Params, ToParts};
51852        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
51853
51854        let mut dd = common::DefaultDelegate;
51855        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
51856        dlg.begin(common::MethodInfo {
51857            id: "dfareporting.floodlightActivityGroups.update",
51858            http_method: hyper::Method::PUT,
51859        });
51860
51861        for &field in ["alt", "profileId"].iter() {
51862            if self._additional_params.contains_key(field) {
51863                dlg.finished(false);
51864                return Err(common::Error::FieldClash(field));
51865            }
51866        }
51867
51868        let mut params = Params::with_capacity(4 + self._additional_params.len());
51869        params.push("profileId", self._profile_id.to_string());
51870
51871        params.extend(self._additional_params.iter());
51872
51873        params.push("alt", "json");
51874        let mut url =
51875            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups";
51876        if self._scopes.is_empty() {
51877            self._scopes
51878                .insert(Scope::Dfatrafficking.as_ref().to_string());
51879        }
51880
51881        #[allow(clippy::single_element_loop)]
51882        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
51883            url = params.uri_replacement(url, param_name, find_this, false);
51884        }
51885        {
51886            let to_remove = ["profileId"];
51887            params.remove_params(&to_remove);
51888        }
51889
51890        let url = params.parse_with_url(&url);
51891
51892        let mut json_mime_type = mime::APPLICATION_JSON;
51893        let mut request_value_reader = {
51894            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
51895            common::remove_json_null_values(&mut value);
51896            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
51897            serde_json::to_writer(&mut dst, &value).unwrap();
51898            dst
51899        };
51900        let request_size = request_value_reader
51901            .seek(std::io::SeekFrom::End(0))
51902            .unwrap();
51903        request_value_reader
51904            .seek(std::io::SeekFrom::Start(0))
51905            .unwrap();
51906
51907        loop {
51908            let token = match self
51909                .hub
51910                .auth
51911                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
51912                .await
51913            {
51914                Ok(token) => token,
51915                Err(e) => match dlg.token(e) {
51916                    Ok(token) => token,
51917                    Err(e) => {
51918                        dlg.finished(false);
51919                        return Err(common::Error::MissingToken(e));
51920                    }
51921                },
51922            };
51923            request_value_reader
51924                .seek(std::io::SeekFrom::Start(0))
51925                .unwrap();
51926            let mut req_result = {
51927                let client = &self.hub.client;
51928                dlg.pre_request();
51929                let mut req_builder = hyper::Request::builder()
51930                    .method(hyper::Method::PUT)
51931                    .uri(url.as_str())
51932                    .header(USER_AGENT, self.hub._user_agent.clone());
51933
51934                if let Some(token) = token.as_ref() {
51935                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
51936                }
51937
51938                let request = req_builder
51939                    .header(CONTENT_TYPE, json_mime_type.to_string())
51940                    .header(CONTENT_LENGTH, request_size as u64)
51941                    .body(common::to_body(
51942                        request_value_reader.get_ref().clone().into(),
51943                    ));
51944
51945                client.request(request.unwrap()).await
51946            };
51947
51948            match req_result {
51949                Err(err) => {
51950                    if let common::Retry::After(d) = dlg.http_error(&err) {
51951                        sleep(d).await;
51952                        continue;
51953                    }
51954                    dlg.finished(false);
51955                    return Err(common::Error::HttpError(err));
51956                }
51957                Ok(res) => {
51958                    let (mut parts, body) = res.into_parts();
51959                    let mut body = common::Body::new(body);
51960                    if !parts.status.is_success() {
51961                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51962                        let error = serde_json::from_str(&common::to_string(&bytes));
51963                        let response = common::to_response(parts, bytes.into());
51964
51965                        if let common::Retry::After(d) =
51966                            dlg.http_failure(&response, error.as_ref().ok())
51967                        {
51968                            sleep(d).await;
51969                            continue;
51970                        }
51971
51972                        dlg.finished(false);
51973
51974                        return Err(match error {
51975                            Ok(value) => common::Error::BadRequest(value),
51976                            _ => common::Error::Failure(response),
51977                        });
51978                    }
51979                    let response = {
51980                        let bytes = common::to_bytes(body).await.unwrap_or_default();
51981                        let encoded = common::to_string(&bytes);
51982                        match serde_json::from_str(&encoded) {
51983                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
51984                            Err(error) => {
51985                                dlg.response_json_decode_error(&encoded, &error);
51986                                return Err(common::Error::JsonDecodeError(
51987                                    encoded.to_string(),
51988                                    error,
51989                                ));
51990                            }
51991                        }
51992                    };
51993
51994                    dlg.finished(true);
51995                    return Ok(response);
51996                }
51997            }
51998        }
51999    }
52000
52001    ///
52002    /// Sets the *request* property to the given value.
52003    ///
52004    /// Even though the property as already been set when instantiating this call,
52005    /// we provide this method for API completeness.
52006    pub fn request(
52007        mut self,
52008        new_value: FloodlightActivityGroup,
52009    ) -> FloodlightActivityGroupUpdateCall<'a, C> {
52010        self._request = new_value;
52011        self
52012    }
52013    /// User profile ID associated with this request.
52014    ///
52015    /// Sets the *profile id* path property to the given value.
52016    ///
52017    /// Even though the property as already been set when instantiating this call,
52018    /// we provide this method for API completeness.
52019    pub fn profile_id(mut self, new_value: i64) -> FloodlightActivityGroupUpdateCall<'a, C> {
52020        self._profile_id = new_value;
52021        self
52022    }
52023    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
52024    /// while executing the actual API request.
52025    ///
52026    /// ````text
52027    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
52028    /// ````
52029    ///
52030    /// Sets the *delegate* property to the given value.
52031    pub fn delegate(
52032        mut self,
52033        new_value: &'a mut dyn common::Delegate,
52034    ) -> FloodlightActivityGroupUpdateCall<'a, C> {
52035        self._delegate = Some(new_value);
52036        self
52037    }
52038
52039    /// Set any additional parameter of the query string used in the request.
52040    /// It should be used to set parameters which are not yet available through their own
52041    /// setters.
52042    ///
52043    /// Please note that this method must not be used to set any of the known parameters
52044    /// which have their own setter method. If done anyway, the request will fail.
52045    ///
52046    /// # Additional Parameters
52047    ///
52048    /// * *alt* (query-string) - Data format for the response.
52049    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
52050    /// * *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.
52051    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
52052    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
52053    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
52054    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
52055    pub fn param<T>(mut self, name: T, value: T) -> FloodlightActivityGroupUpdateCall<'a, C>
52056    where
52057        T: AsRef<str>,
52058    {
52059        self._additional_params
52060            .insert(name.as_ref().to_string(), value.as_ref().to_string());
52061        self
52062    }
52063
52064    /// Identifies the authorization scope for the method you are building.
52065    ///
52066    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
52067    /// [`Scope::Dfatrafficking`].
52068    ///
52069    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
52070    /// tokens for more than one scope.
52071    ///
52072    /// Usually there is more than one suitable scope to authorize an operation, some of which may
52073    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
52074    /// sufficient, a read-write scope will do as well.
52075    pub fn add_scope<St>(mut self, scope: St) -> FloodlightActivityGroupUpdateCall<'a, C>
52076    where
52077        St: AsRef<str>,
52078    {
52079        self._scopes.insert(String::from(scope.as_ref()));
52080        self
52081    }
52082    /// Identifies the authorization scope(s) for the method you are building.
52083    ///
52084    /// See [`Self::add_scope()`] for details.
52085    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightActivityGroupUpdateCall<'a, C>
52086    where
52087        I: IntoIterator<Item = St>,
52088        St: AsRef<str>,
52089    {
52090        self._scopes
52091            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
52092        self
52093    }
52094
52095    /// Removes all scopes, and no default scope will be used either.
52096    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
52097    /// for details).
52098    pub fn clear_scopes(mut self) -> FloodlightActivityGroupUpdateCall<'a, C> {
52099        self._scopes.clear();
52100        self
52101    }
52102}
52103
52104/// Gets one floodlight configuration by ID.
52105///
52106/// A builder for the *get* method supported by a *floodlightConfiguration* resource.
52107/// It is not used directly, but through a [`FloodlightConfigurationMethods`] instance.
52108///
52109/// # Example
52110///
52111/// Instantiate a resource method builder
52112///
52113/// ```test_harness,no_run
52114/// # extern crate hyper;
52115/// # extern crate hyper_rustls;
52116/// # extern crate google_dfareporting3d2 as dfareporting3d2;
52117/// # async fn dox() {
52118/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52119///
52120/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
52121/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
52122/// #     secret,
52123/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
52124/// # ).build().await.unwrap();
52125///
52126/// # let client = hyper_util::client::legacy::Client::builder(
52127/// #     hyper_util::rt::TokioExecutor::new()
52128/// # )
52129/// # .build(
52130/// #     hyper_rustls::HttpsConnectorBuilder::new()
52131/// #         .with_native_roots()
52132/// #         .unwrap()
52133/// #         .https_or_http()
52134/// #         .enable_http1()
52135/// #         .build()
52136/// # );
52137/// # let mut hub = Dfareporting::new(client, auth);
52138/// // You can configure optional parameters by calling the respective setters at will, and
52139/// // execute the final call using `doit()`.
52140/// // Values shown here are possibly random and not representative !
52141/// let result = hub.floodlight_configurations().get(-32, -5)
52142///              .doit().await;
52143/// # }
52144/// ```
52145pub struct FloodlightConfigurationGetCall<'a, C>
52146where
52147    C: 'a,
52148{
52149    hub: &'a Dfareporting<C>,
52150    _profile_id: i64,
52151    _id: i64,
52152    _delegate: Option<&'a mut dyn common::Delegate>,
52153    _additional_params: HashMap<String, String>,
52154    _scopes: BTreeSet<String>,
52155}
52156
52157impl<'a, C> common::CallBuilder for FloodlightConfigurationGetCall<'a, C> {}
52158
52159impl<'a, C> FloodlightConfigurationGetCall<'a, C>
52160where
52161    C: common::Connector,
52162{
52163    /// Perform the operation you have build so far.
52164    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightConfiguration)> {
52165        use std::borrow::Cow;
52166        use std::io::{Read, Seek};
52167
52168        use common::{url::Params, ToParts};
52169        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
52170
52171        let mut dd = common::DefaultDelegate;
52172        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
52173        dlg.begin(common::MethodInfo {
52174            id: "dfareporting.floodlightConfigurations.get",
52175            http_method: hyper::Method::GET,
52176        });
52177
52178        for &field in ["alt", "profileId", "id"].iter() {
52179            if self._additional_params.contains_key(field) {
52180                dlg.finished(false);
52181                return Err(common::Error::FieldClash(field));
52182            }
52183        }
52184
52185        let mut params = Params::with_capacity(4 + self._additional_params.len());
52186        params.push("profileId", self._profile_id.to_string());
52187        params.push("id", self._id.to_string());
52188
52189        params.extend(self._additional_params.iter());
52190
52191        params.push("alt", "json");
52192        let mut url =
52193            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations/{id}";
52194        if self._scopes.is_empty() {
52195            self._scopes
52196                .insert(Scope::Dfatrafficking.as_ref().to_string());
52197        }
52198
52199        #[allow(clippy::single_element_loop)]
52200        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
52201            url = params.uri_replacement(url, param_name, find_this, false);
52202        }
52203        {
52204            let to_remove = ["id", "profileId"];
52205            params.remove_params(&to_remove);
52206        }
52207
52208        let url = params.parse_with_url(&url);
52209
52210        loop {
52211            let token = match self
52212                .hub
52213                .auth
52214                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
52215                .await
52216            {
52217                Ok(token) => token,
52218                Err(e) => match dlg.token(e) {
52219                    Ok(token) => token,
52220                    Err(e) => {
52221                        dlg.finished(false);
52222                        return Err(common::Error::MissingToken(e));
52223                    }
52224                },
52225            };
52226            let mut req_result = {
52227                let client = &self.hub.client;
52228                dlg.pre_request();
52229                let mut req_builder = hyper::Request::builder()
52230                    .method(hyper::Method::GET)
52231                    .uri(url.as_str())
52232                    .header(USER_AGENT, self.hub._user_agent.clone());
52233
52234                if let Some(token) = token.as_ref() {
52235                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
52236                }
52237
52238                let request = req_builder
52239                    .header(CONTENT_LENGTH, 0_u64)
52240                    .body(common::to_body::<String>(None));
52241
52242                client.request(request.unwrap()).await
52243            };
52244
52245            match req_result {
52246                Err(err) => {
52247                    if let common::Retry::After(d) = dlg.http_error(&err) {
52248                        sleep(d).await;
52249                        continue;
52250                    }
52251                    dlg.finished(false);
52252                    return Err(common::Error::HttpError(err));
52253                }
52254                Ok(res) => {
52255                    let (mut parts, body) = res.into_parts();
52256                    let mut body = common::Body::new(body);
52257                    if !parts.status.is_success() {
52258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52259                        let error = serde_json::from_str(&common::to_string(&bytes));
52260                        let response = common::to_response(parts, bytes.into());
52261
52262                        if let common::Retry::After(d) =
52263                            dlg.http_failure(&response, error.as_ref().ok())
52264                        {
52265                            sleep(d).await;
52266                            continue;
52267                        }
52268
52269                        dlg.finished(false);
52270
52271                        return Err(match error {
52272                            Ok(value) => common::Error::BadRequest(value),
52273                            _ => common::Error::Failure(response),
52274                        });
52275                    }
52276                    let response = {
52277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52278                        let encoded = common::to_string(&bytes);
52279                        match serde_json::from_str(&encoded) {
52280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
52281                            Err(error) => {
52282                                dlg.response_json_decode_error(&encoded, &error);
52283                                return Err(common::Error::JsonDecodeError(
52284                                    encoded.to_string(),
52285                                    error,
52286                                ));
52287                            }
52288                        }
52289                    };
52290
52291                    dlg.finished(true);
52292                    return Ok(response);
52293                }
52294            }
52295        }
52296    }
52297
52298    /// User profile ID associated with this request.
52299    ///
52300    /// Sets the *profile id* path property to the given value.
52301    ///
52302    /// Even though the property as already been set when instantiating this call,
52303    /// we provide this method for API completeness.
52304    pub fn profile_id(mut self, new_value: i64) -> FloodlightConfigurationGetCall<'a, C> {
52305        self._profile_id = new_value;
52306        self
52307    }
52308    /// Floodlight configuration ID.
52309    ///
52310    /// Sets the *id* path property to the given value.
52311    ///
52312    /// Even though the property as already been set when instantiating this call,
52313    /// we provide this method for API completeness.
52314    pub fn id(mut self, new_value: i64) -> FloodlightConfigurationGetCall<'a, C> {
52315        self._id = new_value;
52316        self
52317    }
52318    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
52319    /// while executing the actual API request.
52320    ///
52321    /// ````text
52322    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
52323    /// ````
52324    ///
52325    /// Sets the *delegate* property to the given value.
52326    pub fn delegate(
52327        mut self,
52328        new_value: &'a mut dyn common::Delegate,
52329    ) -> FloodlightConfigurationGetCall<'a, C> {
52330        self._delegate = Some(new_value);
52331        self
52332    }
52333
52334    /// Set any additional parameter of the query string used in the request.
52335    /// It should be used to set parameters which are not yet available through their own
52336    /// setters.
52337    ///
52338    /// Please note that this method must not be used to set any of the known parameters
52339    /// which have their own setter method. If done anyway, the request will fail.
52340    ///
52341    /// # Additional Parameters
52342    ///
52343    /// * *alt* (query-string) - Data format for the response.
52344    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
52345    /// * *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.
52346    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
52347    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
52348    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
52349    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
52350    pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationGetCall<'a, C>
52351    where
52352        T: AsRef<str>,
52353    {
52354        self._additional_params
52355            .insert(name.as_ref().to_string(), value.as_ref().to_string());
52356        self
52357    }
52358
52359    /// Identifies the authorization scope for the method you are building.
52360    ///
52361    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
52362    /// [`Scope::Dfatrafficking`].
52363    ///
52364    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
52365    /// tokens for more than one scope.
52366    ///
52367    /// Usually there is more than one suitable scope to authorize an operation, some of which may
52368    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
52369    /// sufficient, a read-write scope will do as well.
52370    pub fn add_scope<St>(mut self, scope: St) -> FloodlightConfigurationGetCall<'a, C>
52371    where
52372        St: AsRef<str>,
52373    {
52374        self._scopes.insert(String::from(scope.as_ref()));
52375        self
52376    }
52377    /// Identifies the authorization scope(s) for the method you are building.
52378    ///
52379    /// See [`Self::add_scope()`] for details.
52380    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightConfigurationGetCall<'a, C>
52381    where
52382        I: IntoIterator<Item = St>,
52383        St: AsRef<str>,
52384    {
52385        self._scopes
52386            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
52387        self
52388    }
52389
52390    /// Removes all scopes, and no default scope will be used either.
52391    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
52392    /// for details).
52393    pub fn clear_scopes(mut self) -> FloodlightConfigurationGetCall<'a, C> {
52394        self._scopes.clear();
52395        self
52396    }
52397}
52398
52399/// Retrieves a list of floodlight configurations, possibly filtered.
52400///
52401/// A builder for the *list* method supported by a *floodlightConfiguration* resource.
52402/// It is not used directly, but through a [`FloodlightConfigurationMethods`] instance.
52403///
52404/// # Example
52405///
52406/// Instantiate a resource method builder
52407///
52408/// ```test_harness,no_run
52409/// # extern crate hyper;
52410/// # extern crate hyper_rustls;
52411/// # extern crate google_dfareporting3d2 as dfareporting3d2;
52412/// # async fn dox() {
52413/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52414///
52415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
52416/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
52417/// #     secret,
52418/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
52419/// # ).build().await.unwrap();
52420///
52421/// # let client = hyper_util::client::legacy::Client::builder(
52422/// #     hyper_util::rt::TokioExecutor::new()
52423/// # )
52424/// # .build(
52425/// #     hyper_rustls::HttpsConnectorBuilder::new()
52426/// #         .with_native_roots()
52427/// #         .unwrap()
52428/// #         .https_or_http()
52429/// #         .enable_http1()
52430/// #         .build()
52431/// # );
52432/// # let mut hub = Dfareporting::new(client, auth);
52433/// // You can configure optional parameters by calling the respective setters at will, and
52434/// // execute the final call using `doit()`.
52435/// // Values shown here are possibly random and not representative !
52436/// let result = hub.floodlight_configurations().list(-62)
52437///              .add_ids(-88)
52438///              .doit().await;
52439/// # }
52440/// ```
52441pub struct FloodlightConfigurationListCall<'a, C>
52442where
52443    C: 'a,
52444{
52445    hub: &'a Dfareporting<C>,
52446    _profile_id: i64,
52447    _ids: Vec<i64>,
52448    _delegate: Option<&'a mut dyn common::Delegate>,
52449    _additional_params: HashMap<String, String>,
52450    _scopes: BTreeSet<String>,
52451}
52452
52453impl<'a, C> common::CallBuilder for FloodlightConfigurationListCall<'a, C> {}
52454
52455impl<'a, C> FloodlightConfigurationListCall<'a, C>
52456where
52457    C: common::Connector,
52458{
52459    /// Perform the operation you have build so far.
52460    pub async fn doit(
52461        mut self,
52462    ) -> common::Result<(common::Response, FloodlightConfigurationsListResponse)> {
52463        use std::borrow::Cow;
52464        use std::io::{Read, Seek};
52465
52466        use common::{url::Params, ToParts};
52467        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
52468
52469        let mut dd = common::DefaultDelegate;
52470        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
52471        dlg.begin(common::MethodInfo {
52472            id: "dfareporting.floodlightConfigurations.list",
52473            http_method: hyper::Method::GET,
52474        });
52475
52476        for &field in ["alt", "profileId", "ids"].iter() {
52477            if self._additional_params.contains_key(field) {
52478                dlg.finished(false);
52479                return Err(common::Error::FieldClash(field));
52480            }
52481        }
52482
52483        let mut params = Params::with_capacity(4 + self._additional_params.len());
52484        params.push("profileId", self._profile_id.to_string());
52485        if !self._ids.is_empty() {
52486            for f in self._ids.iter() {
52487                params.push("ids", f.to_string());
52488            }
52489        }
52490
52491        params.extend(self._additional_params.iter());
52492
52493        params.push("alt", "json");
52494        let mut url =
52495            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations";
52496        if self._scopes.is_empty() {
52497            self._scopes
52498                .insert(Scope::Dfatrafficking.as_ref().to_string());
52499        }
52500
52501        #[allow(clippy::single_element_loop)]
52502        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
52503            url = params.uri_replacement(url, param_name, find_this, false);
52504        }
52505        {
52506            let to_remove = ["profileId"];
52507            params.remove_params(&to_remove);
52508        }
52509
52510        let url = params.parse_with_url(&url);
52511
52512        loop {
52513            let token = match self
52514                .hub
52515                .auth
52516                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
52517                .await
52518            {
52519                Ok(token) => token,
52520                Err(e) => match dlg.token(e) {
52521                    Ok(token) => token,
52522                    Err(e) => {
52523                        dlg.finished(false);
52524                        return Err(common::Error::MissingToken(e));
52525                    }
52526                },
52527            };
52528            let mut req_result = {
52529                let client = &self.hub.client;
52530                dlg.pre_request();
52531                let mut req_builder = hyper::Request::builder()
52532                    .method(hyper::Method::GET)
52533                    .uri(url.as_str())
52534                    .header(USER_AGENT, self.hub._user_agent.clone());
52535
52536                if let Some(token) = token.as_ref() {
52537                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
52538                }
52539
52540                let request = req_builder
52541                    .header(CONTENT_LENGTH, 0_u64)
52542                    .body(common::to_body::<String>(None));
52543
52544                client.request(request.unwrap()).await
52545            };
52546
52547            match req_result {
52548                Err(err) => {
52549                    if let common::Retry::After(d) = dlg.http_error(&err) {
52550                        sleep(d).await;
52551                        continue;
52552                    }
52553                    dlg.finished(false);
52554                    return Err(common::Error::HttpError(err));
52555                }
52556                Ok(res) => {
52557                    let (mut parts, body) = res.into_parts();
52558                    let mut body = common::Body::new(body);
52559                    if !parts.status.is_success() {
52560                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52561                        let error = serde_json::from_str(&common::to_string(&bytes));
52562                        let response = common::to_response(parts, bytes.into());
52563
52564                        if let common::Retry::After(d) =
52565                            dlg.http_failure(&response, error.as_ref().ok())
52566                        {
52567                            sleep(d).await;
52568                            continue;
52569                        }
52570
52571                        dlg.finished(false);
52572
52573                        return Err(match error {
52574                            Ok(value) => common::Error::BadRequest(value),
52575                            _ => common::Error::Failure(response),
52576                        });
52577                    }
52578                    let response = {
52579                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52580                        let encoded = common::to_string(&bytes);
52581                        match serde_json::from_str(&encoded) {
52582                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
52583                            Err(error) => {
52584                                dlg.response_json_decode_error(&encoded, &error);
52585                                return Err(common::Error::JsonDecodeError(
52586                                    encoded.to_string(),
52587                                    error,
52588                                ));
52589                            }
52590                        }
52591                    };
52592
52593                    dlg.finished(true);
52594                    return Ok(response);
52595                }
52596            }
52597        }
52598    }
52599
52600    /// User profile ID associated with this request.
52601    ///
52602    /// Sets the *profile id* path property to the given value.
52603    ///
52604    /// Even though the property as already been set when instantiating this call,
52605    /// we provide this method for API completeness.
52606    pub fn profile_id(mut self, new_value: i64) -> FloodlightConfigurationListCall<'a, C> {
52607        self._profile_id = new_value;
52608        self
52609    }
52610    /// Set of IDs of floodlight configurations to retrieve. Required field; otherwise an empty list will be returned.
52611    ///
52612    /// Append the given value to the *ids* query property.
52613    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
52614    pub fn add_ids(mut self, new_value: i64) -> FloodlightConfigurationListCall<'a, C> {
52615        self._ids.push(new_value);
52616        self
52617    }
52618    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
52619    /// while executing the actual API request.
52620    ///
52621    /// ````text
52622    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
52623    /// ````
52624    ///
52625    /// Sets the *delegate* property to the given value.
52626    pub fn delegate(
52627        mut self,
52628        new_value: &'a mut dyn common::Delegate,
52629    ) -> FloodlightConfigurationListCall<'a, C> {
52630        self._delegate = Some(new_value);
52631        self
52632    }
52633
52634    /// Set any additional parameter of the query string used in the request.
52635    /// It should be used to set parameters which are not yet available through their own
52636    /// setters.
52637    ///
52638    /// Please note that this method must not be used to set any of the known parameters
52639    /// which have their own setter method. If done anyway, the request will fail.
52640    ///
52641    /// # Additional Parameters
52642    ///
52643    /// * *alt* (query-string) - Data format for the response.
52644    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
52645    /// * *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.
52646    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
52647    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
52648    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
52649    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
52650    pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationListCall<'a, C>
52651    where
52652        T: AsRef<str>,
52653    {
52654        self._additional_params
52655            .insert(name.as_ref().to_string(), value.as_ref().to_string());
52656        self
52657    }
52658
52659    /// Identifies the authorization scope for the method you are building.
52660    ///
52661    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
52662    /// [`Scope::Dfatrafficking`].
52663    ///
52664    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
52665    /// tokens for more than one scope.
52666    ///
52667    /// Usually there is more than one suitable scope to authorize an operation, some of which may
52668    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
52669    /// sufficient, a read-write scope will do as well.
52670    pub fn add_scope<St>(mut self, scope: St) -> FloodlightConfigurationListCall<'a, C>
52671    where
52672        St: AsRef<str>,
52673    {
52674        self._scopes.insert(String::from(scope.as_ref()));
52675        self
52676    }
52677    /// Identifies the authorization scope(s) for the method you are building.
52678    ///
52679    /// See [`Self::add_scope()`] for details.
52680    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightConfigurationListCall<'a, C>
52681    where
52682        I: IntoIterator<Item = St>,
52683        St: AsRef<str>,
52684    {
52685        self._scopes
52686            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
52687        self
52688    }
52689
52690    /// Removes all scopes, and no default scope will be used either.
52691    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
52692    /// for details).
52693    pub fn clear_scopes(mut self) -> FloodlightConfigurationListCall<'a, C> {
52694        self._scopes.clear();
52695        self
52696    }
52697}
52698
52699/// Updates an existing floodlight configuration. This method supports patch semantics.
52700///
52701/// A builder for the *patch* method supported by a *floodlightConfiguration* resource.
52702/// It is not used directly, but through a [`FloodlightConfigurationMethods`] instance.
52703///
52704/// # Example
52705///
52706/// Instantiate a resource method builder
52707///
52708/// ```test_harness,no_run
52709/// # extern crate hyper;
52710/// # extern crate hyper_rustls;
52711/// # extern crate google_dfareporting3d2 as dfareporting3d2;
52712/// use dfareporting3d2::api::FloodlightConfiguration;
52713/// # async fn dox() {
52714/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52715///
52716/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
52717/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
52718/// #     secret,
52719/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
52720/// # ).build().await.unwrap();
52721///
52722/// # let client = hyper_util::client::legacy::Client::builder(
52723/// #     hyper_util::rt::TokioExecutor::new()
52724/// # )
52725/// # .build(
52726/// #     hyper_rustls::HttpsConnectorBuilder::new()
52727/// #         .with_native_roots()
52728/// #         .unwrap()
52729/// #         .https_or_http()
52730/// #         .enable_http1()
52731/// #         .build()
52732/// # );
52733/// # let mut hub = Dfareporting::new(client, auth);
52734/// // As the method needs a request, you would usually fill it with the desired information
52735/// // into the respective structure. Some of the parts shown here might not be applicable !
52736/// // Values shown here are possibly random and not representative !
52737/// let mut req = FloodlightConfiguration::default();
52738///
52739/// // You can configure optional parameters by calling the respective setters at will, and
52740/// // execute the final call using `doit()`.
52741/// // Values shown here are possibly random and not representative !
52742/// let result = hub.floodlight_configurations().patch(req, -10, -20)
52743///              .doit().await;
52744/// # }
52745/// ```
52746pub struct FloodlightConfigurationPatchCall<'a, C>
52747where
52748    C: 'a,
52749{
52750    hub: &'a Dfareporting<C>,
52751    _request: FloodlightConfiguration,
52752    _profile_id: i64,
52753    _id: i64,
52754    _delegate: Option<&'a mut dyn common::Delegate>,
52755    _additional_params: HashMap<String, String>,
52756    _scopes: BTreeSet<String>,
52757}
52758
52759impl<'a, C> common::CallBuilder for FloodlightConfigurationPatchCall<'a, C> {}
52760
52761impl<'a, C> FloodlightConfigurationPatchCall<'a, C>
52762where
52763    C: common::Connector,
52764{
52765    /// Perform the operation you have build so far.
52766    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightConfiguration)> {
52767        use std::borrow::Cow;
52768        use std::io::{Read, Seek};
52769
52770        use common::{url::Params, ToParts};
52771        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
52772
52773        let mut dd = common::DefaultDelegate;
52774        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
52775        dlg.begin(common::MethodInfo {
52776            id: "dfareporting.floodlightConfigurations.patch",
52777            http_method: hyper::Method::PATCH,
52778        });
52779
52780        for &field in ["alt", "profileId", "id"].iter() {
52781            if self._additional_params.contains_key(field) {
52782                dlg.finished(false);
52783                return Err(common::Error::FieldClash(field));
52784            }
52785        }
52786
52787        let mut params = Params::with_capacity(5 + self._additional_params.len());
52788        params.push("profileId", self._profile_id.to_string());
52789        params.push("id", self._id.to_string());
52790
52791        params.extend(self._additional_params.iter());
52792
52793        params.push("alt", "json");
52794        let mut url =
52795            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations";
52796        if self._scopes.is_empty() {
52797            self._scopes
52798                .insert(Scope::Dfatrafficking.as_ref().to_string());
52799        }
52800
52801        #[allow(clippy::single_element_loop)]
52802        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
52803            url = params.uri_replacement(url, param_name, find_this, false);
52804        }
52805        {
52806            let to_remove = ["profileId"];
52807            params.remove_params(&to_remove);
52808        }
52809
52810        let url = params.parse_with_url(&url);
52811
52812        let mut json_mime_type = mime::APPLICATION_JSON;
52813        let mut request_value_reader = {
52814            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
52815            common::remove_json_null_values(&mut value);
52816            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
52817            serde_json::to_writer(&mut dst, &value).unwrap();
52818            dst
52819        };
52820        let request_size = request_value_reader
52821            .seek(std::io::SeekFrom::End(0))
52822            .unwrap();
52823        request_value_reader
52824            .seek(std::io::SeekFrom::Start(0))
52825            .unwrap();
52826
52827        loop {
52828            let token = match self
52829                .hub
52830                .auth
52831                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
52832                .await
52833            {
52834                Ok(token) => token,
52835                Err(e) => match dlg.token(e) {
52836                    Ok(token) => token,
52837                    Err(e) => {
52838                        dlg.finished(false);
52839                        return Err(common::Error::MissingToken(e));
52840                    }
52841                },
52842            };
52843            request_value_reader
52844                .seek(std::io::SeekFrom::Start(0))
52845                .unwrap();
52846            let mut req_result = {
52847                let client = &self.hub.client;
52848                dlg.pre_request();
52849                let mut req_builder = hyper::Request::builder()
52850                    .method(hyper::Method::PATCH)
52851                    .uri(url.as_str())
52852                    .header(USER_AGENT, self.hub._user_agent.clone());
52853
52854                if let Some(token) = token.as_ref() {
52855                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
52856                }
52857
52858                let request = req_builder
52859                    .header(CONTENT_TYPE, json_mime_type.to_string())
52860                    .header(CONTENT_LENGTH, request_size as u64)
52861                    .body(common::to_body(
52862                        request_value_reader.get_ref().clone().into(),
52863                    ));
52864
52865                client.request(request.unwrap()).await
52866            };
52867
52868            match req_result {
52869                Err(err) => {
52870                    if let common::Retry::After(d) = dlg.http_error(&err) {
52871                        sleep(d).await;
52872                        continue;
52873                    }
52874                    dlg.finished(false);
52875                    return Err(common::Error::HttpError(err));
52876                }
52877                Ok(res) => {
52878                    let (mut parts, body) = res.into_parts();
52879                    let mut body = common::Body::new(body);
52880                    if !parts.status.is_success() {
52881                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52882                        let error = serde_json::from_str(&common::to_string(&bytes));
52883                        let response = common::to_response(parts, bytes.into());
52884
52885                        if let common::Retry::After(d) =
52886                            dlg.http_failure(&response, error.as_ref().ok())
52887                        {
52888                            sleep(d).await;
52889                            continue;
52890                        }
52891
52892                        dlg.finished(false);
52893
52894                        return Err(match error {
52895                            Ok(value) => common::Error::BadRequest(value),
52896                            _ => common::Error::Failure(response),
52897                        });
52898                    }
52899                    let response = {
52900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
52901                        let encoded = common::to_string(&bytes);
52902                        match serde_json::from_str(&encoded) {
52903                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
52904                            Err(error) => {
52905                                dlg.response_json_decode_error(&encoded, &error);
52906                                return Err(common::Error::JsonDecodeError(
52907                                    encoded.to_string(),
52908                                    error,
52909                                ));
52910                            }
52911                        }
52912                    };
52913
52914                    dlg.finished(true);
52915                    return Ok(response);
52916                }
52917            }
52918        }
52919    }
52920
52921    ///
52922    /// Sets the *request* property to the given value.
52923    ///
52924    /// Even though the property as already been set when instantiating this call,
52925    /// we provide this method for API completeness.
52926    pub fn request(
52927        mut self,
52928        new_value: FloodlightConfiguration,
52929    ) -> FloodlightConfigurationPatchCall<'a, C> {
52930        self._request = new_value;
52931        self
52932    }
52933    /// User profile ID associated with this request.
52934    ///
52935    /// Sets the *profile id* path property to the given value.
52936    ///
52937    /// Even though the property as already been set when instantiating this call,
52938    /// we provide this method for API completeness.
52939    pub fn profile_id(mut self, new_value: i64) -> FloodlightConfigurationPatchCall<'a, C> {
52940        self._profile_id = new_value;
52941        self
52942    }
52943    /// Floodlight configuration ID.
52944    ///
52945    /// Sets the *id* query property to the given value.
52946    ///
52947    /// Even though the property as already been set when instantiating this call,
52948    /// we provide this method for API completeness.
52949    pub fn id(mut self, new_value: i64) -> FloodlightConfigurationPatchCall<'a, C> {
52950        self._id = new_value;
52951        self
52952    }
52953    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
52954    /// while executing the actual API request.
52955    ///
52956    /// ````text
52957    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
52958    /// ````
52959    ///
52960    /// Sets the *delegate* property to the given value.
52961    pub fn delegate(
52962        mut self,
52963        new_value: &'a mut dyn common::Delegate,
52964    ) -> FloodlightConfigurationPatchCall<'a, C> {
52965        self._delegate = Some(new_value);
52966        self
52967    }
52968
52969    /// Set any additional parameter of the query string used in the request.
52970    /// It should be used to set parameters which are not yet available through their own
52971    /// setters.
52972    ///
52973    /// Please note that this method must not be used to set any of the known parameters
52974    /// which have their own setter method. If done anyway, the request will fail.
52975    ///
52976    /// # Additional Parameters
52977    ///
52978    /// * *alt* (query-string) - Data format for the response.
52979    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
52980    /// * *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.
52981    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
52982    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
52983    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
52984    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
52985    pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationPatchCall<'a, C>
52986    where
52987        T: AsRef<str>,
52988    {
52989        self._additional_params
52990            .insert(name.as_ref().to_string(), value.as_ref().to_string());
52991        self
52992    }
52993
52994    /// Identifies the authorization scope for the method you are building.
52995    ///
52996    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
52997    /// [`Scope::Dfatrafficking`].
52998    ///
52999    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
53000    /// tokens for more than one scope.
53001    ///
53002    /// Usually there is more than one suitable scope to authorize an operation, some of which may
53003    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
53004    /// sufficient, a read-write scope will do as well.
53005    pub fn add_scope<St>(mut self, scope: St) -> FloodlightConfigurationPatchCall<'a, C>
53006    where
53007        St: AsRef<str>,
53008    {
53009        self._scopes.insert(String::from(scope.as_ref()));
53010        self
53011    }
53012    /// Identifies the authorization scope(s) for the method you are building.
53013    ///
53014    /// See [`Self::add_scope()`] for details.
53015    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightConfigurationPatchCall<'a, C>
53016    where
53017        I: IntoIterator<Item = St>,
53018        St: AsRef<str>,
53019    {
53020        self._scopes
53021            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
53022        self
53023    }
53024
53025    /// Removes all scopes, and no default scope will be used either.
53026    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
53027    /// for details).
53028    pub fn clear_scopes(mut self) -> FloodlightConfigurationPatchCall<'a, C> {
53029        self._scopes.clear();
53030        self
53031    }
53032}
53033
53034/// Updates an existing floodlight configuration.
53035///
53036/// A builder for the *update* method supported by a *floodlightConfiguration* resource.
53037/// It is not used directly, but through a [`FloodlightConfigurationMethods`] instance.
53038///
53039/// # Example
53040///
53041/// Instantiate a resource method builder
53042///
53043/// ```test_harness,no_run
53044/// # extern crate hyper;
53045/// # extern crate hyper_rustls;
53046/// # extern crate google_dfareporting3d2 as dfareporting3d2;
53047/// use dfareporting3d2::api::FloodlightConfiguration;
53048/// # async fn dox() {
53049/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53050///
53051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
53052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
53053/// #     secret,
53054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
53055/// # ).build().await.unwrap();
53056///
53057/// # let client = hyper_util::client::legacy::Client::builder(
53058/// #     hyper_util::rt::TokioExecutor::new()
53059/// # )
53060/// # .build(
53061/// #     hyper_rustls::HttpsConnectorBuilder::new()
53062/// #         .with_native_roots()
53063/// #         .unwrap()
53064/// #         .https_or_http()
53065/// #         .enable_http1()
53066/// #         .build()
53067/// # );
53068/// # let mut hub = Dfareporting::new(client, auth);
53069/// // As the method needs a request, you would usually fill it with the desired information
53070/// // into the respective structure. Some of the parts shown here might not be applicable !
53071/// // Values shown here are possibly random and not representative !
53072/// let mut req = FloodlightConfiguration::default();
53073///
53074/// // You can configure optional parameters by calling the respective setters at will, and
53075/// // execute the final call using `doit()`.
53076/// // Values shown here are possibly random and not representative !
53077/// let result = hub.floodlight_configurations().update(req, -60)
53078///              .doit().await;
53079/// # }
53080/// ```
53081pub struct FloodlightConfigurationUpdateCall<'a, C>
53082where
53083    C: 'a,
53084{
53085    hub: &'a Dfareporting<C>,
53086    _request: FloodlightConfiguration,
53087    _profile_id: i64,
53088    _delegate: Option<&'a mut dyn common::Delegate>,
53089    _additional_params: HashMap<String, String>,
53090    _scopes: BTreeSet<String>,
53091}
53092
53093impl<'a, C> common::CallBuilder for FloodlightConfigurationUpdateCall<'a, C> {}
53094
53095impl<'a, C> FloodlightConfigurationUpdateCall<'a, C>
53096where
53097    C: common::Connector,
53098{
53099    /// Perform the operation you have build so far.
53100    pub async fn doit(mut self) -> common::Result<(common::Response, FloodlightConfiguration)> {
53101        use std::borrow::Cow;
53102        use std::io::{Read, Seek};
53103
53104        use common::{url::Params, ToParts};
53105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
53106
53107        let mut dd = common::DefaultDelegate;
53108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
53109        dlg.begin(common::MethodInfo {
53110            id: "dfareporting.floodlightConfigurations.update",
53111            http_method: hyper::Method::PUT,
53112        });
53113
53114        for &field in ["alt", "profileId"].iter() {
53115            if self._additional_params.contains_key(field) {
53116                dlg.finished(false);
53117                return Err(common::Error::FieldClash(field));
53118            }
53119        }
53120
53121        let mut params = Params::with_capacity(4 + self._additional_params.len());
53122        params.push("profileId", self._profile_id.to_string());
53123
53124        params.extend(self._additional_params.iter());
53125
53126        params.push("alt", "json");
53127        let mut url =
53128            self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations";
53129        if self._scopes.is_empty() {
53130            self._scopes
53131                .insert(Scope::Dfatrafficking.as_ref().to_string());
53132        }
53133
53134        #[allow(clippy::single_element_loop)]
53135        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
53136            url = params.uri_replacement(url, param_name, find_this, false);
53137        }
53138        {
53139            let to_remove = ["profileId"];
53140            params.remove_params(&to_remove);
53141        }
53142
53143        let url = params.parse_with_url(&url);
53144
53145        let mut json_mime_type = mime::APPLICATION_JSON;
53146        let mut request_value_reader = {
53147            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
53148            common::remove_json_null_values(&mut value);
53149            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
53150            serde_json::to_writer(&mut dst, &value).unwrap();
53151            dst
53152        };
53153        let request_size = request_value_reader
53154            .seek(std::io::SeekFrom::End(0))
53155            .unwrap();
53156        request_value_reader
53157            .seek(std::io::SeekFrom::Start(0))
53158            .unwrap();
53159
53160        loop {
53161            let token = match self
53162                .hub
53163                .auth
53164                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
53165                .await
53166            {
53167                Ok(token) => token,
53168                Err(e) => match dlg.token(e) {
53169                    Ok(token) => token,
53170                    Err(e) => {
53171                        dlg.finished(false);
53172                        return Err(common::Error::MissingToken(e));
53173                    }
53174                },
53175            };
53176            request_value_reader
53177                .seek(std::io::SeekFrom::Start(0))
53178                .unwrap();
53179            let mut req_result = {
53180                let client = &self.hub.client;
53181                dlg.pre_request();
53182                let mut req_builder = hyper::Request::builder()
53183                    .method(hyper::Method::PUT)
53184                    .uri(url.as_str())
53185                    .header(USER_AGENT, self.hub._user_agent.clone());
53186
53187                if let Some(token) = token.as_ref() {
53188                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
53189                }
53190
53191                let request = req_builder
53192                    .header(CONTENT_TYPE, json_mime_type.to_string())
53193                    .header(CONTENT_LENGTH, request_size as u64)
53194                    .body(common::to_body(
53195                        request_value_reader.get_ref().clone().into(),
53196                    ));
53197
53198                client.request(request.unwrap()).await
53199            };
53200
53201            match req_result {
53202                Err(err) => {
53203                    if let common::Retry::After(d) = dlg.http_error(&err) {
53204                        sleep(d).await;
53205                        continue;
53206                    }
53207                    dlg.finished(false);
53208                    return Err(common::Error::HttpError(err));
53209                }
53210                Ok(res) => {
53211                    let (mut parts, body) = res.into_parts();
53212                    let mut body = common::Body::new(body);
53213                    if !parts.status.is_success() {
53214                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53215                        let error = serde_json::from_str(&common::to_string(&bytes));
53216                        let response = common::to_response(parts, bytes.into());
53217
53218                        if let common::Retry::After(d) =
53219                            dlg.http_failure(&response, error.as_ref().ok())
53220                        {
53221                            sleep(d).await;
53222                            continue;
53223                        }
53224
53225                        dlg.finished(false);
53226
53227                        return Err(match error {
53228                            Ok(value) => common::Error::BadRequest(value),
53229                            _ => common::Error::Failure(response),
53230                        });
53231                    }
53232                    let response = {
53233                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53234                        let encoded = common::to_string(&bytes);
53235                        match serde_json::from_str(&encoded) {
53236                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
53237                            Err(error) => {
53238                                dlg.response_json_decode_error(&encoded, &error);
53239                                return Err(common::Error::JsonDecodeError(
53240                                    encoded.to_string(),
53241                                    error,
53242                                ));
53243                            }
53244                        }
53245                    };
53246
53247                    dlg.finished(true);
53248                    return Ok(response);
53249                }
53250            }
53251        }
53252    }
53253
53254    ///
53255    /// Sets the *request* property to the given value.
53256    ///
53257    /// Even though the property as already been set when instantiating this call,
53258    /// we provide this method for API completeness.
53259    pub fn request(
53260        mut self,
53261        new_value: FloodlightConfiguration,
53262    ) -> FloodlightConfigurationUpdateCall<'a, C> {
53263        self._request = new_value;
53264        self
53265    }
53266    /// User profile ID associated with this request.
53267    ///
53268    /// Sets the *profile id* path property to the given value.
53269    ///
53270    /// Even though the property as already been set when instantiating this call,
53271    /// we provide this method for API completeness.
53272    pub fn profile_id(mut self, new_value: i64) -> FloodlightConfigurationUpdateCall<'a, C> {
53273        self._profile_id = new_value;
53274        self
53275    }
53276    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
53277    /// while executing the actual API request.
53278    ///
53279    /// ````text
53280    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
53281    /// ````
53282    ///
53283    /// Sets the *delegate* property to the given value.
53284    pub fn delegate(
53285        mut self,
53286        new_value: &'a mut dyn common::Delegate,
53287    ) -> FloodlightConfigurationUpdateCall<'a, C> {
53288        self._delegate = Some(new_value);
53289        self
53290    }
53291
53292    /// Set any additional parameter of the query string used in the request.
53293    /// It should be used to set parameters which are not yet available through their own
53294    /// setters.
53295    ///
53296    /// Please note that this method must not be used to set any of the known parameters
53297    /// which have their own setter method. If done anyway, the request will fail.
53298    ///
53299    /// # Additional Parameters
53300    ///
53301    /// * *alt* (query-string) - Data format for the response.
53302    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
53303    /// * *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.
53304    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
53305    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
53306    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
53307    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
53308    pub fn param<T>(mut self, name: T, value: T) -> FloodlightConfigurationUpdateCall<'a, C>
53309    where
53310        T: AsRef<str>,
53311    {
53312        self._additional_params
53313            .insert(name.as_ref().to_string(), value.as_ref().to_string());
53314        self
53315    }
53316
53317    /// Identifies the authorization scope for the method you are building.
53318    ///
53319    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
53320    /// [`Scope::Dfatrafficking`].
53321    ///
53322    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
53323    /// tokens for more than one scope.
53324    ///
53325    /// Usually there is more than one suitable scope to authorize an operation, some of which may
53326    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
53327    /// sufficient, a read-write scope will do as well.
53328    pub fn add_scope<St>(mut self, scope: St) -> FloodlightConfigurationUpdateCall<'a, C>
53329    where
53330        St: AsRef<str>,
53331    {
53332        self._scopes.insert(String::from(scope.as_ref()));
53333        self
53334    }
53335    /// Identifies the authorization scope(s) for the method you are building.
53336    ///
53337    /// See [`Self::add_scope()`] for details.
53338    pub fn add_scopes<I, St>(mut self, scopes: I) -> FloodlightConfigurationUpdateCall<'a, C>
53339    where
53340        I: IntoIterator<Item = St>,
53341        St: AsRef<str>,
53342    {
53343        self._scopes
53344            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
53345        self
53346    }
53347
53348    /// Removes all scopes, and no default scope will be used either.
53349    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
53350    /// for details).
53351    pub fn clear_scopes(mut self) -> FloodlightConfigurationUpdateCall<'a, C> {
53352        self._scopes.clear();
53353        self
53354    }
53355}
53356
53357/// Gets one inventory item by ID.
53358///
53359/// A builder for the *get* method supported by a *inventoryItem* resource.
53360/// It is not used directly, but through a [`InventoryItemMethods`] instance.
53361///
53362/// # Example
53363///
53364/// Instantiate a resource method builder
53365///
53366/// ```test_harness,no_run
53367/// # extern crate hyper;
53368/// # extern crate hyper_rustls;
53369/// # extern crate google_dfareporting3d2 as dfareporting3d2;
53370/// # async fn dox() {
53371/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53372///
53373/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
53374/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
53375/// #     secret,
53376/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
53377/// # ).build().await.unwrap();
53378///
53379/// # let client = hyper_util::client::legacy::Client::builder(
53380/// #     hyper_util::rt::TokioExecutor::new()
53381/// # )
53382/// # .build(
53383/// #     hyper_rustls::HttpsConnectorBuilder::new()
53384/// #         .with_native_roots()
53385/// #         .unwrap()
53386/// #         .https_or_http()
53387/// #         .enable_http1()
53388/// #         .build()
53389/// # );
53390/// # let mut hub = Dfareporting::new(client, auth);
53391/// // You can configure optional parameters by calling the respective setters at will, and
53392/// // execute the final call using `doit()`.
53393/// // Values shown here are possibly random and not representative !
53394/// let result = hub.inventory_items().get(-65, -95, -11)
53395///              .doit().await;
53396/// # }
53397/// ```
53398pub struct InventoryItemGetCall<'a, C>
53399where
53400    C: 'a,
53401{
53402    hub: &'a Dfareporting<C>,
53403    _profile_id: i64,
53404    _project_id: i64,
53405    _id: i64,
53406    _delegate: Option<&'a mut dyn common::Delegate>,
53407    _additional_params: HashMap<String, String>,
53408    _scopes: BTreeSet<String>,
53409}
53410
53411impl<'a, C> common::CallBuilder for InventoryItemGetCall<'a, C> {}
53412
53413impl<'a, C> InventoryItemGetCall<'a, C>
53414where
53415    C: common::Connector,
53416{
53417    /// Perform the operation you have build so far.
53418    pub async fn doit(mut self) -> common::Result<(common::Response, InventoryItem)> {
53419        use std::borrow::Cow;
53420        use std::io::{Read, Seek};
53421
53422        use common::{url::Params, ToParts};
53423        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
53424
53425        let mut dd = common::DefaultDelegate;
53426        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
53427        dlg.begin(common::MethodInfo {
53428            id: "dfareporting.inventoryItems.get",
53429            http_method: hyper::Method::GET,
53430        });
53431
53432        for &field in ["alt", "profileId", "projectId", "id"].iter() {
53433            if self._additional_params.contains_key(field) {
53434                dlg.finished(false);
53435                return Err(common::Error::FieldClash(field));
53436            }
53437        }
53438
53439        let mut params = Params::with_capacity(5 + self._additional_params.len());
53440        params.push("profileId", self._profile_id.to_string());
53441        params.push("projectId", self._project_id.to_string());
53442        params.push("id", self._id.to_string());
53443
53444        params.extend(self._additional_params.iter());
53445
53446        params.push("alt", "json");
53447        let mut url = self.hub._base_url.clone()
53448            + "userprofiles/{profileId}/projects/{projectId}/inventoryItems/{id}";
53449        if self._scopes.is_empty() {
53450            self._scopes
53451                .insert(Scope::Dfatrafficking.as_ref().to_string());
53452        }
53453
53454        #[allow(clippy::single_element_loop)]
53455        for &(find_this, param_name) in [
53456            ("{profileId}", "profileId"),
53457            ("{projectId}", "projectId"),
53458            ("{id}", "id"),
53459        ]
53460        .iter()
53461        {
53462            url = params.uri_replacement(url, param_name, find_this, false);
53463        }
53464        {
53465            let to_remove = ["id", "projectId", "profileId"];
53466            params.remove_params(&to_remove);
53467        }
53468
53469        let url = params.parse_with_url(&url);
53470
53471        loop {
53472            let token = match self
53473                .hub
53474                .auth
53475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
53476                .await
53477            {
53478                Ok(token) => token,
53479                Err(e) => match dlg.token(e) {
53480                    Ok(token) => token,
53481                    Err(e) => {
53482                        dlg.finished(false);
53483                        return Err(common::Error::MissingToken(e));
53484                    }
53485                },
53486            };
53487            let mut req_result = {
53488                let client = &self.hub.client;
53489                dlg.pre_request();
53490                let mut req_builder = hyper::Request::builder()
53491                    .method(hyper::Method::GET)
53492                    .uri(url.as_str())
53493                    .header(USER_AGENT, self.hub._user_agent.clone());
53494
53495                if let Some(token) = token.as_ref() {
53496                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
53497                }
53498
53499                let request = req_builder
53500                    .header(CONTENT_LENGTH, 0_u64)
53501                    .body(common::to_body::<String>(None));
53502
53503                client.request(request.unwrap()).await
53504            };
53505
53506            match req_result {
53507                Err(err) => {
53508                    if let common::Retry::After(d) = dlg.http_error(&err) {
53509                        sleep(d).await;
53510                        continue;
53511                    }
53512                    dlg.finished(false);
53513                    return Err(common::Error::HttpError(err));
53514                }
53515                Ok(res) => {
53516                    let (mut parts, body) = res.into_parts();
53517                    let mut body = common::Body::new(body);
53518                    if !parts.status.is_success() {
53519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53520                        let error = serde_json::from_str(&common::to_string(&bytes));
53521                        let response = common::to_response(parts, bytes.into());
53522
53523                        if let common::Retry::After(d) =
53524                            dlg.http_failure(&response, error.as_ref().ok())
53525                        {
53526                            sleep(d).await;
53527                            continue;
53528                        }
53529
53530                        dlg.finished(false);
53531
53532                        return Err(match error {
53533                            Ok(value) => common::Error::BadRequest(value),
53534                            _ => common::Error::Failure(response),
53535                        });
53536                    }
53537                    let response = {
53538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53539                        let encoded = common::to_string(&bytes);
53540                        match serde_json::from_str(&encoded) {
53541                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
53542                            Err(error) => {
53543                                dlg.response_json_decode_error(&encoded, &error);
53544                                return Err(common::Error::JsonDecodeError(
53545                                    encoded.to_string(),
53546                                    error,
53547                                ));
53548                            }
53549                        }
53550                    };
53551
53552                    dlg.finished(true);
53553                    return Ok(response);
53554                }
53555            }
53556        }
53557    }
53558
53559    /// User profile ID associated with this request.
53560    ///
53561    /// Sets the *profile id* path property to the given value.
53562    ///
53563    /// Even though the property as already been set when instantiating this call,
53564    /// we provide this method for API completeness.
53565    pub fn profile_id(mut self, new_value: i64) -> InventoryItemGetCall<'a, C> {
53566        self._profile_id = new_value;
53567        self
53568    }
53569    /// Project ID for order documents.
53570    ///
53571    /// Sets the *project id* path property to the given value.
53572    ///
53573    /// Even though the property as already been set when instantiating this call,
53574    /// we provide this method for API completeness.
53575    pub fn project_id(mut self, new_value: i64) -> InventoryItemGetCall<'a, C> {
53576        self._project_id = new_value;
53577        self
53578    }
53579    /// Inventory item ID.
53580    ///
53581    /// Sets the *id* path property to the given value.
53582    ///
53583    /// Even though the property as already been set when instantiating this call,
53584    /// we provide this method for API completeness.
53585    pub fn id(mut self, new_value: i64) -> InventoryItemGetCall<'a, C> {
53586        self._id = new_value;
53587        self
53588    }
53589    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
53590    /// while executing the actual API request.
53591    ///
53592    /// ````text
53593    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
53594    /// ````
53595    ///
53596    /// Sets the *delegate* property to the given value.
53597    pub fn delegate(
53598        mut self,
53599        new_value: &'a mut dyn common::Delegate,
53600    ) -> InventoryItemGetCall<'a, C> {
53601        self._delegate = Some(new_value);
53602        self
53603    }
53604
53605    /// Set any additional parameter of the query string used in the request.
53606    /// It should be used to set parameters which are not yet available through their own
53607    /// setters.
53608    ///
53609    /// Please note that this method must not be used to set any of the known parameters
53610    /// which have their own setter method. If done anyway, the request will fail.
53611    ///
53612    /// # Additional Parameters
53613    ///
53614    /// * *alt* (query-string) - Data format for the response.
53615    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
53616    /// * *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.
53617    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
53618    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
53619    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
53620    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
53621    pub fn param<T>(mut self, name: T, value: T) -> InventoryItemGetCall<'a, C>
53622    where
53623        T: AsRef<str>,
53624    {
53625        self._additional_params
53626            .insert(name.as_ref().to_string(), value.as_ref().to_string());
53627        self
53628    }
53629
53630    /// Identifies the authorization scope for the method you are building.
53631    ///
53632    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
53633    /// [`Scope::Dfatrafficking`].
53634    ///
53635    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
53636    /// tokens for more than one scope.
53637    ///
53638    /// Usually there is more than one suitable scope to authorize an operation, some of which may
53639    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
53640    /// sufficient, a read-write scope will do as well.
53641    pub fn add_scope<St>(mut self, scope: St) -> InventoryItemGetCall<'a, C>
53642    where
53643        St: AsRef<str>,
53644    {
53645        self._scopes.insert(String::from(scope.as_ref()));
53646        self
53647    }
53648    /// Identifies the authorization scope(s) for the method you are building.
53649    ///
53650    /// See [`Self::add_scope()`] for details.
53651    pub fn add_scopes<I, St>(mut self, scopes: I) -> InventoryItemGetCall<'a, C>
53652    where
53653        I: IntoIterator<Item = St>,
53654        St: AsRef<str>,
53655    {
53656        self._scopes
53657            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
53658        self
53659    }
53660
53661    /// Removes all scopes, and no default scope will be used either.
53662    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
53663    /// for details).
53664    pub fn clear_scopes(mut self) -> InventoryItemGetCall<'a, C> {
53665        self._scopes.clear();
53666        self
53667    }
53668}
53669
53670/// Retrieves a list of inventory items, possibly filtered. This method supports paging.
53671///
53672/// A builder for the *list* method supported by a *inventoryItem* resource.
53673/// It is not used directly, but through a [`InventoryItemMethods`] instance.
53674///
53675/// # Example
53676///
53677/// Instantiate a resource method builder
53678///
53679/// ```test_harness,no_run
53680/// # extern crate hyper;
53681/// # extern crate hyper_rustls;
53682/// # extern crate google_dfareporting3d2 as dfareporting3d2;
53683/// # async fn dox() {
53684/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53685///
53686/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
53687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
53688/// #     secret,
53689/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
53690/// # ).build().await.unwrap();
53691///
53692/// # let client = hyper_util::client::legacy::Client::builder(
53693/// #     hyper_util::rt::TokioExecutor::new()
53694/// # )
53695/// # .build(
53696/// #     hyper_rustls::HttpsConnectorBuilder::new()
53697/// #         .with_native_roots()
53698/// #         .unwrap()
53699/// #         .https_or_http()
53700/// #         .enable_http1()
53701/// #         .build()
53702/// # );
53703/// # let mut hub = Dfareporting::new(client, auth);
53704/// // You can configure optional parameters by calling the respective setters at will, and
53705/// // execute the final call using `doit()`.
53706/// // Values shown here are possibly random and not representative !
53707/// let result = hub.inventory_items().list(-39, -55)
53708///              .type_("sea")
53709///              .sort_order("sit")
53710///              .sort_field("amet.")
53711///              .add_site_id(-55)
53712///              .page_token("At")
53713///              .add_order_id(-26)
53714///              .max_results(-59)
53715///              .in_plan(false)
53716///              .add_ids(-88)
53717///              .doit().await;
53718/// # }
53719/// ```
53720pub struct InventoryItemListCall<'a, C>
53721where
53722    C: 'a,
53723{
53724    hub: &'a Dfareporting<C>,
53725    _profile_id: i64,
53726    _project_id: i64,
53727    _type_: Option<String>,
53728    _sort_order: Option<String>,
53729    _sort_field: Option<String>,
53730    _site_id: Vec<i64>,
53731    _page_token: Option<String>,
53732    _order_id: Vec<i64>,
53733    _max_results: Option<i32>,
53734    _in_plan: Option<bool>,
53735    _ids: Vec<i64>,
53736    _delegate: Option<&'a mut dyn common::Delegate>,
53737    _additional_params: HashMap<String, String>,
53738    _scopes: BTreeSet<String>,
53739}
53740
53741impl<'a, C> common::CallBuilder for InventoryItemListCall<'a, C> {}
53742
53743impl<'a, C> InventoryItemListCall<'a, C>
53744where
53745    C: common::Connector,
53746{
53747    /// Perform the operation you have build so far.
53748    pub async fn doit(mut self) -> common::Result<(common::Response, InventoryItemsListResponse)> {
53749        use std::borrow::Cow;
53750        use std::io::{Read, Seek};
53751
53752        use common::{url::Params, ToParts};
53753        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
53754
53755        let mut dd = common::DefaultDelegate;
53756        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
53757        dlg.begin(common::MethodInfo {
53758            id: "dfareporting.inventoryItems.list",
53759            http_method: hyper::Method::GET,
53760        });
53761
53762        for &field in [
53763            "alt",
53764            "profileId",
53765            "projectId",
53766            "type",
53767            "sortOrder",
53768            "sortField",
53769            "siteId",
53770            "pageToken",
53771            "orderId",
53772            "maxResults",
53773            "inPlan",
53774            "ids",
53775        ]
53776        .iter()
53777        {
53778            if self._additional_params.contains_key(field) {
53779                dlg.finished(false);
53780                return Err(common::Error::FieldClash(field));
53781            }
53782        }
53783
53784        let mut params = Params::with_capacity(13 + self._additional_params.len());
53785        params.push("profileId", self._profile_id.to_string());
53786        params.push("projectId", self._project_id.to_string());
53787        if let Some(value) = self._type_.as_ref() {
53788            params.push("type", value);
53789        }
53790        if let Some(value) = self._sort_order.as_ref() {
53791            params.push("sortOrder", value);
53792        }
53793        if let Some(value) = self._sort_field.as_ref() {
53794            params.push("sortField", value);
53795        }
53796        if !self._site_id.is_empty() {
53797            for f in self._site_id.iter() {
53798                params.push("siteId", f.to_string());
53799            }
53800        }
53801        if let Some(value) = self._page_token.as_ref() {
53802            params.push("pageToken", value);
53803        }
53804        if !self._order_id.is_empty() {
53805            for f in self._order_id.iter() {
53806                params.push("orderId", f.to_string());
53807            }
53808        }
53809        if let Some(value) = self._max_results.as_ref() {
53810            params.push("maxResults", value.to_string());
53811        }
53812        if let Some(value) = self._in_plan.as_ref() {
53813            params.push("inPlan", value.to_string());
53814        }
53815        if !self._ids.is_empty() {
53816            for f in self._ids.iter() {
53817                params.push("ids", f.to_string());
53818            }
53819        }
53820
53821        params.extend(self._additional_params.iter());
53822
53823        params.push("alt", "json");
53824        let mut url = self.hub._base_url.clone()
53825            + "userprofiles/{profileId}/projects/{projectId}/inventoryItems";
53826        if self._scopes.is_empty() {
53827            self._scopes
53828                .insert(Scope::Dfatrafficking.as_ref().to_string());
53829        }
53830
53831        #[allow(clippy::single_element_loop)]
53832        for &(find_this, param_name) in
53833            [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter()
53834        {
53835            url = params.uri_replacement(url, param_name, find_this, false);
53836        }
53837        {
53838            let to_remove = ["projectId", "profileId"];
53839            params.remove_params(&to_remove);
53840        }
53841
53842        let url = params.parse_with_url(&url);
53843
53844        loop {
53845            let token = match self
53846                .hub
53847                .auth
53848                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
53849                .await
53850            {
53851                Ok(token) => token,
53852                Err(e) => match dlg.token(e) {
53853                    Ok(token) => token,
53854                    Err(e) => {
53855                        dlg.finished(false);
53856                        return Err(common::Error::MissingToken(e));
53857                    }
53858                },
53859            };
53860            let mut req_result = {
53861                let client = &self.hub.client;
53862                dlg.pre_request();
53863                let mut req_builder = hyper::Request::builder()
53864                    .method(hyper::Method::GET)
53865                    .uri(url.as_str())
53866                    .header(USER_AGENT, self.hub._user_agent.clone());
53867
53868                if let Some(token) = token.as_ref() {
53869                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
53870                }
53871
53872                let request = req_builder
53873                    .header(CONTENT_LENGTH, 0_u64)
53874                    .body(common::to_body::<String>(None));
53875
53876                client.request(request.unwrap()).await
53877            };
53878
53879            match req_result {
53880                Err(err) => {
53881                    if let common::Retry::After(d) = dlg.http_error(&err) {
53882                        sleep(d).await;
53883                        continue;
53884                    }
53885                    dlg.finished(false);
53886                    return Err(common::Error::HttpError(err));
53887                }
53888                Ok(res) => {
53889                    let (mut parts, body) = res.into_parts();
53890                    let mut body = common::Body::new(body);
53891                    if !parts.status.is_success() {
53892                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53893                        let error = serde_json::from_str(&common::to_string(&bytes));
53894                        let response = common::to_response(parts, bytes.into());
53895
53896                        if let common::Retry::After(d) =
53897                            dlg.http_failure(&response, error.as_ref().ok())
53898                        {
53899                            sleep(d).await;
53900                            continue;
53901                        }
53902
53903                        dlg.finished(false);
53904
53905                        return Err(match error {
53906                            Ok(value) => common::Error::BadRequest(value),
53907                            _ => common::Error::Failure(response),
53908                        });
53909                    }
53910                    let response = {
53911                        let bytes = common::to_bytes(body).await.unwrap_or_default();
53912                        let encoded = common::to_string(&bytes);
53913                        match serde_json::from_str(&encoded) {
53914                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
53915                            Err(error) => {
53916                                dlg.response_json_decode_error(&encoded, &error);
53917                                return Err(common::Error::JsonDecodeError(
53918                                    encoded.to_string(),
53919                                    error,
53920                                ));
53921                            }
53922                        }
53923                    };
53924
53925                    dlg.finished(true);
53926                    return Ok(response);
53927                }
53928            }
53929        }
53930    }
53931
53932    /// User profile ID associated with this request.
53933    ///
53934    /// Sets the *profile id* path property to the given value.
53935    ///
53936    /// Even though the property as already been set when instantiating this call,
53937    /// we provide this method for API completeness.
53938    pub fn profile_id(mut self, new_value: i64) -> InventoryItemListCall<'a, C> {
53939        self._profile_id = new_value;
53940        self
53941    }
53942    /// Project ID for order documents.
53943    ///
53944    /// Sets the *project id* path property to the given value.
53945    ///
53946    /// Even though the property as already been set when instantiating this call,
53947    /// we provide this method for API completeness.
53948    pub fn project_id(mut self, new_value: i64) -> InventoryItemListCall<'a, C> {
53949        self._project_id = new_value;
53950        self
53951    }
53952    /// Select only inventory items with this type.
53953    ///
53954    /// Sets the *type* query property to the given value.
53955    pub fn type_(mut self, new_value: &str) -> InventoryItemListCall<'a, C> {
53956        self._type_ = Some(new_value.to_string());
53957        self
53958    }
53959    /// Order of sorted results.
53960    ///
53961    /// Sets the *sort order* query property to the given value.
53962    pub fn sort_order(mut self, new_value: &str) -> InventoryItemListCall<'a, C> {
53963        self._sort_order = Some(new_value.to_string());
53964        self
53965    }
53966    /// Field by which to sort the list.
53967    ///
53968    /// Sets the *sort field* query property to the given value.
53969    pub fn sort_field(mut self, new_value: &str) -> InventoryItemListCall<'a, C> {
53970        self._sort_field = Some(new_value.to_string());
53971        self
53972    }
53973    /// Select only inventory items that are associated with these sites.
53974    ///
53975    /// Append the given value to the *site id* query property.
53976    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
53977    pub fn add_site_id(mut self, new_value: i64) -> InventoryItemListCall<'a, C> {
53978        self._site_id.push(new_value);
53979        self
53980    }
53981    /// Value of the nextPageToken from the previous result page.
53982    ///
53983    /// Sets the *page token* query property to the given value.
53984    pub fn page_token(mut self, new_value: &str) -> InventoryItemListCall<'a, C> {
53985        self._page_token = Some(new_value.to_string());
53986        self
53987    }
53988    /// Select only inventory items that belong to specified orders.
53989    ///
53990    /// Append the given value to the *order id* query property.
53991    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
53992    pub fn add_order_id(mut self, new_value: i64) -> InventoryItemListCall<'a, C> {
53993        self._order_id.push(new_value);
53994        self
53995    }
53996    /// Maximum number of results to return.
53997    ///
53998    /// Sets the *max results* query property to the given value.
53999    pub fn max_results(mut self, new_value: i32) -> InventoryItemListCall<'a, C> {
54000        self._max_results = Some(new_value);
54001        self
54002    }
54003    /// Select only inventory items that are in plan.
54004    ///
54005    /// Sets the *in plan* query property to the given value.
54006    pub fn in_plan(mut self, new_value: bool) -> InventoryItemListCall<'a, C> {
54007        self._in_plan = Some(new_value);
54008        self
54009    }
54010    /// Select only inventory items with these IDs.
54011    ///
54012    /// Append the given value to the *ids* query property.
54013    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
54014    pub fn add_ids(mut self, new_value: i64) -> InventoryItemListCall<'a, C> {
54015        self._ids.push(new_value);
54016        self
54017    }
54018    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
54019    /// while executing the actual API request.
54020    ///
54021    /// ````text
54022    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
54023    /// ````
54024    ///
54025    /// Sets the *delegate* property to the given value.
54026    pub fn delegate(
54027        mut self,
54028        new_value: &'a mut dyn common::Delegate,
54029    ) -> InventoryItemListCall<'a, C> {
54030        self._delegate = Some(new_value);
54031        self
54032    }
54033
54034    /// Set any additional parameter of the query string used in the request.
54035    /// It should be used to set parameters which are not yet available through their own
54036    /// setters.
54037    ///
54038    /// Please note that this method must not be used to set any of the known parameters
54039    /// which have their own setter method. If done anyway, the request will fail.
54040    ///
54041    /// # Additional Parameters
54042    ///
54043    /// * *alt* (query-string) - Data format for the response.
54044    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
54045    /// * *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.
54046    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
54047    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
54048    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
54049    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
54050    pub fn param<T>(mut self, name: T, value: T) -> InventoryItemListCall<'a, C>
54051    where
54052        T: AsRef<str>,
54053    {
54054        self._additional_params
54055            .insert(name.as_ref().to_string(), value.as_ref().to_string());
54056        self
54057    }
54058
54059    /// Identifies the authorization scope for the method you are building.
54060    ///
54061    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
54062    /// [`Scope::Dfatrafficking`].
54063    ///
54064    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
54065    /// tokens for more than one scope.
54066    ///
54067    /// Usually there is more than one suitable scope to authorize an operation, some of which may
54068    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
54069    /// sufficient, a read-write scope will do as well.
54070    pub fn add_scope<St>(mut self, scope: St) -> InventoryItemListCall<'a, C>
54071    where
54072        St: AsRef<str>,
54073    {
54074        self._scopes.insert(String::from(scope.as_ref()));
54075        self
54076    }
54077    /// Identifies the authorization scope(s) for the method you are building.
54078    ///
54079    /// See [`Self::add_scope()`] for details.
54080    pub fn add_scopes<I, St>(mut self, scopes: I) -> InventoryItemListCall<'a, C>
54081    where
54082        I: IntoIterator<Item = St>,
54083        St: AsRef<str>,
54084    {
54085        self._scopes
54086            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
54087        self
54088    }
54089
54090    /// Removes all scopes, and no default scope will be used either.
54091    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
54092    /// for details).
54093    pub fn clear_scopes(mut self) -> InventoryItemListCall<'a, C> {
54094        self._scopes.clear();
54095        self
54096    }
54097}
54098
54099/// Retrieves a list of languages.
54100///
54101/// A builder for the *list* method supported by a *language* resource.
54102/// It is not used directly, but through a [`LanguageMethods`] instance.
54103///
54104/// # Example
54105///
54106/// Instantiate a resource method builder
54107///
54108/// ```test_harness,no_run
54109/// # extern crate hyper;
54110/// # extern crate hyper_rustls;
54111/// # extern crate google_dfareporting3d2 as dfareporting3d2;
54112/// # async fn dox() {
54113/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
54114///
54115/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
54116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
54117/// #     secret,
54118/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
54119/// # ).build().await.unwrap();
54120///
54121/// # let client = hyper_util::client::legacy::Client::builder(
54122/// #     hyper_util::rt::TokioExecutor::new()
54123/// # )
54124/// # .build(
54125/// #     hyper_rustls::HttpsConnectorBuilder::new()
54126/// #         .with_native_roots()
54127/// #         .unwrap()
54128/// #         .https_or_http()
54129/// #         .enable_http1()
54130/// #         .build()
54131/// # );
54132/// # let mut hub = Dfareporting::new(client, auth);
54133/// // You can configure optional parameters by calling the respective setters at will, and
54134/// // execute the final call using `doit()`.
54135/// // Values shown here are possibly random and not representative !
54136/// let result = hub.languages().list(-33)
54137///              .doit().await;
54138/// # }
54139/// ```
54140pub struct LanguageListCall<'a, C>
54141where
54142    C: 'a,
54143{
54144    hub: &'a Dfareporting<C>,
54145    _profile_id: i64,
54146    _delegate: Option<&'a mut dyn common::Delegate>,
54147    _additional_params: HashMap<String, String>,
54148    _scopes: BTreeSet<String>,
54149}
54150
54151impl<'a, C> common::CallBuilder for LanguageListCall<'a, C> {}
54152
54153impl<'a, C> LanguageListCall<'a, C>
54154where
54155    C: common::Connector,
54156{
54157    /// Perform the operation you have build so far.
54158    pub async fn doit(mut self) -> common::Result<(common::Response, LanguagesListResponse)> {
54159        use std::borrow::Cow;
54160        use std::io::{Read, Seek};
54161
54162        use common::{url::Params, ToParts};
54163        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
54164
54165        let mut dd = common::DefaultDelegate;
54166        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
54167        dlg.begin(common::MethodInfo {
54168            id: "dfareporting.languages.list",
54169            http_method: hyper::Method::GET,
54170        });
54171
54172        for &field in ["alt", "profileId"].iter() {
54173            if self._additional_params.contains_key(field) {
54174                dlg.finished(false);
54175                return Err(common::Error::FieldClash(field));
54176            }
54177        }
54178
54179        let mut params = Params::with_capacity(3 + self._additional_params.len());
54180        params.push("profileId", self._profile_id.to_string());
54181
54182        params.extend(self._additional_params.iter());
54183
54184        params.push("alt", "json");
54185        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/languages";
54186        if self._scopes.is_empty() {
54187            self._scopes
54188                .insert(Scope::Dfatrafficking.as_ref().to_string());
54189        }
54190
54191        #[allow(clippy::single_element_loop)]
54192        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
54193            url = params.uri_replacement(url, param_name, find_this, false);
54194        }
54195        {
54196            let to_remove = ["profileId"];
54197            params.remove_params(&to_remove);
54198        }
54199
54200        let url = params.parse_with_url(&url);
54201
54202        loop {
54203            let token = match self
54204                .hub
54205                .auth
54206                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
54207                .await
54208            {
54209                Ok(token) => token,
54210                Err(e) => match dlg.token(e) {
54211                    Ok(token) => token,
54212                    Err(e) => {
54213                        dlg.finished(false);
54214                        return Err(common::Error::MissingToken(e));
54215                    }
54216                },
54217            };
54218            let mut req_result = {
54219                let client = &self.hub.client;
54220                dlg.pre_request();
54221                let mut req_builder = hyper::Request::builder()
54222                    .method(hyper::Method::GET)
54223                    .uri(url.as_str())
54224                    .header(USER_AGENT, self.hub._user_agent.clone());
54225
54226                if let Some(token) = token.as_ref() {
54227                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
54228                }
54229
54230                let request = req_builder
54231                    .header(CONTENT_LENGTH, 0_u64)
54232                    .body(common::to_body::<String>(None));
54233
54234                client.request(request.unwrap()).await
54235            };
54236
54237            match req_result {
54238                Err(err) => {
54239                    if let common::Retry::After(d) = dlg.http_error(&err) {
54240                        sleep(d).await;
54241                        continue;
54242                    }
54243                    dlg.finished(false);
54244                    return Err(common::Error::HttpError(err));
54245                }
54246                Ok(res) => {
54247                    let (mut parts, body) = res.into_parts();
54248                    let mut body = common::Body::new(body);
54249                    if !parts.status.is_success() {
54250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54251                        let error = serde_json::from_str(&common::to_string(&bytes));
54252                        let response = common::to_response(parts, bytes.into());
54253
54254                        if let common::Retry::After(d) =
54255                            dlg.http_failure(&response, error.as_ref().ok())
54256                        {
54257                            sleep(d).await;
54258                            continue;
54259                        }
54260
54261                        dlg.finished(false);
54262
54263                        return Err(match error {
54264                            Ok(value) => common::Error::BadRequest(value),
54265                            _ => common::Error::Failure(response),
54266                        });
54267                    }
54268                    let response = {
54269                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54270                        let encoded = common::to_string(&bytes);
54271                        match serde_json::from_str(&encoded) {
54272                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
54273                            Err(error) => {
54274                                dlg.response_json_decode_error(&encoded, &error);
54275                                return Err(common::Error::JsonDecodeError(
54276                                    encoded.to_string(),
54277                                    error,
54278                                ));
54279                            }
54280                        }
54281                    };
54282
54283                    dlg.finished(true);
54284                    return Ok(response);
54285                }
54286            }
54287        }
54288    }
54289
54290    /// User profile ID associated with this request.
54291    ///
54292    /// Sets the *profile id* path property to the given value.
54293    ///
54294    /// Even though the property as already been set when instantiating this call,
54295    /// we provide this method for API completeness.
54296    pub fn profile_id(mut self, new_value: i64) -> LanguageListCall<'a, C> {
54297        self._profile_id = new_value;
54298        self
54299    }
54300    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
54301    /// while executing the actual API request.
54302    ///
54303    /// ````text
54304    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
54305    /// ````
54306    ///
54307    /// Sets the *delegate* property to the given value.
54308    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LanguageListCall<'a, C> {
54309        self._delegate = Some(new_value);
54310        self
54311    }
54312
54313    /// Set any additional parameter of the query string used in the request.
54314    /// It should be used to set parameters which are not yet available through their own
54315    /// setters.
54316    ///
54317    /// Please note that this method must not be used to set any of the known parameters
54318    /// which have their own setter method. If done anyway, the request will fail.
54319    ///
54320    /// # Additional Parameters
54321    ///
54322    /// * *alt* (query-string) - Data format for the response.
54323    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
54324    /// * *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.
54325    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
54326    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
54327    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
54328    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
54329    pub fn param<T>(mut self, name: T, value: T) -> LanguageListCall<'a, C>
54330    where
54331        T: AsRef<str>,
54332    {
54333        self._additional_params
54334            .insert(name.as_ref().to_string(), value.as_ref().to_string());
54335        self
54336    }
54337
54338    /// Identifies the authorization scope for the method you are building.
54339    ///
54340    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
54341    /// [`Scope::Dfatrafficking`].
54342    ///
54343    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
54344    /// tokens for more than one scope.
54345    ///
54346    /// Usually there is more than one suitable scope to authorize an operation, some of which may
54347    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
54348    /// sufficient, a read-write scope will do as well.
54349    pub fn add_scope<St>(mut self, scope: St) -> LanguageListCall<'a, C>
54350    where
54351        St: AsRef<str>,
54352    {
54353        self._scopes.insert(String::from(scope.as_ref()));
54354        self
54355    }
54356    /// Identifies the authorization scope(s) for the method you are building.
54357    ///
54358    /// See [`Self::add_scope()`] for details.
54359    pub fn add_scopes<I, St>(mut self, scopes: I) -> LanguageListCall<'a, C>
54360    where
54361        I: IntoIterator<Item = St>,
54362        St: AsRef<str>,
54363    {
54364        self._scopes
54365            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
54366        self
54367    }
54368
54369    /// Removes all scopes, and no default scope will be used either.
54370    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
54371    /// for details).
54372    pub fn clear_scopes(mut self) -> LanguageListCall<'a, C> {
54373        self._scopes.clear();
54374        self
54375    }
54376}
54377
54378/// Retrieves a list of metros.
54379///
54380/// A builder for the *list* method supported by a *metro* resource.
54381/// It is not used directly, but through a [`MetroMethods`] instance.
54382///
54383/// # Example
54384///
54385/// Instantiate a resource method builder
54386///
54387/// ```test_harness,no_run
54388/// # extern crate hyper;
54389/// # extern crate hyper_rustls;
54390/// # extern crate google_dfareporting3d2 as dfareporting3d2;
54391/// # async fn dox() {
54392/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
54393///
54394/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
54395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
54396/// #     secret,
54397/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
54398/// # ).build().await.unwrap();
54399///
54400/// # let client = hyper_util::client::legacy::Client::builder(
54401/// #     hyper_util::rt::TokioExecutor::new()
54402/// # )
54403/// # .build(
54404/// #     hyper_rustls::HttpsConnectorBuilder::new()
54405/// #         .with_native_roots()
54406/// #         .unwrap()
54407/// #         .https_or_http()
54408/// #         .enable_http1()
54409/// #         .build()
54410/// # );
54411/// # let mut hub = Dfareporting::new(client, auth);
54412/// // You can configure optional parameters by calling the respective setters at will, and
54413/// // execute the final call using `doit()`.
54414/// // Values shown here are possibly random and not representative !
54415/// let result = hub.metros().list(-98)
54416///              .doit().await;
54417/// # }
54418/// ```
54419pub struct MetroListCall<'a, C>
54420where
54421    C: 'a,
54422{
54423    hub: &'a Dfareporting<C>,
54424    _profile_id: i64,
54425    _delegate: Option<&'a mut dyn common::Delegate>,
54426    _additional_params: HashMap<String, String>,
54427    _scopes: BTreeSet<String>,
54428}
54429
54430impl<'a, C> common::CallBuilder for MetroListCall<'a, C> {}
54431
54432impl<'a, C> MetroListCall<'a, C>
54433where
54434    C: common::Connector,
54435{
54436    /// Perform the operation you have build so far.
54437    pub async fn doit(mut self) -> common::Result<(common::Response, MetrosListResponse)> {
54438        use std::borrow::Cow;
54439        use std::io::{Read, Seek};
54440
54441        use common::{url::Params, ToParts};
54442        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
54443
54444        let mut dd = common::DefaultDelegate;
54445        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
54446        dlg.begin(common::MethodInfo {
54447            id: "dfareporting.metros.list",
54448            http_method: hyper::Method::GET,
54449        });
54450
54451        for &field in ["alt", "profileId"].iter() {
54452            if self._additional_params.contains_key(field) {
54453                dlg.finished(false);
54454                return Err(common::Error::FieldClash(field));
54455            }
54456        }
54457
54458        let mut params = Params::with_capacity(3 + self._additional_params.len());
54459        params.push("profileId", self._profile_id.to_string());
54460
54461        params.extend(self._additional_params.iter());
54462
54463        params.push("alt", "json");
54464        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/metros";
54465        if self._scopes.is_empty() {
54466            self._scopes
54467                .insert(Scope::Dfatrafficking.as_ref().to_string());
54468        }
54469
54470        #[allow(clippy::single_element_loop)]
54471        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
54472            url = params.uri_replacement(url, param_name, find_this, false);
54473        }
54474        {
54475            let to_remove = ["profileId"];
54476            params.remove_params(&to_remove);
54477        }
54478
54479        let url = params.parse_with_url(&url);
54480
54481        loop {
54482            let token = match self
54483                .hub
54484                .auth
54485                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
54486                .await
54487            {
54488                Ok(token) => token,
54489                Err(e) => match dlg.token(e) {
54490                    Ok(token) => token,
54491                    Err(e) => {
54492                        dlg.finished(false);
54493                        return Err(common::Error::MissingToken(e));
54494                    }
54495                },
54496            };
54497            let mut req_result = {
54498                let client = &self.hub.client;
54499                dlg.pre_request();
54500                let mut req_builder = hyper::Request::builder()
54501                    .method(hyper::Method::GET)
54502                    .uri(url.as_str())
54503                    .header(USER_AGENT, self.hub._user_agent.clone());
54504
54505                if let Some(token) = token.as_ref() {
54506                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
54507                }
54508
54509                let request = req_builder
54510                    .header(CONTENT_LENGTH, 0_u64)
54511                    .body(common::to_body::<String>(None));
54512
54513                client.request(request.unwrap()).await
54514            };
54515
54516            match req_result {
54517                Err(err) => {
54518                    if let common::Retry::After(d) = dlg.http_error(&err) {
54519                        sleep(d).await;
54520                        continue;
54521                    }
54522                    dlg.finished(false);
54523                    return Err(common::Error::HttpError(err));
54524                }
54525                Ok(res) => {
54526                    let (mut parts, body) = res.into_parts();
54527                    let mut body = common::Body::new(body);
54528                    if !parts.status.is_success() {
54529                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54530                        let error = serde_json::from_str(&common::to_string(&bytes));
54531                        let response = common::to_response(parts, bytes.into());
54532
54533                        if let common::Retry::After(d) =
54534                            dlg.http_failure(&response, error.as_ref().ok())
54535                        {
54536                            sleep(d).await;
54537                            continue;
54538                        }
54539
54540                        dlg.finished(false);
54541
54542                        return Err(match error {
54543                            Ok(value) => common::Error::BadRequest(value),
54544                            _ => common::Error::Failure(response),
54545                        });
54546                    }
54547                    let response = {
54548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54549                        let encoded = common::to_string(&bytes);
54550                        match serde_json::from_str(&encoded) {
54551                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
54552                            Err(error) => {
54553                                dlg.response_json_decode_error(&encoded, &error);
54554                                return Err(common::Error::JsonDecodeError(
54555                                    encoded.to_string(),
54556                                    error,
54557                                ));
54558                            }
54559                        }
54560                    };
54561
54562                    dlg.finished(true);
54563                    return Ok(response);
54564                }
54565            }
54566        }
54567    }
54568
54569    /// User profile ID associated with this request.
54570    ///
54571    /// Sets the *profile id* path property to the given value.
54572    ///
54573    /// Even though the property as already been set when instantiating this call,
54574    /// we provide this method for API completeness.
54575    pub fn profile_id(mut self, new_value: i64) -> MetroListCall<'a, C> {
54576        self._profile_id = new_value;
54577        self
54578    }
54579    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
54580    /// while executing the actual API request.
54581    ///
54582    /// ````text
54583    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
54584    /// ````
54585    ///
54586    /// Sets the *delegate* property to the given value.
54587    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MetroListCall<'a, C> {
54588        self._delegate = Some(new_value);
54589        self
54590    }
54591
54592    /// Set any additional parameter of the query string used in the request.
54593    /// It should be used to set parameters which are not yet available through their own
54594    /// setters.
54595    ///
54596    /// Please note that this method must not be used to set any of the known parameters
54597    /// which have their own setter method. If done anyway, the request will fail.
54598    ///
54599    /// # Additional Parameters
54600    ///
54601    /// * *alt* (query-string) - Data format for the response.
54602    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
54603    /// * *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.
54604    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
54605    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
54606    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
54607    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
54608    pub fn param<T>(mut self, name: T, value: T) -> MetroListCall<'a, C>
54609    where
54610        T: AsRef<str>,
54611    {
54612        self._additional_params
54613            .insert(name.as_ref().to_string(), value.as_ref().to_string());
54614        self
54615    }
54616
54617    /// Identifies the authorization scope for the method you are building.
54618    ///
54619    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
54620    /// [`Scope::Dfatrafficking`].
54621    ///
54622    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
54623    /// tokens for more than one scope.
54624    ///
54625    /// Usually there is more than one suitable scope to authorize an operation, some of which may
54626    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
54627    /// sufficient, a read-write scope will do as well.
54628    pub fn add_scope<St>(mut self, scope: St) -> MetroListCall<'a, C>
54629    where
54630        St: AsRef<str>,
54631    {
54632        self._scopes.insert(String::from(scope.as_ref()));
54633        self
54634    }
54635    /// Identifies the authorization scope(s) for the method you are building.
54636    ///
54637    /// See [`Self::add_scope()`] for details.
54638    pub fn add_scopes<I, St>(mut self, scopes: I) -> MetroListCall<'a, C>
54639    where
54640        I: IntoIterator<Item = St>,
54641        St: AsRef<str>,
54642    {
54643        self._scopes
54644            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
54645        self
54646    }
54647
54648    /// Removes all scopes, and no default scope will be used either.
54649    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
54650    /// for details).
54651    pub fn clear_scopes(mut self) -> MetroListCall<'a, C> {
54652        self._scopes.clear();
54653        self
54654    }
54655}
54656
54657/// Gets one mobile app by ID.
54658///
54659/// A builder for the *get* method supported by a *mobileApp* resource.
54660/// It is not used directly, but through a [`MobileAppMethods`] instance.
54661///
54662/// # Example
54663///
54664/// Instantiate a resource method builder
54665///
54666/// ```test_harness,no_run
54667/// # extern crate hyper;
54668/// # extern crate hyper_rustls;
54669/// # extern crate google_dfareporting3d2 as dfareporting3d2;
54670/// # async fn dox() {
54671/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
54672///
54673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
54674/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
54675/// #     secret,
54676/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
54677/// # ).build().await.unwrap();
54678///
54679/// # let client = hyper_util::client::legacy::Client::builder(
54680/// #     hyper_util::rt::TokioExecutor::new()
54681/// # )
54682/// # .build(
54683/// #     hyper_rustls::HttpsConnectorBuilder::new()
54684/// #         .with_native_roots()
54685/// #         .unwrap()
54686/// #         .https_or_http()
54687/// #         .enable_http1()
54688/// #         .build()
54689/// # );
54690/// # let mut hub = Dfareporting::new(client, auth);
54691/// // You can configure optional parameters by calling the respective setters at will, and
54692/// // execute the final call using `doit()`.
54693/// // Values shown here are possibly random and not representative !
54694/// let result = hub.mobile_apps().get(-12, "id")
54695///              .doit().await;
54696/// # }
54697/// ```
54698pub struct MobileAppGetCall<'a, C>
54699where
54700    C: 'a,
54701{
54702    hub: &'a Dfareporting<C>,
54703    _profile_id: i64,
54704    _id: String,
54705    _delegate: Option<&'a mut dyn common::Delegate>,
54706    _additional_params: HashMap<String, String>,
54707    _scopes: BTreeSet<String>,
54708}
54709
54710impl<'a, C> common::CallBuilder for MobileAppGetCall<'a, C> {}
54711
54712impl<'a, C> MobileAppGetCall<'a, C>
54713where
54714    C: common::Connector,
54715{
54716    /// Perform the operation you have build so far.
54717    pub async fn doit(mut self) -> common::Result<(common::Response, MobileApp)> {
54718        use std::borrow::Cow;
54719        use std::io::{Read, Seek};
54720
54721        use common::{url::Params, ToParts};
54722        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
54723
54724        let mut dd = common::DefaultDelegate;
54725        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
54726        dlg.begin(common::MethodInfo {
54727            id: "dfareporting.mobileApps.get",
54728            http_method: hyper::Method::GET,
54729        });
54730
54731        for &field in ["alt", "profileId", "id"].iter() {
54732            if self._additional_params.contains_key(field) {
54733                dlg.finished(false);
54734                return Err(common::Error::FieldClash(field));
54735            }
54736        }
54737
54738        let mut params = Params::with_capacity(4 + self._additional_params.len());
54739        params.push("profileId", self._profile_id.to_string());
54740        params.push("id", self._id);
54741
54742        params.extend(self._additional_params.iter());
54743
54744        params.push("alt", "json");
54745        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileApps/{id}";
54746        if self._scopes.is_empty() {
54747            self._scopes
54748                .insert(Scope::Dfatrafficking.as_ref().to_string());
54749        }
54750
54751        #[allow(clippy::single_element_loop)]
54752        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
54753            url = params.uri_replacement(url, param_name, find_this, false);
54754        }
54755        {
54756            let to_remove = ["id", "profileId"];
54757            params.remove_params(&to_remove);
54758        }
54759
54760        let url = params.parse_with_url(&url);
54761
54762        loop {
54763            let token = match self
54764                .hub
54765                .auth
54766                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
54767                .await
54768            {
54769                Ok(token) => token,
54770                Err(e) => match dlg.token(e) {
54771                    Ok(token) => token,
54772                    Err(e) => {
54773                        dlg.finished(false);
54774                        return Err(common::Error::MissingToken(e));
54775                    }
54776                },
54777            };
54778            let mut req_result = {
54779                let client = &self.hub.client;
54780                dlg.pre_request();
54781                let mut req_builder = hyper::Request::builder()
54782                    .method(hyper::Method::GET)
54783                    .uri(url.as_str())
54784                    .header(USER_AGENT, self.hub._user_agent.clone());
54785
54786                if let Some(token) = token.as_ref() {
54787                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
54788                }
54789
54790                let request = req_builder
54791                    .header(CONTENT_LENGTH, 0_u64)
54792                    .body(common::to_body::<String>(None));
54793
54794                client.request(request.unwrap()).await
54795            };
54796
54797            match req_result {
54798                Err(err) => {
54799                    if let common::Retry::After(d) = dlg.http_error(&err) {
54800                        sleep(d).await;
54801                        continue;
54802                    }
54803                    dlg.finished(false);
54804                    return Err(common::Error::HttpError(err));
54805                }
54806                Ok(res) => {
54807                    let (mut parts, body) = res.into_parts();
54808                    let mut body = common::Body::new(body);
54809                    if !parts.status.is_success() {
54810                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54811                        let error = serde_json::from_str(&common::to_string(&bytes));
54812                        let response = common::to_response(parts, bytes.into());
54813
54814                        if let common::Retry::After(d) =
54815                            dlg.http_failure(&response, error.as_ref().ok())
54816                        {
54817                            sleep(d).await;
54818                            continue;
54819                        }
54820
54821                        dlg.finished(false);
54822
54823                        return Err(match error {
54824                            Ok(value) => common::Error::BadRequest(value),
54825                            _ => common::Error::Failure(response),
54826                        });
54827                    }
54828                    let response = {
54829                        let bytes = common::to_bytes(body).await.unwrap_or_default();
54830                        let encoded = common::to_string(&bytes);
54831                        match serde_json::from_str(&encoded) {
54832                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
54833                            Err(error) => {
54834                                dlg.response_json_decode_error(&encoded, &error);
54835                                return Err(common::Error::JsonDecodeError(
54836                                    encoded.to_string(),
54837                                    error,
54838                                ));
54839                            }
54840                        }
54841                    };
54842
54843                    dlg.finished(true);
54844                    return Ok(response);
54845                }
54846            }
54847        }
54848    }
54849
54850    /// User profile ID associated with this request.
54851    ///
54852    /// Sets the *profile id* path property to the given value.
54853    ///
54854    /// Even though the property as already been set when instantiating this call,
54855    /// we provide this method for API completeness.
54856    pub fn profile_id(mut self, new_value: i64) -> MobileAppGetCall<'a, C> {
54857        self._profile_id = new_value;
54858        self
54859    }
54860    /// Mobile app ID.
54861    ///
54862    /// Sets the *id* path property to the given value.
54863    ///
54864    /// Even though the property as already been set when instantiating this call,
54865    /// we provide this method for API completeness.
54866    pub fn id(mut self, new_value: &str) -> MobileAppGetCall<'a, C> {
54867        self._id = new_value.to_string();
54868        self
54869    }
54870    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
54871    /// while executing the actual API request.
54872    ///
54873    /// ````text
54874    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
54875    /// ````
54876    ///
54877    /// Sets the *delegate* property to the given value.
54878    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MobileAppGetCall<'a, C> {
54879        self._delegate = Some(new_value);
54880        self
54881    }
54882
54883    /// Set any additional parameter of the query string used in the request.
54884    /// It should be used to set parameters which are not yet available through their own
54885    /// setters.
54886    ///
54887    /// Please note that this method must not be used to set any of the known parameters
54888    /// which have their own setter method. If done anyway, the request will fail.
54889    ///
54890    /// # Additional Parameters
54891    ///
54892    /// * *alt* (query-string) - Data format for the response.
54893    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
54894    /// * *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.
54895    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
54896    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
54897    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
54898    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
54899    pub fn param<T>(mut self, name: T, value: T) -> MobileAppGetCall<'a, C>
54900    where
54901        T: AsRef<str>,
54902    {
54903        self._additional_params
54904            .insert(name.as_ref().to_string(), value.as_ref().to_string());
54905        self
54906    }
54907
54908    /// Identifies the authorization scope for the method you are building.
54909    ///
54910    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
54911    /// [`Scope::Dfatrafficking`].
54912    ///
54913    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
54914    /// tokens for more than one scope.
54915    ///
54916    /// Usually there is more than one suitable scope to authorize an operation, some of which may
54917    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
54918    /// sufficient, a read-write scope will do as well.
54919    pub fn add_scope<St>(mut self, scope: St) -> MobileAppGetCall<'a, C>
54920    where
54921        St: AsRef<str>,
54922    {
54923        self._scopes.insert(String::from(scope.as_ref()));
54924        self
54925    }
54926    /// Identifies the authorization scope(s) for the method you are building.
54927    ///
54928    /// See [`Self::add_scope()`] for details.
54929    pub fn add_scopes<I, St>(mut self, scopes: I) -> MobileAppGetCall<'a, C>
54930    where
54931        I: IntoIterator<Item = St>,
54932        St: AsRef<str>,
54933    {
54934        self._scopes
54935            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
54936        self
54937    }
54938
54939    /// Removes all scopes, and no default scope will be used either.
54940    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
54941    /// for details).
54942    pub fn clear_scopes(mut self) -> MobileAppGetCall<'a, C> {
54943        self._scopes.clear();
54944        self
54945    }
54946}
54947
54948/// Retrieves list of available mobile apps.
54949///
54950/// A builder for the *list* method supported by a *mobileApp* resource.
54951/// It is not used directly, but through a [`MobileAppMethods`] instance.
54952///
54953/// # Example
54954///
54955/// Instantiate a resource method builder
54956///
54957/// ```test_harness,no_run
54958/// # extern crate hyper;
54959/// # extern crate hyper_rustls;
54960/// # extern crate google_dfareporting3d2 as dfareporting3d2;
54961/// # async fn dox() {
54962/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
54963///
54964/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
54965/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
54966/// #     secret,
54967/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
54968/// # ).build().await.unwrap();
54969///
54970/// # let client = hyper_util::client::legacy::Client::builder(
54971/// #     hyper_util::rt::TokioExecutor::new()
54972/// # )
54973/// # .build(
54974/// #     hyper_rustls::HttpsConnectorBuilder::new()
54975/// #         .with_native_roots()
54976/// #         .unwrap()
54977/// #         .https_or_http()
54978/// #         .enable_http1()
54979/// #         .build()
54980/// # );
54981/// # let mut hub = Dfareporting::new(client, auth);
54982/// // You can configure optional parameters by calling the respective setters at will, and
54983/// // execute the final call using `doit()`.
54984/// // Values shown here are possibly random and not representative !
54985/// let result = hub.mobile_apps().list(-50)
54986///              .search_string("kasd")
54987///              .page_token("dolore")
54988///              .max_results(-51)
54989///              .add_ids("amet")
54990///              .add_directories("ipsum")
54991///              .doit().await;
54992/// # }
54993/// ```
54994pub struct MobileAppListCall<'a, C>
54995where
54996    C: 'a,
54997{
54998    hub: &'a Dfareporting<C>,
54999    _profile_id: i64,
55000    _search_string: Option<String>,
55001    _page_token: Option<String>,
55002    _max_results: Option<i32>,
55003    _ids: Vec<String>,
55004    _directories: Vec<String>,
55005    _delegate: Option<&'a mut dyn common::Delegate>,
55006    _additional_params: HashMap<String, String>,
55007    _scopes: BTreeSet<String>,
55008}
55009
55010impl<'a, C> common::CallBuilder for MobileAppListCall<'a, C> {}
55011
55012impl<'a, C> MobileAppListCall<'a, C>
55013where
55014    C: common::Connector,
55015{
55016    /// Perform the operation you have build so far.
55017    pub async fn doit(mut self) -> common::Result<(common::Response, MobileAppsListResponse)> {
55018        use std::borrow::Cow;
55019        use std::io::{Read, Seek};
55020
55021        use common::{url::Params, ToParts};
55022        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
55023
55024        let mut dd = common::DefaultDelegate;
55025        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
55026        dlg.begin(common::MethodInfo {
55027            id: "dfareporting.mobileApps.list",
55028            http_method: hyper::Method::GET,
55029        });
55030
55031        for &field in [
55032            "alt",
55033            "profileId",
55034            "searchString",
55035            "pageToken",
55036            "maxResults",
55037            "ids",
55038            "directories",
55039        ]
55040        .iter()
55041        {
55042            if self._additional_params.contains_key(field) {
55043                dlg.finished(false);
55044                return Err(common::Error::FieldClash(field));
55045            }
55046        }
55047
55048        let mut params = Params::with_capacity(8 + self._additional_params.len());
55049        params.push("profileId", self._profile_id.to_string());
55050        if let Some(value) = self._search_string.as_ref() {
55051            params.push("searchString", value);
55052        }
55053        if let Some(value) = self._page_token.as_ref() {
55054            params.push("pageToken", value);
55055        }
55056        if let Some(value) = self._max_results.as_ref() {
55057            params.push("maxResults", value.to_string());
55058        }
55059        if !self._ids.is_empty() {
55060            for f in self._ids.iter() {
55061                params.push("ids", f);
55062            }
55063        }
55064        if !self._directories.is_empty() {
55065            for f in self._directories.iter() {
55066                params.push("directories", f);
55067            }
55068        }
55069
55070        params.extend(self._additional_params.iter());
55071
55072        params.push("alt", "json");
55073        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileApps";
55074        if self._scopes.is_empty() {
55075            self._scopes
55076                .insert(Scope::Dfatrafficking.as_ref().to_string());
55077        }
55078
55079        #[allow(clippy::single_element_loop)]
55080        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
55081            url = params.uri_replacement(url, param_name, find_this, false);
55082        }
55083        {
55084            let to_remove = ["profileId"];
55085            params.remove_params(&to_remove);
55086        }
55087
55088        let url = params.parse_with_url(&url);
55089
55090        loop {
55091            let token = match self
55092                .hub
55093                .auth
55094                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
55095                .await
55096            {
55097                Ok(token) => token,
55098                Err(e) => match dlg.token(e) {
55099                    Ok(token) => token,
55100                    Err(e) => {
55101                        dlg.finished(false);
55102                        return Err(common::Error::MissingToken(e));
55103                    }
55104                },
55105            };
55106            let mut req_result = {
55107                let client = &self.hub.client;
55108                dlg.pre_request();
55109                let mut req_builder = hyper::Request::builder()
55110                    .method(hyper::Method::GET)
55111                    .uri(url.as_str())
55112                    .header(USER_AGENT, self.hub._user_agent.clone());
55113
55114                if let Some(token) = token.as_ref() {
55115                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
55116                }
55117
55118                let request = req_builder
55119                    .header(CONTENT_LENGTH, 0_u64)
55120                    .body(common::to_body::<String>(None));
55121
55122                client.request(request.unwrap()).await
55123            };
55124
55125            match req_result {
55126                Err(err) => {
55127                    if let common::Retry::After(d) = dlg.http_error(&err) {
55128                        sleep(d).await;
55129                        continue;
55130                    }
55131                    dlg.finished(false);
55132                    return Err(common::Error::HttpError(err));
55133                }
55134                Ok(res) => {
55135                    let (mut parts, body) = res.into_parts();
55136                    let mut body = common::Body::new(body);
55137                    if !parts.status.is_success() {
55138                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55139                        let error = serde_json::from_str(&common::to_string(&bytes));
55140                        let response = common::to_response(parts, bytes.into());
55141
55142                        if let common::Retry::After(d) =
55143                            dlg.http_failure(&response, error.as_ref().ok())
55144                        {
55145                            sleep(d).await;
55146                            continue;
55147                        }
55148
55149                        dlg.finished(false);
55150
55151                        return Err(match error {
55152                            Ok(value) => common::Error::BadRequest(value),
55153                            _ => common::Error::Failure(response),
55154                        });
55155                    }
55156                    let response = {
55157                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55158                        let encoded = common::to_string(&bytes);
55159                        match serde_json::from_str(&encoded) {
55160                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
55161                            Err(error) => {
55162                                dlg.response_json_decode_error(&encoded, &error);
55163                                return Err(common::Error::JsonDecodeError(
55164                                    encoded.to_string(),
55165                                    error,
55166                                ));
55167                            }
55168                        }
55169                    };
55170
55171                    dlg.finished(true);
55172                    return Ok(response);
55173                }
55174            }
55175        }
55176    }
55177
55178    /// User profile ID associated with this request.
55179    ///
55180    /// Sets the *profile id* path property to the given value.
55181    ///
55182    /// Even though the property as already been set when instantiating this call,
55183    /// we provide this method for API completeness.
55184    pub fn profile_id(mut self, new_value: i64) -> MobileAppListCall<'a, C> {
55185        self._profile_id = new_value;
55186        self
55187    }
55188    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "app*2015" will return objects with names like "app Jan 2018", "app Jan 2018", or simply "app 2018". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "app" will match objects with name "my app", "app 2018", or simply "app".
55189    ///
55190    /// Sets the *search string* query property to the given value.
55191    pub fn search_string(mut self, new_value: &str) -> MobileAppListCall<'a, C> {
55192        self._search_string = Some(new_value.to_string());
55193        self
55194    }
55195    /// Value of the nextPageToken from the previous result page.
55196    ///
55197    /// Sets the *page token* query property to the given value.
55198    pub fn page_token(mut self, new_value: &str) -> MobileAppListCall<'a, C> {
55199        self._page_token = Some(new_value.to_string());
55200        self
55201    }
55202    /// Maximum number of results to return.
55203    ///
55204    /// Sets the *max results* query property to the given value.
55205    pub fn max_results(mut self, new_value: i32) -> MobileAppListCall<'a, C> {
55206        self._max_results = Some(new_value);
55207        self
55208    }
55209    /// Select only apps with these IDs.
55210    ///
55211    /// Append the given value to the *ids* query property.
55212    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
55213    pub fn add_ids(mut self, new_value: &str) -> MobileAppListCall<'a, C> {
55214        self._ids.push(new_value.to_string());
55215        self
55216    }
55217    /// Select only apps from these directories.
55218    ///
55219    /// Append the given value to the *directories* query property.
55220    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
55221    pub fn add_directories(mut self, new_value: &str) -> MobileAppListCall<'a, C> {
55222        self._directories.push(new_value.to_string());
55223        self
55224    }
55225    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
55226    /// while executing the actual API request.
55227    ///
55228    /// ````text
55229    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
55230    /// ````
55231    ///
55232    /// Sets the *delegate* property to the given value.
55233    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MobileAppListCall<'a, C> {
55234        self._delegate = Some(new_value);
55235        self
55236    }
55237
55238    /// Set any additional parameter of the query string used in the request.
55239    /// It should be used to set parameters which are not yet available through their own
55240    /// setters.
55241    ///
55242    /// Please note that this method must not be used to set any of the known parameters
55243    /// which have their own setter method. If done anyway, the request will fail.
55244    ///
55245    /// # Additional Parameters
55246    ///
55247    /// * *alt* (query-string) - Data format for the response.
55248    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
55249    /// * *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.
55250    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
55251    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
55252    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
55253    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
55254    pub fn param<T>(mut self, name: T, value: T) -> MobileAppListCall<'a, C>
55255    where
55256        T: AsRef<str>,
55257    {
55258        self._additional_params
55259            .insert(name.as_ref().to_string(), value.as_ref().to_string());
55260        self
55261    }
55262
55263    /// Identifies the authorization scope for the method you are building.
55264    ///
55265    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
55266    /// [`Scope::Dfatrafficking`].
55267    ///
55268    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
55269    /// tokens for more than one scope.
55270    ///
55271    /// Usually there is more than one suitable scope to authorize an operation, some of which may
55272    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
55273    /// sufficient, a read-write scope will do as well.
55274    pub fn add_scope<St>(mut self, scope: St) -> MobileAppListCall<'a, C>
55275    where
55276        St: AsRef<str>,
55277    {
55278        self._scopes.insert(String::from(scope.as_ref()));
55279        self
55280    }
55281    /// Identifies the authorization scope(s) for the method you are building.
55282    ///
55283    /// See [`Self::add_scope()`] for details.
55284    pub fn add_scopes<I, St>(mut self, scopes: I) -> MobileAppListCall<'a, C>
55285    where
55286        I: IntoIterator<Item = St>,
55287        St: AsRef<str>,
55288    {
55289        self._scopes
55290            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
55291        self
55292    }
55293
55294    /// Removes all scopes, and no default scope will be used either.
55295    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
55296    /// for details).
55297    pub fn clear_scopes(mut self) -> MobileAppListCall<'a, C> {
55298        self._scopes.clear();
55299        self
55300    }
55301}
55302
55303/// Gets one mobile carrier by ID.
55304///
55305/// A builder for the *get* method supported by a *mobileCarrier* resource.
55306/// It is not used directly, but through a [`MobileCarrierMethods`] instance.
55307///
55308/// # Example
55309///
55310/// Instantiate a resource method builder
55311///
55312/// ```test_harness,no_run
55313/// # extern crate hyper;
55314/// # extern crate hyper_rustls;
55315/// # extern crate google_dfareporting3d2 as dfareporting3d2;
55316/// # async fn dox() {
55317/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
55318///
55319/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
55320/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
55321/// #     secret,
55322/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
55323/// # ).build().await.unwrap();
55324///
55325/// # let client = hyper_util::client::legacy::Client::builder(
55326/// #     hyper_util::rt::TokioExecutor::new()
55327/// # )
55328/// # .build(
55329/// #     hyper_rustls::HttpsConnectorBuilder::new()
55330/// #         .with_native_roots()
55331/// #         .unwrap()
55332/// #         .https_or_http()
55333/// #         .enable_http1()
55334/// #         .build()
55335/// # );
55336/// # let mut hub = Dfareporting::new(client, auth);
55337/// // You can configure optional parameters by calling the respective setters at will, and
55338/// // execute the final call using `doit()`.
55339/// // Values shown here are possibly random and not representative !
55340/// let result = hub.mobile_carriers().get(-101, -19)
55341///              .doit().await;
55342/// # }
55343/// ```
55344pub struct MobileCarrierGetCall<'a, C>
55345where
55346    C: 'a,
55347{
55348    hub: &'a Dfareporting<C>,
55349    _profile_id: i64,
55350    _id: i64,
55351    _delegate: Option<&'a mut dyn common::Delegate>,
55352    _additional_params: HashMap<String, String>,
55353    _scopes: BTreeSet<String>,
55354}
55355
55356impl<'a, C> common::CallBuilder for MobileCarrierGetCall<'a, C> {}
55357
55358impl<'a, C> MobileCarrierGetCall<'a, C>
55359where
55360    C: common::Connector,
55361{
55362    /// Perform the operation you have build so far.
55363    pub async fn doit(mut self) -> common::Result<(common::Response, MobileCarrier)> {
55364        use std::borrow::Cow;
55365        use std::io::{Read, Seek};
55366
55367        use common::{url::Params, ToParts};
55368        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
55369
55370        let mut dd = common::DefaultDelegate;
55371        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
55372        dlg.begin(common::MethodInfo {
55373            id: "dfareporting.mobileCarriers.get",
55374            http_method: hyper::Method::GET,
55375        });
55376
55377        for &field in ["alt", "profileId", "id"].iter() {
55378            if self._additional_params.contains_key(field) {
55379                dlg.finished(false);
55380                return Err(common::Error::FieldClash(field));
55381            }
55382        }
55383
55384        let mut params = Params::with_capacity(4 + self._additional_params.len());
55385        params.push("profileId", self._profile_id.to_string());
55386        params.push("id", self._id.to_string());
55387
55388        params.extend(self._additional_params.iter());
55389
55390        params.push("alt", "json");
55391        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileCarriers/{id}";
55392        if self._scopes.is_empty() {
55393            self._scopes
55394                .insert(Scope::Dfatrafficking.as_ref().to_string());
55395        }
55396
55397        #[allow(clippy::single_element_loop)]
55398        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
55399            url = params.uri_replacement(url, param_name, find_this, false);
55400        }
55401        {
55402            let to_remove = ["id", "profileId"];
55403            params.remove_params(&to_remove);
55404        }
55405
55406        let url = params.parse_with_url(&url);
55407
55408        loop {
55409            let token = match self
55410                .hub
55411                .auth
55412                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
55413                .await
55414            {
55415                Ok(token) => token,
55416                Err(e) => match dlg.token(e) {
55417                    Ok(token) => token,
55418                    Err(e) => {
55419                        dlg.finished(false);
55420                        return Err(common::Error::MissingToken(e));
55421                    }
55422                },
55423            };
55424            let mut req_result = {
55425                let client = &self.hub.client;
55426                dlg.pre_request();
55427                let mut req_builder = hyper::Request::builder()
55428                    .method(hyper::Method::GET)
55429                    .uri(url.as_str())
55430                    .header(USER_AGENT, self.hub._user_agent.clone());
55431
55432                if let Some(token) = token.as_ref() {
55433                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
55434                }
55435
55436                let request = req_builder
55437                    .header(CONTENT_LENGTH, 0_u64)
55438                    .body(common::to_body::<String>(None));
55439
55440                client.request(request.unwrap()).await
55441            };
55442
55443            match req_result {
55444                Err(err) => {
55445                    if let common::Retry::After(d) = dlg.http_error(&err) {
55446                        sleep(d).await;
55447                        continue;
55448                    }
55449                    dlg.finished(false);
55450                    return Err(common::Error::HttpError(err));
55451                }
55452                Ok(res) => {
55453                    let (mut parts, body) = res.into_parts();
55454                    let mut body = common::Body::new(body);
55455                    if !parts.status.is_success() {
55456                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55457                        let error = serde_json::from_str(&common::to_string(&bytes));
55458                        let response = common::to_response(parts, bytes.into());
55459
55460                        if let common::Retry::After(d) =
55461                            dlg.http_failure(&response, error.as_ref().ok())
55462                        {
55463                            sleep(d).await;
55464                            continue;
55465                        }
55466
55467                        dlg.finished(false);
55468
55469                        return Err(match error {
55470                            Ok(value) => common::Error::BadRequest(value),
55471                            _ => common::Error::Failure(response),
55472                        });
55473                    }
55474                    let response = {
55475                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55476                        let encoded = common::to_string(&bytes);
55477                        match serde_json::from_str(&encoded) {
55478                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
55479                            Err(error) => {
55480                                dlg.response_json_decode_error(&encoded, &error);
55481                                return Err(common::Error::JsonDecodeError(
55482                                    encoded.to_string(),
55483                                    error,
55484                                ));
55485                            }
55486                        }
55487                    };
55488
55489                    dlg.finished(true);
55490                    return Ok(response);
55491                }
55492            }
55493        }
55494    }
55495
55496    /// User profile ID associated with this request.
55497    ///
55498    /// Sets the *profile id* path property to the given value.
55499    ///
55500    /// Even though the property as already been set when instantiating this call,
55501    /// we provide this method for API completeness.
55502    pub fn profile_id(mut self, new_value: i64) -> MobileCarrierGetCall<'a, C> {
55503        self._profile_id = new_value;
55504        self
55505    }
55506    /// Mobile carrier ID.
55507    ///
55508    /// Sets the *id* path property to the given value.
55509    ///
55510    /// Even though the property as already been set when instantiating this call,
55511    /// we provide this method for API completeness.
55512    pub fn id(mut self, new_value: i64) -> MobileCarrierGetCall<'a, C> {
55513        self._id = new_value;
55514        self
55515    }
55516    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
55517    /// while executing the actual API request.
55518    ///
55519    /// ````text
55520    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
55521    /// ````
55522    ///
55523    /// Sets the *delegate* property to the given value.
55524    pub fn delegate(
55525        mut self,
55526        new_value: &'a mut dyn common::Delegate,
55527    ) -> MobileCarrierGetCall<'a, C> {
55528        self._delegate = Some(new_value);
55529        self
55530    }
55531
55532    /// Set any additional parameter of the query string used in the request.
55533    /// It should be used to set parameters which are not yet available through their own
55534    /// setters.
55535    ///
55536    /// Please note that this method must not be used to set any of the known parameters
55537    /// which have their own setter method. If done anyway, the request will fail.
55538    ///
55539    /// # Additional Parameters
55540    ///
55541    /// * *alt* (query-string) - Data format for the response.
55542    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
55543    /// * *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.
55544    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
55545    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
55546    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
55547    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
55548    pub fn param<T>(mut self, name: T, value: T) -> MobileCarrierGetCall<'a, C>
55549    where
55550        T: AsRef<str>,
55551    {
55552        self._additional_params
55553            .insert(name.as_ref().to_string(), value.as_ref().to_string());
55554        self
55555    }
55556
55557    /// Identifies the authorization scope for the method you are building.
55558    ///
55559    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
55560    /// [`Scope::Dfatrafficking`].
55561    ///
55562    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
55563    /// tokens for more than one scope.
55564    ///
55565    /// Usually there is more than one suitable scope to authorize an operation, some of which may
55566    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
55567    /// sufficient, a read-write scope will do as well.
55568    pub fn add_scope<St>(mut self, scope: St) -> MobileCarrierGetCall<'a, C>
55569    where
55570        St: AsRef<str>,
55571    {
55572        self._scopes.insert(String::from(scope.as_ref()));
55573        self
55574    }
55575    /// Identifies the authorization scope(s) for the method you are building.
55576    ///
55577    /// See [`Self::add_scope()`] for details.
55578    pub fn add_scopes<I, St>(mut self, scopes: I) -> MobileCarrierGetCall<'a, C>
55579    where
55580        I: IntoIterator<Item = St>,
55581        St: AsRef<str>,
55582    {
55583        self._scopes
55584            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
55585        self
55586    }
55587
55588    /// Removes all scopes, and no default scope will be used either.
55589    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
55590    /// for details).
55591    pub fn clear_scopes(mut self) -> MobileCarrierGetCall<'a, C> {
55592        self._scopes.clear();
55593        self
55594    }
55595}
55596
55597/// Retrieves a list of mobile carriers.
55598///
55599/// A builder for the *list* method supported by a *mobileCarrier* resource.
55600/// It is not used directly, but through a [`MobileCarrierMethods`] instance.
55601///
55602/// # Example
55603///
55604/// Instantiate a resource method builder
55605///
55606/// ```test_harness,no_run
55607/// # extern crate hyper;
55608/// # extern crate hyper_rustls;
55609/// # extern crate google_dfareporting3d2 as dfareporting3d2;
55610/// # async fn dox() {
55611/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
55612///
55613/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
55614/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
55615/// #     secret,
55616/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
55617/// # ).build().await.unwrap();
55618///
55619/// # let client = hyper_util::client::legacy::Client::builder(
55620/// #     hyper_util::rt::TokioExecutor::new()
55621/// # )
55622/// # .build(
55623/// #     hyper_rustls::HttpsConnectorBuilder::new()
55624/// #         .with_native_roots()
55625/// #         .unwrap()
55626/// #         .https_or_http()
55627/// #         .enable_http1()
55628/// #         .build()
55629/// # );
55630/// # let mut hub = Dfareporting::new(client, auth);
55631/// // You can configure optional parameters by calling the respective setters at will, and
55632/// // execute the final call using `doit()`.
55633/// // Values shown here are possibly random and not representative !
55634/// let result = hub.mobile_carriers().list(-96)
55635///              .doit().await;
55636/// # }
55637/// ```
55638pub struct MobileCarrierListCall<'a, C>
55639where
55640    C: 'a,
55641{
55642    hub: &'a Dfareporting<C>,
55643    _profile_id: i64,
55644    _delegate: Option<&'a mut dyn common::Delegate>,
55645    _additional_params: HashMap<String, String>,
55646    _scopes: BTreeSet<String>,
55647}
55648
55649impl<'a, C> common::CallBuilder for MobileCarrierListCall<'a, C> {}
55650
55651impl<'a, C> MobileCarrierListCall<'a, C>
55652where
55653    C: common::Connector,
55654{
55655    /// Perform the operation you have build so far.
55656    pub async fn doit(mut self) -> common::Result<(common::Response, MobileCarriersListResponse)> {
55657        use std::borrow::Cow;
55658        use std::io::{Read, Seek};
55659
55660        use common::{url::Params, ToParts};
55661        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
55662
55663        let mut dd = common::DefaultDelegate;
55664        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
55665        dlg.begin(common::MethodInfo {
55666            id: "dfareporting.mobileCarriers.list",
55667            http_method: hyper::Method::GET,
55668        });
55669
55670        for &field in ["alt", "profileId"].iter() {
55671            if self._additional_params.contains_key(field) {
55672                dlg.finished(false);
55673                return Err(common::Error::FieldClash(field));
55674            }
55675        }
55676
55677        let mut params = Params::with_capacity(3 + self._additional_params.len());
55678        params.push("profileId", self._profile_id.to_string());
55679
55680        params.extend(self._additional_params.iter());
55681
55682        params.push("alt", "json");
55683        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileCarriers";
55684        if self._scopes.is_empty() {
55685            self._scopes
55686                .insert(Scope::Dfatrafficking.as_ref().to_string());
55687        }
55688
55689        #[allow(clippy::single_element_loop)]
55690        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
55691            url = params.uri_replacement(url, param_name, find_this, false);
55692        }
55693        {
55694            let to_remove = ["profileId"];
55695            params.remove_params(&to_remove);
55696        }
55697
55698        let url = params.parse_with_url(&url);
55699
55700        loop {
55701            let token = match self
55702                .hub
55703                .auth
55704                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
55705                .await
55706            {
55707                Ok(token) => token,
55708                Err(e) => match dlg.token(e) {
55709                    Ok(token) => token,
55710                    Err(e) => {
55711                        dlg.finished(false);
55712                        return Err(common::Error::MissingToken(e));
55713                    }
55714                },
55715            };
55716            let mut req_result = {
55717                let client = &self.hub.client;
55718                dlg.pre_request();
55719                let mut req_builder = hyper::Request::builder()
55720                    .method(hyper::Method::GET)
55721                    .uri(url.as_str())
55722                    .header(USER_AGENT, self.hub._user_agent.clone());
55723
55724                if let Some(token) = token.as_ref() {
55725                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
55726                }
55727
55728                let request = req_builder
55729                    .header(CONTENT_LENGTH, 0_u64)
55730                    .body(common::to_body::<String>(None));
55731
55732                client.request(request.unwrap()).await
55733            };
55734
55735            match req_result {
55736                Err(err) => {
55737                    if let common::Retry::After(d) = dlg.http_error(&err) {
55738                        sleep(d).await;
55739                        continue;
55740                    }
55741                    dlg.finished(false);
55742                    return Err(common::Error::HttpError(err));
55743                }
55744                Ok(res) => {
55745                    let (mut parts, body) = res.into_parts();
55746                    let mut body = common::Body::new(body);
55747                    if !parts.status.is_success() {
55748                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55749                        let error = serde_json::from_str(&common::to_string(&bytes));
55750                        let response = common::to_response(parts, bytes.into());
55751
55752                        if let common::Retry::After(d) =
55753                            dlg.http_failure(&response, error.as_ref().ok())
55754                        {
55755                            sleep(d).await;
55756                            continue;
55757                        }
55758
55759                        dlg.finished(false);
55760
55761                        return Err(match error {
55762                            Ok(value) => common::Error::BadRequest(value),
55763                            _ => common::Error::Failure(response),
55764                        });
55765                    }
55766                    let response = {
55767                        let bytes = common::to_bytes(body).await.unwrap_or_default();
55768                        let encoded = common::to_string(&bytes);
55769                        match serde_json::from_str(&encoded) {
55770                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
55771                            Err(error) => {
55772                                dlg.response_json_decode_error(&encoded, &error);
55773                                return Err(common::Error::JsonDecodeError(
55774                                    encoded.to_string(),
55775                                    error,
55776                                ));
55777                            }
55778                        }
55779                    };
55780
55781                    dlg.finished(true);
55782                    return Ok(response);
55783                }
55784            }
55785        }
55786    }
55787
55788    /// User profile ID associated with this request.
55789    ///
55790    /// Sets the *profile id* path property to the given value.
55791    ///
55792    /// Even though the property as already been set when instantiating this call,
55793    /// we provide this method for API completeness.
55794    pub fn profile_id(mut self, new_value: i64) -> MobileCarrierListCall<'a, C> {
55795        self._profile_id = new_value;
55796        self
55797    }
55798    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
55799    /// while executing the actual API request.
55800    ///
55801    /// ````text
55802    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
55803    /// ````
55804    ///
55805    /// Sets the *delegate* property to the given value.
55806    pub fn delegate(
55807        mut self,
55808        new_value: &'a mut dyn common::Delegate,
55809    ) -> MobileCarrierListCall<'a, C> {
55810        self._delegate = Some(new_value);
55811        self
55812    }
55813
55814    /// Set any additional parameter of the query string used in the request.
55815    /// It should be used to set parameters which are not yet available through their own
55816    /// setters.
55817    ///
55818    /// Please note that this method must not be used to set any of the known parameters
55819    /// which have their own setter method. If done anyway, the request will fail.
55820    ///
55821    /// # Additional Parameters
55822    ///
55823    /// * *alt* (query-string) - Data format for the response.
55824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
55825    /// * *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.
55826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
55827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
55828    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
55829    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
55830    pub fn param<T>(mut self, name: T, value: T) -> MobileCarrierListCall<'a, C>
55831    where
55832        T: AsRef<str>,
55833    {
55834        self._additional_params
55835            .insert(name.as_ref().to_string(), value.as_ref().to_string());
55836        self
55837    }
55838
55839    /// Identifies the authorization scope for the method you are building.
55840    ///
55841    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
55842    /// [`Scope::Dfatrafficking`].
55843    ///
55844    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
55845    /// tokens for more than one scope.
55846    ///
55847    /// Usually there is more than one suitable scope to authorize an operation, some of which may
55848    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
55849    /// sufficient, a read-write scope will do as well.
55850    pub fn add_scope<St>(mut self, scope: St) -> MobileCarrierListCall<'a, C>
55851    where
55852        St: AsRef<str>,
55853    {
55854        self._scopes.insert(String::from(scope.as_ref()));
55855        self
55856    }
55857    /// Identifies the authorization scope(s) for the method you are building.
55858    ///
55859    /// See [`Self::add_scope()`] for details.
55860    pub fn add_scopes<I, St>(mut self, scopes: I) -> MobileCarrierListCall<'a, C>
55861    where
55862        I: IntoIterator<Item = St>,
55863        St: AsRef<str>,
55864    {
55865        self._scopes
55866            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
55867        self
55868    }
55869
55870    /// Removes all scopes, and no default scope will be used either.
55871    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
55872    /// for details).
55873    pub fn clear_scopes(mut self) -> MobileCarrierListCall<'a, C> {
55874        self._scopes.clear();
55875        self
55876    }
55877}
55878
55879/// Gets one operating system version by ID.
55880///
55881/// A builder for the *get* method supported by a *operatingSystemVersion* resource.
55882/// It is not used directly, but through a [`OperatingSystemVersionMethods`] instance.
55883///
55884/// # Example
55885///
55886/// Instantiate a resource method builder
55887///
55888/// ```test_harness,no_run
55889/// # extern crate hyper;
55890/// # extern crate hyper_rustls;
55891/// # extern crate google_dfareporting3d2 as dfareporting3d2;
55892/// # async fn dox() {
55893/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
55894///
55895/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
55896/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
55897/// #     secret,
55898/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
55899/// # ).build().await.unwrap();
55900///
55901/// # let client = hyper_util::client::legacy::Client::builder(
55902/// #     hyper_util::rt::TokioExecutor::new()
55903/// # )
55904/// # .build(
55905/// #     hyper_rustls::HttpsConnectorBuilder::new()
55906/// #         .with_native_roots()
55907/// #         .unwrap()
55908/// #         .https_or_http()
55909/// #         .enable_http1()
55910/// #         .build()
55911/// # );
55912/// # let mut hub = Dfareporting::new(client, auth);
55913/// // You can configure optional parameters by calling the respective setters at will, and
55914/// // execute the final call using `doit()`.
55915/// // Values shown here are possibly random and not representative !
55916/// let result = hub.operating_system_versions().get(-15, -23)
55917///              .doit().await;
55918/// # }
55919/// ```
55920pub struct OperatingSystemVersionGetCall<'a, C>
55921where
55922    C: 'a,
55923{
55924    hub: &'a Dfareporting<C>,
55925    _profile_id: i64,
55926    _id: i64,
55927    _delegate: Option<&'a mut dyn common::Delegate>,
55928    _additional_params: HashMap<String, String>,
55929    _scopes: BTreeSet<String>,
55930}
55931
55932impl<'a, C> common::CallBuilder for OperatingSystemVersionGetCall<'a, C> {}
55933
55934impl<'a, C> OperatingSystemVersionGetCall<'a, C>
55935where
55936    C: common::Connector,
55937{
55938    /// Perform the operation you have build so far.
55939    pub async fn doit(mut self) -> common::Result<(common::Response, OperatingSystemVersion)> {
55940        use std::borrow::Cow;
55941        use std::io::{Read, Seek};
55942
55943        use common::{url::Params, ToParts};
55944        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
55945
55946        let mut dd = common::DefaultDelegate;
55947        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
55948        dlg.begin(common::MethodInfo {
55949            id: "dfareporting.operatingSystemVersions.get",
55950            http_method: hyper::Method::GET,
55951        });
55952
55953        for &field in ["alt", "profileId", "id"].iter() {
55954            if self._additional_params.contains_key(field) {
55955                dlg.finished(false);
55956                return Err(common::Error::FieldClash(field));
55957            }
55958        }
55959
55960        let mut params = Params::with_capacity(4 + self._additional_params.len());
55961        params.push("profileId", self._profile_id.to_string());
55962        params.push("id", self._id.to_string());
55963
55964        params.extend(self._additional_params.iter());
55965
55966        params.push("alt", "json");
55967        let mut url =
55968            self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystemVersions/{id}";
55969        if self._scopes.is_empty() {
55970            self._scopes
55971                .insert(Scope::Dfatrafficking.as_ref().to_string());
55972        }
55973
55974        #[allow(clippy::single_element_loop)]
55975        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
55976            url = params.uri_replacement(url, param_name, find_this, false);
55977        }
55978        {
55979            let to_remove = ["id", "profileId"];
55980            params.remove_params(&to_remove);
55981        }
55982
55983        let url = params.parse_with_url(&url);
55984
55985        loop {
55986            let token = match self
55987                .hub
55988                .auth
55989                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
55990                .await
55991            {
55992                Ok(token) => token,
55993                Err(e) => match dlg.token(e) {
55994                    Ok(token) => token,
55995                    Err(e) => {
55996                        dlg.finished(false);
55997                        return Err(common::Error::MissingToken(e));
55998                    }
55999                },
56000            };
56001            let mut req_result = {
56002                let client = &self.hub.client;
56003                dlg.pre_request();
56004                let mut req_builder = hyper::Request::builder()
56005                    .method(hyper::Method::GET)
56006                    .uri(url.as_str())
56007                    .header(USER_AGENT, self.hub._user_agent.clone());
56008
56009                if let Some(token) = token.as_ref() {
56010                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
56011                }
56012
56013                let request = req_builder
56014                    .header(CONTENT_LENGTH, 0_u64)
56015                    .body(common::to_body::<String>(None));
56016
56017                client.request(request.unwrap()).await
56018            };
56019
56020            match req_result {
56021                Err(err) => {
56022                    if let common::Retry::After(d) = dlg.http_error(&err) {
56023                        sleep(d).await;
56024                        continue;
56025                    }
56026                    dlg.finished(false);
56027                    return Err(common::Error::HttpError(err));
56028                }
56029                Ok(res) => {
56030                    let (mut parts, body) = res.into_parts();
56031                    let mut body = common::Body::new(body);
56032                    if !parts.status.is_success() {
56033                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56034                        let error = serde_json::from_str(&common::to_string(&bytes));
56035                        let response = common::to_response(parts, bytes.into());
56036
56037                        if let common::Retry::After(d) =
56038                            dlg.http_failure(&response, error.as_ref().ok())
56039                        {
56040                            sleep(d).await;
56041                            continue;
56042                        }
56043
56044                        dlg.finished(false);
56045
56046                        return Err(match error {
56047                            Ok(value) => common::Error::BadRequest(value),
56048                            _ => common::Error::Failure(response),
56049                        });
56050                    }
56051                    let response = {
56052                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56053                        let encoded = common::to_string(&bytes);
56054                        match serde_json::from_str(&encoded) {
56055                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
56056                            Err(error) => {
56057                                dlg.response_json_decode_error(&encoded, &error);
56058                                return Err(common::Error::JsonDecodeError(
56059                                    encoded.to_string(),
56060                                    error,
56061                                ));
56062                            }
56063                        }
56064                    };
56065
56066                    dlg.finished(true);
56067                    return Ok(response);
56068                }
56069            }
56070        }
56071    }
56072
56073    /// User profile ID associated with this request.
56074    ///
56075    /// Sets the *profile id* path property to the given value.
56076    ///
56077    /// Even though the property as already been set when instantiating this call,
56078    /// we provide this method for API completeness.
56079    pub fn profile_id(mut self, new_value: i64) -> OperatingSystemVersionGetCall<'a, C> {
56080        self._profile_id = new_value;
56081        self
56082    }
56083    /// Operating system version ID.
56084    ///
56085    /// Sets the *id* path property to the given value.
56086    ///
56087    /// Even though the property as already been set when instantiating this call,
56088    /// we provide this method for API completeness.
56089    pub fn id(mut self, new_value: i64) -> OperatingSystemVersionGetCall<'a, C> {
56090        self._id = new_value;
56091        self
56092    }
56093    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
56094    /// while executing the actual API request.
56095    ///
56096    /// ````text
56097    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
56098    /// ````
56099    ///
56100    /// Sets the *delegate* property to the given value.
56101    pub fn delegate(
56102        mut self,
56103        new_value: &'a mut dyn common::Delegate,
56104    ) -> OperatingSystemVersionGetCall<'a, C> {
56105        self._delegate = Some(new_value);
56106        self
56107    }
56108
56109    /// Set any additional parameter of the query string used in the request.
56110    /// It should be used to set parameters which are not yet available through their own
56111    /// setters.
56112    ///
56113    /// Please note that this method must not be used to set any of the known parameters
56114    /// which have their own setter method. If done anyway, the request will fail.
56115    ///
56116    /// # Additional Parameters
56117    ///
56118    /// * *alt* (query-string) - Data format for the response.
56119    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
56120    /// * *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.
56121    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
56122    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
56123    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
56124    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
56125    pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemVersionGetCall<'a, C>
56126    where
56127        T: AsRef<str>,
56128    {
56129        self._additional_params
56130            .insert(name.as_ref().to_string(), value.as_ref().to_string());
56131        self
56132    }
56133
56134    /// Identifies the authorization scope for the method you are building.
56135    ///
56136    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
56137    /// [`Scope::Dfatrafficking`].
56138    ///
56139    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
56140    /// tokens for more than one scope.
56141    ///
56142    /// Usually there is more than one suitable scope to authorize an operation, some of which may
56143    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
56144    /// sufficient, a read-write scope will do as well.
56145    pub fn add_scope<St>(mut self, scope: St) -> OperatingSystemVersionGetCall<'a, C>
56146    where
56147        St: AsRef<str>,
56148    {
56149        self._scopes.insert(String::from(scope.as_ref()));
56150        self
56151    }
56152    /// Identifies the authorization scope(s) for the method you are building.
56153    ///
56154    /// See [`Self::add_scope()`] for details.
56155    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperatingSystemVersionGetCall<'a, C>
56156    where
56157        I: IntoIterator<Item = St>,
56158        St: AsRef<str>,
56159    {
56160        self._scopes
56161            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
56162        self
56163    }
56164
56165    /// Removes all scopes, and no default scope will be used either.
56166    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
56167    /// for details).
56168    pub fn clear_scopes(mut self) -> OperatingSystemVersionGetCall<'a, C> {
56169        self._scopes.clear();
56170        self
56171    }
56172}
56173
56174/// Retrieves a list of operating system versions.
56175///
56176/// A builder for the *list* method supported by a *operatingSystemVersion* resource.
56177/// It is not used directly, but through a [`OperatingSystemVersionMethods`] instance.
56178///
56179/// # Example
56180///
56181/// Instantiate a resource method builder
56182///
56183/// ```test_harness,no_run
56184/// # extern crate hyper;
56185/// # extern crate hyper_rustls;
56186/// # extern crate google_dfareporting3d2 as dfareporting3d2;
56187/// # async fn dox() {
56188/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56189///
56190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
56191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
56192/// #     secret,
56193/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
56194/// # ).build().await.unwrap();
56195///
56196/// # let client = hyper_util::client::legacy::Client::builder(
56197/// #     hyper_util::rt::TokioExecutor::new()
56198/// # )
56199/// # .build(
56200/// #     hyper_rustls::HttpsConnectorBuilder::new()
56201/// #         .with_native_roots()
56202/// #         .unwrap()
56203/// #         .https_or_http()
56204/// #         .enable_http1()
56205/// #         .build()
56206/// # );
56207/// # let mut hub = Dfareporting::new(client, auth);
56208/// // You can configure optional parameters by calling the respective setters at will, and
56209/// // execute the final call using `doit()`.
56210/// // Values shown here are possibly random and not representative !
56211/// let result = hub.operating_system_versions().list(-46)
56212///              .doit().await;
56213/// # }
56214/// ```
56215pub struct OperatingSystemVersionListCall<'a, C>
56216where
56217    C: 'a,
56218{
56219    hub: &'a Dfareporting<C>,
56220    _profile_id: i64,
56221    _delegate: Option<&'a mut dyn common::Delegate>,
56222    _additional_params: HashMap<String, String>,
56223    _scopes: BTreeSet<String>,
56224}
56225
56226impl<'a, C> common::CallBuilder for OperatingSystemVersionListCall<'a, C> {}
56227
56228impl<'a, C> OperatingSystemVersionListCall<'a, C>
56229where
56230    C: common::Connector,
56231{
56232    /// Perform the operation you have build so far.
56233    pub async fn doit(
56234        mut self,
56235    ) -> common::Result<(common::Response, OperatingSystemVersionsListResponse)> {
56236        use std::borrow::Cow;
56237        use std::io::{Read, Seek};
56238
56239        use common::{url::Params, ToParts};
56240        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
56241
56242        let mut dd = common::DefaultDelegate;
56243        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
56244        dlg.begin(common::MethodInfo {
56245            id: "dfareporting.operatingSystemVersions.list",
56246            http_method: hyper::Method::GET,
56247        });
56248
56249        for &field in ["alt", "profileId"].iter() {
56250            if self._additional_params.contains_key(field) {
56251                dlg.finished(false);
56252                return Err(common::Error::FieldClash(field));
56253            }
56254        }
56255
56256        let mut params = Params::with_capacity(3 + self._additional_params.len());
56257        params.push("profileId", self._profile_id.to_string());
56258
56259        params.extend(self._additional_params.iter());
56260
56261        params.push("alt", "json");
56262        let mut url =
56263            self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystemVersions";
56264        if self._scopes.is_empty() {
56265            self._scopes
56266                .insert(Scope::Dfatrafficking.as_ref().to_string());
56267        }
56268
56269        #[allow(clippy::single_element_loop)]
56270        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
56271            url = params.uri_replacement(url, param_name, find_this, false);
56272        }
56273        {
56274            let to_remove = ["profileId"];
56275            params.remove_params(&to_remove);
56276        }
56277
56278        let url = params.parse_with_url(&url);
56279
56280        loop {
56281            let token = match self
56282                .hub
56283                .auth
56284                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
56285                .await
56286            {
56287                Ok(token) => token,
56288                Err(e) => match dlg.token(e) {
56289                    Ok(token) => token,
56290                    Err(e) => {
56291                        dlg.finished(false);
56292                        return Err(common::Error::MissingToken(e));
56293                    }
56294                },
56295            };
56296            let mut req_result = {
56297                let client = &self.hub.client;
56298                dlg.pre_request();
56299                let mut req_builder = hyper::Request::builder()
56300                    .method(hyper::Method::GET)
56301                    .uri(url.as_str())
56302                    .header(USER_AGENT, self.hub._user_agent.clone());
56303
56304                if let Some(token) = token.as_ref() {
56305                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
56306                }
56307
56308                let request = req_builder
56309                    .header(CONTENT_LENGTH, 0_u64)
56310                    .body(common::to_body::<String>(None));
56311
56312                client.request(request.unwrap()).await
56313            };
56314
56315            match req_result {
56316                Err(err) => {
56317                    if let common::Retry::After(d) = dlg.http_error(&err) {
56318                        sleep(d).await;
56319                        continue;
56320                    }
56321                    dlg.finished(false);
56322                    return Err(common::Error::HttpError(err));
56323                }
56324                Ok(res) => {
56325                    let (mut parts, body) = res.into_parts();
56326                    let mut body = common::Body::new(body);
56327                    if !parts.status.is_success() {
56328                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56329                        let error = serde_json::from_str(&common::to_string(&bytes));
56330                        let response = common::to_response(parts, bytes.into());
56331
56332                        if let common::Retry::After(d) =
56333                            dlg.http_failure(&response, error.as_ref().ok())
56334                        {
56335                            sleep(d).await;
56336                            continue;
56337                        }
56338
56339                        dlg.finished(false);
56340
56341                        return Err(match error {
56342                            Ok(value) => common::Error::BadRequest(value),
56343                            _ => common::Error::Failure(response),
56344                        });
56345                    }
56346                    let response = {
56347                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56348                        let encoded = common::to_string(&bytes);
56349                        match serde_json::from_str(&encoded) {
56350                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
56351                            Err(error) => {
56352                                dlg.response_json_decode_error(&encoded, &error);
56353                                return Err(common::Error::JsonDecodeError(
56354                                    encoded.to_string(),
56355                                    error,
56356                                ));
56357                            }
56358                        }
56359                    };
56360
56361                    dlg.finished(true);
56362                    return Ok(response);
56363                }
56364            }
56365        }
56366    }
56367
56368    /// User profile ID associated with this request.
56369    ///
56370    /// Sets the *profile id* path property to the given value.
56371    ///
56372    /// Even though the property as already been set when instantiating this call,
56373    /// we provide this method for API completeness.
56374    pub fn profile_id(mut self, new_value: i64) -> OperatingSystemVersionListCall<'a, C> {
56375        self._profile_id = new_value;
56376        self
56377    }
56378    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
56379    /// while executing the actual API request.
56380    ///
56381    /// ````text
56382    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
56383    /// ````
56384    ///
56385    /// Sets the *delegate* property to the given value.
56386    pub fn delegate(
56387        mut self,
56388        new_value: &'a mut dyn common::Delegate,
56389    ) -> OperatingSystemVersionListCall<'a, C> {
56390        self._delegate = Some(new_value);
56391        self
56392    }
56393
56394    /// Set any additional parameter of the query string used in the request.
56395    /// It should be used to set parameters which are not yet available through their own
56396    /// setters.
56397    ///
56398    /// Please note that this method must not be used to set any of the known parameters
56399    /// which have their own setter method. If done anyway, the request will fail.
56400    ///
56401    /// # Additional Parameters
56402    ///
56403    /// * *alt* (query-string) - Data format for the response.
56404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
56405    /// * *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.
56406    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
56407    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
56408    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
56409    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
56410    pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemVersionListCall<'a, C>
56411    where
56412        T: AsRef<str>,
56413    {
56414        self._additional_params
56415            .insert(name.as_ref().to_string(), value.as_ref().to_string());
56416        self
56417    }
56418
56419    /// Identifies the authorization scope for the method you are building.
56420    ///
56421    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
56422    /// [`Scope::Dfatrafficking`].
56423    ///
56424    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
56425    /// tokens for more than one scope.
56426    ///
56427    /// Usually there is more than one suitable scope to authorize an operation, some of which may
56428    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
56429    /// sufficient, a read-write scope will do as well.
56430    pub fn add_scope<St>(mut self, scope: St) -> OperatingSystemVersionListCall<'a, C>
56431    where
56432        St: AsRef<str>,
56433    {
56434        self._scopes.insert(String::from(scope.as_ref()));
56435        self
56436    }
56437    /// Identifies the authorization scope(s) for the method you are building.
56438    ///
56439    /// See [`Self::add_scope()`] for details.
56440    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperatingSystemVersionListCall<'a, C>
56441    where
56442        I: IntoIterator<Item = St>,
56443        St: AsRef<str>,
56444    {
56445        self._scopes
56446            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
56447        self
56448    }
56449
56450    /// Removes all scopes, and no default scope will be used either.
56451    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
56452    /// for details).
56453    pub fn clear_scopes(mut self) -> OperatingSystemVersionListCall<'a, C> {
56454        self._scopes.clear();
56455        self
56456    }
56457}
56458
56459/// Gets one operating system by DART ID.
56460///
56461/// A builder for the *get* method supported by a *operatingSystem* resource.
56462/// It is not used directly, but through a [`OperatingSystemMethods`] instance.
56463///
56464/// # Example
56465///
56466/// Instantiate a resource method builder
56467///
56468/// ```test_harness,no_run
56469/// # extern crate hyper;
56470/// # extern crate hyper_rustls;
56471/// # extern crate google_dfareporting3d2 as dfareporting3d2;
56472/// # async fn dox() {
56473/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56474///
56475/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
56476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
56477/// #     secret,
56478/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
56479/// # ).build().await.unwrap();
56480///
56481/// # let client = hyper_util::client::legacy::Client::builder(
56482/// #     hyper_util::rt::TokioExecutor::new()
56483/// # )
56484/// # .build(
56485/// #     hyper_rustls::HttpsConnectorBuilder::new()
56486/// #         .with_native_roots()
56487/// #         .unwrap()
56488/// #         .https_or_http()
56489/// #         .enable_http1()
56490/// #         .build()
56491/// # );
56492/// # let mut hub = Dfareporting::new(client, auth);
56493/// // You can configure optional parameters by calling the respective setters at will, and
56494/// // execute the final call using `doit()`.
56495/// // Values shown here are possibly random and not representative !
56496/// let result = hub.operating_systems().get(-9, -43)
56497///              .doit().await;
56498/// # }
56499/// ```
56500pub struct OperatingSystemGetCall<'a, C>
56501where
56502    C: 'a,
56503{
56504    hub: &'a Dfareporting<C>,
56505    _profile_id: i64,
56506    _dart_id: i64,
56507    _delegate: Option<&'a mut dyn common::Delegate>,
56508    _additional_params: HashMap<String, String>,
56509    _scopes: BTreeSet<String>,
56510}
56511
56512impl<'a, C> common::CallBuilder for OperatingSystemGetCall<'a, C> {}
56513
56514impl<'a, C> OperatingSystemGetCall<'a, C>
56515where
56516    C: common::Connector,
56517{
56518    /// Perform the operation you have build so far.
56519    pub async fn doit(mut self) -> common::Result<(common::Response, OperatingSystem)> {
56520        use std::borrow::Cow;
56521        use std::io::{Read, Seek};
56522
56523        use common::{url::Params, ToParts};
56524        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
56525
56526        let mut dd = common::DefaultDelegate;
56527        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
56528        dlg.begin(common::MethodInfo {
56529            id: "dfareporting.operatingSystems.get",
56530            http_method: hyper::Method::GET,
56531        });
56532
56533        for &field in ["alt", "profileId", "dartId"].iter() {
56534            if self._additional_params.contains_key(field) {
56535                dlg.finished(false);
56536                return Err(common::Error::FieldClash(field));
56537            }
56538        }
56539
56540        let mut params = Params::with_capacity(4 + self._additional_params.len());
56541        params.push("profileId", self._profile_id.to_string());
56542        params.push("dartId", self._dart_id.to_string());
56543
56544        params.extend(self._additional_params.iter());
56545
56546        params.push("alt", "json");
56547        let mut url =
56548            self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystems/{dartId}";
56549        if self._scopes.is_empty() {
56550            self._scopes
56551                .insert(Scope::Dfatrafficking.as_ref().to_string());
56552        }
56553
56554        #[allow(clippy::single_element_loop)]
56555        for &(find_this, param_name) in
56556            [("{profileId}", "profileId"), ("{dartId}", "dartId")].iter()
56557        {
56558            url = params.uri_replacement(url, param_name, find_this, false);
56559        }
56560        {
56561            let to_remove = ["dartId", "profileId"];
56562            params.remove_params(&to_remove);
56563        }
56564
56565        let url = params.parse_with_url(&url);
56566
56567        loop {
56568            let token = match self
56569                .hub
56570                .auth
56571                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
56572                .await
56573            {
56574                Ok(token) => token,
56575                Err(e) => match dlg.token(e) {
56576                    Ok(token) => token,
56577                    Err(e) => {
56578                        dlg.finished(false);
56579                        return Err(common::Error::MissingToken(e));
56580                    }
56581                },
56582            };
56583            let mut req_result = {
56584                let client = &self.hub.client;
56585                dlg.pre_request();
56586                let mut req_builder = hyper::Request::builder()
56587                    .method(hyper::Method::GET)
56588                    .uri(url.as_str())
56589                    .header(USER_AGENT, self.hub._user_agent.clone());
56590
56591                if let Some(token) = token.as_ref() {
56592                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
56593                }
56594
56595                let request = req_builder
56596                    .header(CONTENT_LENGTH, 0_u64)
56597                    .body(common::to_body::<String>(None));
56598
56599                client.request(request.unwrap()).await
56600            };
56601
56602            match req_result {
56603                Err(err) => {
56604                    if let common::Retry::After(d) = dlg.http_error(&err) {
56605                        sleep(d).await;
56606                        continue;
56607                    }
56608                    dlg.finished(false);
56609                    return Err(common::Error::HttpError(err));
56610                }
56611                Ok(res) => {
56612                    let (mut parts, body) = res.into_parts();
56613                    let mut body = common::Body::new(body);
56614                    if !parts.status.is_success() {
56615                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56616                        let error = serde_json::from_str(&common::to_string(&bytes));
56617                        let response = common::to_response(parts, bytes.into());
56618
56619                        if let common::Retry::After(d) =
56620                            dlg.http_failure(&response, error.as_ref().ok())
56621                        {
56622                            sleep(d).await;
56623                            continue;
56624                        }
56625
56626                        dlg.finished(false);
56627
56628                        return Err(match error {
56629                            Ok(value) => common::Error::BadRequest(value),
56630                            _ => common::Error::Failure(response),
56631                        });
56632                    }
56633                    let response = {
56634                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56635                        let encoded = common::to_string(&bytes);
56636                        match serde_json::from_str(&encoded) {
56637                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
56638                            Err(error) => {
56639                                dlg.response_json_decode_error(&encoded, &error);
56640                                return Err(common::Error::JsonDecodeError(
56641                                    encoded.to_string(),
56642                                    error,
56643                                ));
56644                            }
56645                        }
56646                    };
56647
56648                    dlg.finished(true);
56649                    return Ok(response);
56650                }
56651            }
56652        }
56653    }
56654
56655    /// User profile ID associated with this request.
56656    ///
56657    /// Sets the *profile id* path property to the given value.
56658    ///
56659    /// Even though the property as already been set when instantiating this call,
56660    /// we provide this method for API completeness.
56661    pub fn profile_id(mut self, new_value: i64) -> OperatingSystemGetCall<'a, C> {
56662        self._profile_id = new_value;
56663        self
56664    }
56665    /// Operating system DART ID.
56666    ///
56667    /// Sets the *dart id* path property to the given value.
56668    ///
56669    /// Even though the property as already been set when instantiating this call,
56670    /// we provide this method for API completeness.
56671    pub fn dart_id(mut self, new_value: i64) -> OperatingSystemGetCall<'a, C> {
56672        self._dart_id = new_value;
56673        self
56674    }
56675    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
56676    /// while executing the actual API request.
56677    ///
56678    /// ````text
56679    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
56680    /// ````
56681    ///
56682    /// Sets the *delegate* property to the given value.
56683    pub fn delegate(
56684        mut self,
56685        new_value: &'a mut dyn common::Delegate,
56686    ) -> OperatingSystemGetCall<'a, C> {
56687        self._delegate = Some(new_value);
56688        self
56689    }
56690
56691    /// Set any additional parameter of the query string used in the request.
56692    /// It should be used to set parameters which are not yet available through their own
56693    /// setters.
56694    ///
56695    /// Please note that this method must not be used to set any of the known parameters
56696    /// which have their own setter method. If done anyway, the request will fail.
56697    ///
56698    /// # Additional Parameters
56699    ///
56700    /// * *alt* (query-string) - Data format for the response.
56701    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
56702    /// * *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.
56703    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
56704    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
56705    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
56706    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
56707    pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemGetCall<'a, C>
56708    where
56709        T: AsRef<str>,
56710    {
56711        self._additional_params
56712            .insert(name.as_ref().to_string(), value.as_ref().to_string());
56713        self
56714    }
56715
56716    /// Identifies the authorization scope for the method you are building.
56717    ///
56718    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
56719    /// [`Scope::Dfatrafficking`].
56720    ///
56721    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
56722    /// tokens for more than one scope.
56723    ///
56724    /// Usually there is more than one suitable scope to authorize an operation, some of which may
56725    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
56726    /// sufficient, a read-write scope will do as well.
56727    pub fn add_scope<St>(mut self, scope: St) -> OperatingSystemGetCall<'a, C>
56728    where
56729        St: AsRef<str>,
56730    {
56731        self._scopes.insert(String::from(scope.as_ref()));
56732        self
56733    }
56734    /// Identifies the authorization scope(s) for the method you are building.
56735    ///
56736    /// See [`Self::add_scope()`] for details.
56737    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperatingSystemGetCall<'a, C>
56738    where
56739        I: IntoIterator<Item = St>,
56740        St: AsRef<str>,
56741    {
56742        self._scopes
56743            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
56744        self
56745    }
56746
56747    /// Removes all scopes, and no default scope will be used either.
56748    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
56749    /// for details).
56750    pub fn clear_scopes(mut self) -> OperatingSystemGetCall<'a, C> {
56751        self._scopes.clear();
56752        self
56753    }
56754}
56755
56756/// Retrieves a list of operating systems.
56757///
56758/// A builder for the *list* method supported by a *operatingSystem* resource.
56759/// It is not used directly, but through a [`OperatingSystemMethods`] instance.
56760///
56761/// # Example
56762///
56763/// Instantiate a resource method builder
56764///
56765/// ```test_harness,no_run
56766/// # extern crate hyper;
56767/// # extern crate hyper_rustls;
56768/// # extern crate google_dfareporting3d2 as dfareporting3d2;
56769/// # async fn dox() {
56770/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56771///
56772/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
56773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
56774/// #     secret,
56775/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
56776/// # ).build().await.unwrap();
56777///
56778/// # let client = hyper_util::client::legacy::Client::builder(
56779/// #     hyper_util::rt::TokioExecutor::new()
56780/// # )
56781/// # .build(
56782/// #     hyper_rustls::HttpsConnectorBuilder::new()
56783/// #         .with_native_roots()
56784/// #         .unwrap()
56785/// #         .https_or_http()
56786/// #         .enable_http1()
56787/// #         .build()
56788/// # );
56789/// # let mut hub = Dfareporting::new(client, auth);
56790/// // You can configure optional parameters by calling the respective setters at will, and
56791/// // execute the final call using `doit()`.
56792/// // Values shown here are possibly random and not representative !
56793/// let result = hub.operating_systems().list(-91)
56794///              .doit().await;
56795/// # }
56796/// ```
56797pub struct OperatingSystemListCall<'a, C>
56798where
56799    C: 'a,
56800{
56801    hub: &'a Dfareporting<C>,
56802    _profile_id: i64,
56803    _delegate: Option<&'a mut dyn common::Delegate>,
56804    _additional_params: HashMap<String, String>,
56805    _scopes: BTreeSet<String>,
56806}
56807
56808impl<'a, C> common::CallBuilder for OperatingSystemListCall<'a, C> {}
56809
56810impl<'a, C> OperatingSystemListCall<'a, C>
56811where
56812    C: common::Connector,
56813{
56814    /// Perform the operation you have build so far.
56815    pub async fn doit(
56816        mut self,
56817    ) -> common::Result<(common::Response, OperatingSystemsListResponse)> {
56818        use std::borrow::Cow;
56819        use std::io::{Read, Seek};
56820
56821        use common::{url::Params, ToParts};
56822        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
56823
56824        let mut dd = common::DefaultDelegate;
56825        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
56826        dlg.begin(common::MethodInfo {
56827            id: "dfareporting.operatingSystems.list",
56828            http_method: hyper::Method::GET,
56829        });
56830
56831        for &field in ["alt", "profileId"].iter() {
56832            if self._additional_params.contains_key(field) {
56833                dlg.finished(false);
56834                return Err(common::Error::FieldClash(field));
56835            }
56836        }
56837
56838        let mut params = Params::with_capacity(3 + self._additional_params.len());
56839        params.push("profileId", self._profile_id.to_string());
56840
56841        params.extend(self._additional_params.iter());
56842
56843        params.push("alt", "json");
56844        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystems";
56845        if self._scopes.is_empty() {
56846            self._scopes
56847                .insert(Scope::Dfatrafficking.as_ref().to_string());
56848        }
56849
56850        #[allow(clippy::single_element_loop)]
56851        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
56852            url = params.uri_replacement(url, param_name, find_this, false);
56853        }
56854        {
56855            let to_remove = ["profileId"];
56856            params.remove_params(&to_remove);
56857        }
56858
56859        let url = params.parse_with_url(&url);
56860
56861        loop {
56862            let token = match self
56863                .hub
56864                .auth
56865                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
56866                .await
56867            {
56868                Ok(token) => token,
56869                Err(e) => match dlg.token(e) {
56870                    Ok(token) => token,
56871                    Err(e) => {
56872                        dlg.finished(false);
56873                        return Err(common::Error::MissingToken(e));
56874                    }
56875                },
56876            };
56877            let mut req_result = {
56878                let client = &self.hub.client;
56879                dlg.pre_request();
56880                let mut req_builder = hyper::Request::builder()
56881                    .method(hyper::Method::GET)
56882                    .uri(url.as_str())
56883                    .header(USER_AGENT, self.hub._user_agent.clone());
56884
56885                if let Some(token) = token.as_ref() {
56886                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
56887                }
56888
56889                let request = req_builder
56890                    .header(CONTENT_LENGTH, 0_u64)
56891                    .body(common::to_body::<String>(None));
56892
56893                client.request(request.unwrap()).await
56894            };
56895
56896            match req_result {
56897                Err(err) => {
56898                    if let common::Retry::After(d) = dlg.http_error(&err) {
56899                        sleep(d).await;
56900                        continue;
56901                    }
56902                    dlg.finished(false);
56903                    return Err(common::Error::HttpError(err));
56904                }
56905                Ok(res) => {
56906                    let (mut parts, body) = res.into_parts();
56907                    let mut body = common::Body::new(body);
56908                    if !parts.status.is_success() {
56909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56910                        let error = serde_json::from_str(&common::to_string(&bytes));
56911                        let response = common::to_response(parts, bytes.into());
56912
56913                        if let common::Retry::After(d) =
56914                            dlg.http_failure(&response, error.as_ref().ok())
56915                        {
56916                            sleep(d).await;
56917                            continue;
56918                        }
56919
56920                        dlg.finished(false);
56921
56922                        return Err(match error {
56923                            Ok(value) => common::Error::BadRequest(value),
56924                            _ => common::Error::Failure(response),
56925                        });
56926                    }
56927                    let response = {
56928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
56929                        let encoded = common::to_string(&bytes);
56930                        match serde_json::from_str(&encoded) {
56931                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
56932                            Err(error) => {
56933                                dlg.response_json_decode_error(&encoded, &error);
56934                                return Err(common::Error::JsonDecodeError(
56935                                    encoded.to_string(),
56936                                    error,
56937                                ));
56938                            }
56939                        }
56940                    };
56941
56942                    dlg.finished(true);
56943                    return Ok(response);
56944                }
56945            }
56946        }
56947    }
56948
56949    /// User profile ID associated with this request.
56950    ///
56951    /// Sets the *profile id* path property to the given value.
56952    ///
56953    /// Even though the property as already been set when instantiating this call,
56954    /// we provide this method for API completeness.
56955    pub fn profile_id(mut self, new_value: i64) -> OperatingSystemListCall<'a, C> {
56956        self._profile_id = new_value;
56957        self
56958    }
56959    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
56960    /// while executing the actual API request.
56961    ///
56962    /// ````text
56963    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
56964    /// ````
56965    ///
56966    /// Sets the *delegate* property to the given value.
56967    pub fn delegate(
56968        mut self,
56969        new_value: &'a mut dyn common::Delegate,
56970    ) -> OperatingSystemListCall<'a, C> {
56971        self._delegate = Some(new_value);
56972        self
56973    }
56974
56975    /// Set any additional parameter of the query string used in the request.
56976    /// It should be used to set parameters which are not yet available through their own
56977    /// setters.
56978    ///
56979    /// Please note that this method must not be used to set any of the known parameters
56980    /// which have their own setter method. If done anyway, the request will fail.
56981    ///
56982    /// # Additional Parameters
56983    ///
56984    /// * *alt* (query-string) - Data format for the response.
56985    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
56986    /// * *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.
56987    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
56988    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
56989    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
56990    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
56991    pub fn param<T>(mut self, name: T, value: T) -> OperatingSystemListCall<'a, C>
56992    where
56993        T: AsRef<str>,
56994    {
56995        self._additional_params
56996            .insert(name.as_ref().to_string(), value.as_ref().to_string());
56997        self
56998    }
56999
57000    /// Identifies the authorization scope for the method you are building.
57001    ///
57002    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
57003    /// [`Scope::Dfatrafficking`].
57004    ///
57005    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
57006    /// tokens for more than one scope.
57007    ///
57008    /// Usually there is more than one suitable scope to authorize an operation, some of which may
57009    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
57010    /// sufficient, a read-write scope will do as well.
57011    pub fn add_scope<St>(mut self, scope: St) -> OperatingSystemListCall<'a, C>
57012    where
57013        St: AsRef<str>,
57014    {
57015        self._scopes.insert(String::from(scope.as_ref()));
57016        self
57017    }
57018    /// Identifies the authorization scope(s) for the method you are building.
57019    ///
57020    /// See [`Self::add_scope()`] for details.
57021    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperatingSystemListCall<'a, C>
57022    where
57023        I: IntoIterator<Item = St>,
57024        St: AsRef<str>,
57025    {
57026        self._scopes
57027            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
57028        self
57029    }
57030
57031    /// Removes all scopes, and no default scope will be used either.
57032    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
57033    /// for details).
57034    pub fn clear_scopes(mut self) -> OperatingSystemListCall<'a, C> {
57035        self._scopes.clear();
57036        self
57037    }
57038}
57039
57040/// Gets one order document by ID.
57041///
57042/// A builder for the *get* method supported by a *orderDocument* resource.
57043/// It is not used directly, but through a [`OrderDocumentMethods`] instance.
57044///
57045/// # Example
57046///
57047/// Instantiate a resource method builder
57048///
57049/// ```test_harness,no_run
57050/// # extern crate hyper;
57051/// # extern crate hyper_rustls;
57052/// # extern crate google_dfareporting3d2 as dfareporting3d2;
57053/// # async fn dox() {
57054/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57055///
57056/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
57057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
57058/// #     secret,
57059/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
57060/// # ).build().await.unwrap();
57061///
57062/// # let client = hyper_util::client::legacy::Client::builder(
57063/// #     hyper_util::rt::TokioExecutor::new()
57064/// # )
57065/// # .build(
57066/// #     hyper_rustls::HttpsConnectorBuilder::new()
57067/// #         .with_native_roots()
57068/// #         .unwrap()
57069/// #         .https_or_http()
57070/// #         .enable_http1()
57071/// #         .build()
57072/// # );
57073/// # let mut hub = Dfareporting::new(client, auth);
57074/// // You can configure optional parameters by calling the respective setters at will, and
57075/// // execute the final call using `doit()`.
57076/// // Values shown here are possibly random and not representative !
57077/// let result = hub.order_documents().get(-60, -25, -34)
57078///              .doit().await;
57079/// # }
57080/// ```
57081pub struct OrderDocumentGetCall<'a, C>
57082where
57083    C: 'a,
57084{
57085    hub: &'a Dfareporting<C>,
57086    _profile_id: i64,
57087    _project_id: i64,
57088    _id: i64,
57089    _delegate: Option<&'a mut dyn common::Delegate>,
57090    _additional_params: HashMap<String, String>,
57091    _scopes: BTreeSet<String>,
57092}
57093
57094impl<'a, C> common::CallBuilder for OrderDocumentGetCall<'a, C> {}
57095
57096impl<'a, C> OrderDocumentGetCall<'a, C>
57097where
57098    C: common::Connector,
57099{
57100    /// Perform the operation you have build so far.
57101    pub async fn doit(mut self) -> common::Result<(common::Response, OrderDocument)> {
57102        use std::borrow::Cow;
57103        use std::io::{Read, Seek};
57104
57105        use common::{url::Params, ToParts};
57106        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
57107
57108        let mut dd = common::DefaultDelegate;
57109        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
57110        dlg.begin(common::MethodInfo {
57111            id: "dfareporting.orderDocuments.get",
57112            http_method: hyper::Method::GET,
57113        });
57114
57115        for &field in ["alt", "profileId", "projectId", "id"].iter() {
57116            if self._additional_params.contains_key(field) {
57117                dlg.finished(false);
57118                return Err(common::Error::FieldClash(field));
57119            }
57120        }
57121
57122        let mut params = Params::with_capacity(5 + self._additional_params.len());
57123        params.push("profileId", self._profile_id.to_string());
57124        params.push("projectId", self._project_id.to_string());
57125        params.push("id", self._id.to_string());
57126
57127        params.extend(self._additional_params.iter());
57128
57129        params.push("alt", "json");
57130        let mut url = self.hub._base_url.clone()
57131            + "userprofiles/{profileId}/projects/{projectId}/orderDocuments/{id}";
57132        if self._scopes.is_empty() {
57133            self._scopes
57134                .insert(Scope::Dfatrafficking.as_ref().to_string());
57135        }
57136
57137        #[allow(clippy::single_element_loop)]
57138        for &(find_this, param_name) in [
57139            ("{profileId}", "profileId"),
57140            ("{projectId}", "projectId"),
57141            ("{id}", "id"),
57142        ]
57143        .iter()
57144        {
57145            url = params.uri_replacement(url, param_name, find_this, false);
57146        }
57147        {
57148            let to_remove = ["id", "projectId", "profileId"];
57149            params.remove_params(&to_remove);
57150        }
57151
57152        let url = params.parse_with_url(&url);
57153
57154        loop {
57155            let token = match self
57156                .hub
57157                .auth
57158                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
57159                .await
57160            {
57161                Ok(token) => token,
57162                Err(e) => match dlg.token(e) {
57163                    Ok(token) => token,
57164                    Err(e) => {
57165                        dlg.finished(false);
57166                        return Err(common::Error::MissingToken(e));
57167                    }
57168                },
57169            };
57170            let mut req_result = {
57171                let client = &self.hub.client;
57172                dlg.pre_request();
57173                let mut req_builder = hyper::Request::builder()
57174                    .method(hyper::Method::GET)
57175                    .uri(url.as_str())
57176                    .header(USER_AGENT, self.hub._user_agent.clone());
57177
57178                if let Some(token) = token.as_ref() {
57179                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
57180                }
57181
57182                let request = req_builder
57183                    .header(CONTENT_LENGTH, 0_u64)
57184                    .body(common::to_body::<String>(None));
57185
57186                client.request(request.unwrap()).await
57187            };
57188
57189            match req_result {
57190                Err(err) => {
57191                    if let common::Retry::After(d) = dlg.http_error(&err) {
57192                        sleep(d).await;
57193                        continue;
57194                    }
57195                    dlg.finished(false);
57196                    return Err(common::Error::HttpError(err));
57197                }
57198                Ok(res) => {
57199                    let (mut parts, body) = res.into_parts();
57200                    let mut body = common::Body::new(body);
57201                    if !parts.status.is_success() {
57202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57203                        let error = serde_json::from_str(&common::to_string(&bytes));
57204                        let response = common::to_response(parts, bytes.into());
57205
57206                        if let common::Retry::After(d) =
57207                            dlg.http_failure(&response, error.as_ref().ok())
57208                        {
57209                            sleep(d).await;
57210                            continue;
57211                        }
57212
57213                        dlg.finished(false);
57214
57215                        return Err(match error {
57216                            Ok(value) => common::Error::BadRequest(value),
57217                            _ => common::Error::Failure(response),
57218                        });
57219                    }
57220                    let response = {
57221                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57222                        let encoded = common::to_string(&bytes);
57223                        match serde_json::from_str(&encoded) {
57224                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
57225                            Err(error) => {
57226                                dlg.response_json_decode_error(&encoded, &error);
57227                                return Err(common::Error::JsonDecodeError(
57228                                    encoded.to_string(),
57229                                    error,
57230                                ));
57231                            }
57232                        }
57233                    };
57234
57235                    dlg.finished(true);
57236                    return Ok(response);
57237                }
57238            }
57239        }
57240    }
57241
57242    /// User profile ID associated with this request.
57243    ///
57244    /// Sets the *profile id* path property to the given value.
57245    ///
57246    /// Even though the property as already been set when instantiating this call,
57247    /// we provide this method for API completeness.
57248    pub fn profile_id(mut self, new_value: i64) -> OrderDocumentGetCall<'a, C> {
57249        self._profile_id = new_value;
57250        self
57251    }
57252    /// Project ID for order documents.
57253    ///
57254    /// Sets the *project id* path property to the given value.
57255    ///
57256    /// Even though the property as already been set when instantiating this call,
57257    /// we provide this method for API completeness.
57258    pub fn project_id(mut self, new_value: i64) -> OrderDocumentGetCall<'a, C> {
57259        self._project_id = new_value;
57260        self
57261    }
57262    /// Order document ID.
57263    ///
57264    /// Sets the *id* path property to the given value.
57265    ///
57266    /// Even though the property as already been set when instantiating this call,
57267    /// we provide this method for API completeness.
57268    pub fn id(mut self, new_value: i64) -> OrderDocumentGetCall<'a, C> {
57269        self._id = new_value;
57270        self
57271    }
57272    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
57273    /// while executing the actual API request.
57274    ///
57275    /// ````text
57276    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
57277    /// ````
57278    ///
57279    /// Sets the *delegate* property to the given value.
57280    pub fn delegate(
57281        mut self,
57282        new_value: &'a mut dyn common::Delegate,
57283    ) -> OrderDocumentGetCall<'a, C> {
57284        self._delegate = Some(new_value);
57285        self
57286    }
57287
57288    /// Set any additional parameter of the query string used in the request.
57289    /// It should be used to set parameters which are not yet available through their own
57290    /// setters.
57291    ///
57292    /// Please note that this method must not be used to set any of the known parameters
57293    /// which have their own setter method. If done anyway, the request will fail.
57294    ///
57295    /// # Additional Parameters
57296    ///
57297    /// * *alt* (query-string) - Data format for the response.
57298    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
57299    /// * *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.
57300    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
57301    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
57302    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
57303    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
57304    pub fn param<T>(mut self, name: T, value: T) -> OrderDocumentGetCall<'a, C>
57305    where
57306        T: AsRef<str>,
57307    {
57308        self._additional_params
57309            .insert(name.as_ref().to_string(), value.as_ref().to_string());
57310        self
57311    }
57312
57313    /// Identifies the authorization scope for the method you are building.
57314    ///
57315    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
57316    /// [`Scope::Dfatrafficking`].
57317    ///
57318    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
57319    /// tokens for more than one scope.
57320    ///
57321    /// Usually there is more than one suitable scope to authorize an operation, some of which may
57322    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
57323    /// sufficient, a read-write scope will do as well.
57324    pub fn add_scope<St>(mut self, scope: St) -> OrderDocumentGetCall<'a, C>
57325    where
57326        St: AsRef<str>,
57327    {
57328        self._scopes.insert(String::from(scope.as_ref()));
57329        self
57330    }
57331    /// Identifies the authorization scope(s) for the method you are building.
57332    ///
57333    /// See [`Self::add_scope()`] for details.
57334    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderDocumentGetCall<'a, C>
57335    where
57336        I: IntoIterator<Item = St>,
57337        St: AsRef<str>,
57338    {
57339        self._scopes
57340            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
57341        self
57342    }
57343
57344    /// Removes all scopes, and no default scope will be used either.
57345    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
57346    /// for details).
57347    pub fn clear_scopes(mut self) -> OrderDocumentGetCall<'a, C> {
57348        self._scopes.clear();
57349        self
57350    }
57351}
57352
57353/// Retrieves a list of order documents, possibly filtered. This method supports paging.
57354///
57355/// A builder for the *list* method supported by a *orderDocument* resource.
57356/// It is not used directly, but through a [`OrderDocumentMethods`] instance.
57357///
57358/// # Example
57359///
57360/// Instantiate a resource method builder
57361///
57362/// ```test_harness,no_run
57363/// # extern crate hyper;
57364/// # extern crate hyper_rustls;
57365/// # extern crate google_dfareporting3d2 as dfareporting3d2;
57366/// # async fn dox() {
57367/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57368///
57369/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
57370/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
57371/// #     secret,
57372/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
57373/// # ).build().await.unwrap();
57374///
57375/// # let client = hyper_util::client::legacy::Client::builder(
57376/// #     hyper_util::rt::TokioExecutor::new()
57377/// # )
57378/// # .build(
57379/// #     hyper_rustls::HttpsConnectorBuilder::new()
57380/// #         .with_native_roots()
57381/// #         .unwrap()
57382/// #         .https_or_http()
57383/// #         .enable_http1()
57384/// #         .build()
57385/// # );
57386/// # let mut hub = Dfareporting::new(client, auth);
57387/// // You can configure optional parameters by calling the respective setters at will, and
57388/// // execute the final call using `doit()`.
57389/// // Values shown here are possibly random and not representative !
57390/// let result = hub.order_documents().list(-23, -44)
57391///              .sort_order("sed")
57392///              .sort_field("labore")
57393///              .add_site_id(-74)
57394///              .search_string("eirmod")
57395///              .page_token("sed")
57396///              .add_order_id(-27)
57397///              .max_results(-15)
57398///              .add_ids(-3)
57399///              .approved(true)
57400///              .doit().await;
57401/// # }
57402/// ```
57403pub struct OrderDocumentListCall<'a, C>
57404where
57405    C: 'a,
57406{
57407    hub: &'a Dfareporting<C>,
57408    _profile_id: i64,
57409    _project_id: i64,
57410    _sort_order: Option<String>,
57411    _sort_field: Option<String>,
57412    _site_id: Vec<i64>,
57413    _search_string: Option<String>,
57414    _page_token: Option<String>,
57415    _order_id: Vec<i64>,
57416    _max_results: Option<i32>,
57417    _ids: Vec<i64>,
57418    _approved: Option<bool>,
57419    _delegate: Option<&'a mut dyn common::Delegate>,
57420    _additional_params: HashMap<String, String>,
57421    _scopes: BTreeSet<String>,
57422}
57423
57424impl<'a, C> common::CallBuilder for OrderDocumentListCall<'a, C> {}
57425
57426impl<'a, C> OrderDocumentListCall<'a, C>
57427where
57428    C: common::Connector,
57429{
57430    /// Perform the operation you have build so far.
57431    pub async fn doit(mut self) -> common::Result<(common::Response, OrderDocumentsListResponse)> {
57432        use std::borrow::Cow;
57433        use std::io::{Read, Seek};
57434
57435        use common::{url::Params, ToParts};
57436        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
57437
57438        let mut dd = common::DefaultDelegate;
57439        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
57440        dlg.begin(common::MethodInfo {
57441            id: "dfareporting.orderDocuments.list",
57442            http_method: hyper::Method::GET,
57443        });
57444
57445        for &field in [
57446            "alt",
57447            "profileId",
57448            "projectId",
57449            "sortOrder",
57450            "sortField",
57451            "siteId",
57452            "searchString",
57453            "pageToken",
57454            "orderId",
57455            "maxResults",
57456            "ids",
57457            "approved",
57458        ]
57459        .iter()
57460        {
57461            if self._additional_params.contains_key(field) {
57462                dlg.finished(false);
57463                return Err(common::Error::FieldClash(field));
57464            }
57465        }
57466
57467        let mut params = Params::with_capacity(13 + self._additional_params.len());
57468        params.push("profileId", self._profile_id.to_string());
57469        params.push("projectId", self._project_id.to_string());
57470        if let Some(value) = self._sort_order.as_ref() {
57471            params.push("sortOrder", value);
57472        }
57473        if let Some(value) = self._sort_field.as_ref() {
57474            params.push("sortField", value);
57475        }
57476        if !self._site_id.is_empty() {
57477            for f in self._site_id.iter() {
57478                params.push("siteId", f.to_string());
57479            }
57480        }
57481        if let Some(value) = self._search_string.as_ref() {
57482            params.push("searchString", value);
57483        }
57484        if let Some(value) = self._page_token.as_ref() {
57485            params.push("pageToken", value);
57486        }
57487        if !self._order_id.is_empty() {
57488            for f in self._order_id.iter() {
57489                params.push("orderId", f.to_string());
57490            }
57491        }
57492        if let Some(value) = self._max_results.as_ref() {
57493            params.push("maxResults", value.to_string());
57494        }
57495        if !self._ids.is_empty() {
57496            for f in self._ids.iter() {
57497                params.push("ids", f.to_string());
57498            }
57499        }
57500        if let Some(value) = self._approved.as_ref() {
57501            params.push("approved", value.to_string());
57502        }
57503
57504        params.extend(self._additional_params.iter());
57505
57506        params.push("alt", "json");
57507        let mut url = self.hub._base_url.clone()
57508            + "userprofiles/{profileId}/projects/{projectId}/orderDocuments";
57509        if self._scopes.is_empty() {
57510            self._scopes
57511                .insert(Scope::Dfatrafficking.as_ref().to_string());
57512        }
57513
57514        #[allow(clippy::single_element_loop)]
57515        for &(find_this, param_name) in
57516            [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter()
57517        {
57518            url = params.uri_replacement(url, param_name, find_this, false);
57519        }
57520        {
57521            let to_remove = ["projectId", "profileId"];
57522            params.remove_params(&to_remove);
57523        }
57524
57525        let url = params.parse_with_url(&url);
57526
57527        loop {
57528            let token = match self
57529                .hub
57530                .auth
57531                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
57532                .await
57533            {
57534                Ok(token) => token,
57535                Err(e) => match dlg.token(e) {
57536                    Ok(token) => token,
57537                    Err(e) => {
57538                        dlg.finished(false);
57539                        return Err(common::Error::MissingToken(e));
57540                    }
57541                },
57542            };
57543            let mut req_result = {
57544                let client = &self.hub.client;
57545                dlg.pre_request();
57546                let mut req_builder = hyper::Request::builder()
57547                    .method(hyper::Method::GET)
57548                    .uri(url.as_str())
57549                    .header(USER_AGENT, self.hub._user_agent.clone());
57550
57551                if let Some(token) = token.as_ref() {
57552                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
57553                }
57554
57555                let request = req_builder
57556                    .header(CONTENT_LENGTH, 0_u64)
57557                    .body(common::to_body::<String>(None));
57558
57559                client.request(request.unwrap()).await
57560            };
57561
57562            match req_result {
57563                Err(err) => {
57564                    if let common::Retry::After(d) = dlg.http_error(&err) {
57565                        sleep(d).await;
57566                        continue;
57567                    }
57568                    dlg.finished(false);
57569                    return Err(common::Error::HttpError(err));
57570                }
57571                Ok(res) => {
57572                    let (mut parts, body) = res.into_parts();
57573                    let mut body = common::Body::new(body);
57574                    if !parts.status.is_success() {
57575                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57576                        let error = serde_json::from_str(&common::to_string(&bytes));
57577                        let response = common::to_response(parts, bytes.into());
57578
57579                        if let common::Retry::After(d) =
57580                            dlg.http_failure(&response, error.as_ref().ok())
57581                        {
57582                            sleep(d).await;
57583                            continue;
57584                        }
57585
57586                        dlg.finished(false);
57587
57588                        return Err(match error {
57589                            Ok(value) => common::Error::BadRequest(value),
57590                            _ => common::Error::Failure(response),
57591                        });
57592                    }
57593                    let response = {
57594                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57595                        let encoded = common::to_string(&bytes);
57596                        match serde_json::from_str(&encoded) {
57597                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
57598                            Err(error) => {
57599                                dlg.response_json_decode_error(&encoded, &error);
57600                                return Err(common::Error::JsonDecodeError(
57601                                    encoded.to_string(),
57602                                    error,
57603                                ));
57604                            }
57605                        }
57606                    };
57607
57608                    dlg.finished(true);
57609                    return Ok(response);
57610                }
57611            }
57612        }
57613    }
57614
57615    /// User profile ID associated with this request.
57616    ///
57617    /// Sets the *profile id* path property to the given value.
57618    ///
57619    /// Even though the property as already been set when instantiating this call,
57620    /// we provide this method for API completeness.
57621    pub fn profile_id(mut self, new_value: i64) -> OrderDocumentListCall<'a, C> {
57622        self._profile_id = new_value;
57623        self
57624    }
57625    /// Project ID for order documents.
57626    ///
57627    /// Sets the *project id* path property to the given value.
57628    ///
57629    /// Even though the property as already been set when instantiating this call,
57630    /// we provide this method for API completeness.
57631    pub fn project_id(mut self, new_value: i64) -> OrderDocumentListCall<'a, C> {
57632        self._project_id = new_value;
57633        self
57634    }
57635    /// Order of sorted results.
57636    ///
57637    /// Sets the *sort order* query property to the given value.
57638    pub fn sort_order(mut self, new_value: &str) -> OrderDocumentListCall<'a, C> {
57639        self._sort_order = Some(new_value.to_string());
57640        self
57641    }
57642    /// Field by which to sort the list.
57643    ///
57644    /// Sets the *sort field* query property to the given value.
57645    pub fn sort_field(mut self, new_value: &str) -> OrderDocumentListCall<'a, C> {
57646        self._sort_field = Some(new_value.to_string());
57647        self
57648    }
57649    /// Select only order documents that are associated with these sites.
57650    ///
57651    /// Append the given value to the *site id* query property.
57652    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
57653    pub fn add_site_id(mut self, new_value: i64) -> OrderDocumentListCall<'a, C> {
57654        self._site_id.push(new_value);
57655        self
57656    }
57657    /// Allows searching for order documents by name or ID. Wildcards (*) are allowed. For example, "orderdocument*2015" will return order documents with names like "orderdocument June 2015", "orderdocument April 2015", or simply "orderdocument 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "orderdocument" will match order documents with name "my orderdocument", "orderdocument 2015", or simply "orderdocument".
57658    ///
57659    /// Sets the *search string* query property to the given value.
57660    pub fn search_string(mut self, new_value: &str) -> OrderDocumentListCall<'a, C> {
57661        self._search_string = Some(new_value.to_string());
57662        self
57663    }
57664    /// Value of the nextPageToken from the previous result page.
57665    ///
57666    /// Sets the *page token* query property to the given value.
57667    pub fn page_token(mut self, new_value: &str) -> OrderDocumentListCall<'a, C> {
57668        self._page_token = Some(new_value.to_string());
57669        self
57670    }
57671    /// Select only order documents for specified orders.
57672    ///
57673    /// Append the given value to the *order id* query property.
57674    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
57675    pub fn add_order_id(mut self, new_value: i64) -> OrderDocumentListCall<'a, C> {
57676        self._order_id.push(new_value);
57677        self
57678    }
57679    /// Maximum number of results to return.
57680    ///
57681    /// Sets the *max results* query property to the given value.
57682    pub fn max_results(mut self, new_value: i32) -> OrderDocumentListCall<'a, C> {
57683        self._max_results = Some(new_value);
57684        self
57685    }
57686    /// Select only order documents with these IDs.
57687    ///
57688    /// Append the given value to the *ids* query property.
57689    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
57690    pub fn add_ids(mut self, new_value: i64) -> OrderDocumentListCall<'a, C> {
57691        self._ids.push(new_value);
57692        self
57693    }
57694    /// Select only order documents that have been approved by at least one user.
57695    ///
57696    /// Sets the *approved* query property to the given value.
57697    pub fn approved(mut self, new_value: bool) -> OrderDocumentListCall<'a, C> {
57698        self._approved = Some(new_value);
57699        self
57700    }
57701    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
57702    /// while executing the actual API request.
57703    ///
57704    /// ````text
57705    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
57706    /// ````
57707    ///
57708    /// Sets the *delegate* property to the given value.
57709    pub fn delegate(
57710        mut self,
57711        new_value: &'a mut dyn common::Delegate,
57712    ) -> OrderDocumentListCall<'a, C> {
57713        self._delegate = Some(new_value);
57714        self
57715    }
57716
57717    /// Set any additional parameter of the query string used in the request.
57718    /// It should be used to set parameters which are not yet available through their own
57719    /// setters.
57720    ///
57721    /// Please note that this method must not be used to set any of the known parameters
57722    /// which have their own setter method. If done anyway, the request will fail.
57723    ///
57724    /// # Additional Parameters
57725    ///
57726    /// * *alt* (query-string) - Data format for the response.
57727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
57728    /// * *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.
57729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
57730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
57731    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
57732    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
57733    pub fn param<T>(mut self, name: T, value: T) -> OrderDocumentListCall<'a, C>
57734    where
57735        T: AsRef<str>,
57736    {
57737        self._additional_params
57738            .insert(name.as_ref().to_string(), value.as_ref().to_string());
57739        self
57740    }
57741
57742    /// Identifies the authorization scope for the method you are building.
57743    ///
57744    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
57745    /// [`Scope::Dfatrafficking`].
57746    ///
57747    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
57748    /// tokens for more than one scope.
57749    ///
57750    /// Usually there is more than one suitable scope to authorize an operation, some of which may
57751    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
57752    /// sufficient, a read-write scope will do as well.
57753    pub fn add_scope<St>(mut self, scope: St) -> OrderDocumentListCall<'a, C>
57754    where
57755        St: AsRef<str>,
57756    {
57757        self._scopes.insert(String::from(scope.as_ref()));
57758        self
57759    }
57760    /// Identifies the authorization scope(s) for the method you are building.
57761    ///
57762    /// See [`Self::add_scope()`] for details.
57763    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderDocumentListCall<'a, C>
57764    where
57765        I: IntoIterator<Item = St>,
57766        St: AsRef<str>,
57767    {
57768        self._scopes
57769            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
57770        self
57771    }
57772
57773    /// Removes all scopes, and no default scope will be used either.
57774    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
57775    /// for details).
57776    pub fn clear_scopes(mut self) -> OrderDocumentListCall<'a, C> {
57777        self._scopes.clear();
57778        self
57779    }
57780}
57781
57782/// Gets one order by ID.
57783///
57784/// A builder for the *get* method supported by a *order* resource.
57785/// It is not used directly, but through a [`OrderMethods`] instance.
57786///
57787/// # Example
57788///
57789/// Instantiate a resource method builder
57790///
57791/// ```test_harness,no_run
57792/// # extern crate hyper;
57793/// # extern crate hyper_rustls;
57794/// # extern crate google_dfareporting3d2 as dfareporting3d2;
57795/// # async fn dox() {
57796/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57797///
57798/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
57799/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
57800/// #     secret,
57801/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
57802/// # ).build().await.unwrap();
57803///
57804/// # let client = hyper_util::client::legacy::Client::builder(
57805/// #     hyper_util::rt::TokioExecutor::new()
57806/// # )
57807/// # .build(
57808/// #     hyper_rustls::HttpsConnectorBuilder::new()
57809/// #         .with_native_roots()
57810/// #         .unwrap()
57811/// #         .https_or_http()
57812/// #         .enable_http1()
57813/// #         .build()
57814/// # );
57815/// # let mut hub = Dfareporting::new(client, auth);
57816/// // You can configure optional parameters by calling the respective setters at will, and
57817/// // execute the final call using `doit()`.
57818/// // Values shown here are possibly random and not representative !
57819/// let result = hub.orders().get(-6, -54, -97)
57820///              .doit().await;
57821/// # }
57822/// ```
57823pub struct OrderGetCall<'a, C>
57824where
57825    C: 'a,
57826{
57827    hub: &'a Dfareporting<C>,
57828    _profile_id: i64,
57829    _project_id: i64,
57830    _id: i64,
57831    _delegate: Option<&'a mut dyn common::Delegate>,
57832    _additional_params: HashMap<String, String>,
57833    _scopes: BTreeSet<String>,
57834}
57835
57836impl<'a, C> common::CallBuilder for OrderGetCall<'a, C> {}
57837
57838impl<'a, C> OrderGetCall<'a, C>
57839where
57840    C: common::Connector,
57841{
57842    /// Perform the operation you have build so far.
57843    pub async fn doit(mut self) -> common::Result<(common::Response, Order)> {
57844        use std::borrow::Cow;
57845        use std::io::{Read, Seek};
57846
57847        use common::{url::Params, ToParts};
57848        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
57849
57850        let mut dd = common::DefaultDelegate;
57851        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
57852        dlg.begin(common::MethodInfo {
57853            id: "dfareporting.orders.get",
57854            http_method: hyper::Method::GET,
57855        });
57856
57857        for &field in ["alt", "profileId", "projectId", "id"].iter() {
57858            if self._additional_params.contains_key(field) {
57859                dlg.finished(false);
57860                return Err(common::Error::FieldClash(field));
57861            }
57862        }
57863
57864        let mut params = Params::with_capacity(5 + self._additional_params.len());
57865        params.push("profileId", self._profile_id.to_string());
57866        params.push("projectId", self._project_id.to_string());
57867        params.push("id", self._id.to_string());
57868
57869        params.extend(self._additional_params.iter());
57870
57871        params.push("alt", "json");
57872        let mut url = self.hub._base_url.clone()
57873            + "userprofiles/{profileId}/projects/{projectId}/orders/{id}";
57874        if self._scopes.is_empty() {
57875            self._scopes
57876                .insert(Scope::Dfatrafficking.as_ref().to_string());
57877        }
57878
57879        #[allow(clippy::single_element_loop)]
57880        for &(find_this, param_name) in [
57881            ("{profileId}", "profileId"),
57882            ("{projectId}", "projectId"),
57883            ("{id}", "id"),
57884        ]
57885        .iter()
57886        {
57887            url = params.uri_replacement(url, param_name, find_this, false);
57888        }
57889        {
57890            let to_remove = ["id", "projectId", "profileId"];
57891            params.remove_params(&to_remove);
57892        }
57893
57894        let url = params.parse_with_url(&url);
57895
57896        loop {
57897            let token = match self
57898                .hub
57899                .auth
57900                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
57901                .await
57902            {
57903                Ok(token) => token,
57904                Err(e) => match dlg.token(e) {
57905                    Ok(token) => token,
57906                    Err(e) => {
57907                        dlg.finished(false);
57908                        return Err(common::Error::MissingToken(e));
57909                    }
57910                },
57911            };
57912            let mut req_result = {
57913                let client = &self.hub.client;
57914                dlg.pre_request();
57915                let mut req_builder = hyper::Request::builder()
57916                    .method(hyper::Method::GET)
57917                    .uri(url.as_str())
57918                    .header(USER_AGENT, self.hub._user_agent.clone());
57919
57920                if let Some(token) = token.as_ref() {
57921                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
57922                }
57923
57924                let request = req_builder
57925                    .header(CONTENT_LENGTH, 0_u64)
57926                    .body(common::to_body::<String>(None));
57927
57928                client.request(request.unwrap()).await
57929            };
57930
57931            match req_result {
57932                Err(err) => {
57933                    if let common::Retry::After(d) = dlg.http_error(&err) {
57934                        sleep(d).await;
57935                        continue;
57936                    }
57937                    dlg.finished(false);
57938                    return Err(common::Error::HttpError(err));
57939                }
57940                Ok(res) => {
57941                    let (mut parts, body) = res.into_parts();
57942                    let mut body = common::Body::new(body);
57943                    if !parts.status.is_success() {
57944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57945                        let error = serde_json::from_str(&common::to_string(&bytes));
57946                        let response = common::to_response(parts, bytes.into());
57947
57948                        if let common::Retry::After(d) =
57949                            dlg.http_failure(&response, error.as_ref().ok())
57950                        {
57951                            sleep(d).await;
57952                            continue;
57953                        }
57954
57955                        dlg.finished(false);
57956
57957                        return Err(match error {
57958                            Ok(value) => common::Error::BadRequest(value),
57959                            _ => common::Error::Failure(response),
57960                        });
57961                    }
57962                    let response = {
57963                        let bytes = common::to_bytes(body).await.unwrap_or_default();
57964                        let encoded = common::to_string(&bytes);
57965                        match serde_json::from_str(&encoded) {
57966                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
57967                            Err(error) => {
57968                                dlg.response_json_decode_error(&encoded, &error);
57969                                return Err(common::Error::JsonDecodeError(
57970                                    encoded.to_string(),
57971                                    error,
57972                                ));
57973                            }
57974                        }
57975                    };
57976
57977                    dlg.finished(true);
57978                    return Ok(response);
57979                }
57980            }
57981        }
57982    }
57983
57984    /// User profile ID associated with this request.
57985    ///
57986    /// Sets the *profile id* path property to the given value.
57987    ///
57988    /// Even though the property as already been set when instantiating this call,
57989    /// we provide this method for API completeness.
57990    pub fn profile_id(mut self, new_value: i64) -> OrderGetCall<'a, C> {
57991        self._profile_id = new_value;
57992        self
57993    }
57994    /// Project ID for orders.
57995    ///
57996    /// Sets the *project id* path property to the given value.
57997    ///
57998    /// Even though the property as already been set when instantiating this call,
57999    /// we provide this method for API completeness.
58000    pub fn project_id(mut self, new_value: i64) -> OrderGetCall<'a, C> {
58001        self._project_id = new_value;
58002        self
58003    }
58004    /// Order ID.
58005    ///
58006    /// Sets the *id* path property to the given value.
58007    ///
58008    /// Even though the property as already been set when instantiating this call,
58009    /// we provide this method for API completeness.
58010    pub fn id(mut self, new_value: i64) -> OrderGetCall<'a, C> {
58011        self._id = new_value;
58012        self
58013    }
58014    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
58015    /// while executing the actual API request.
58016    ///
58017    /// ````text
58018    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
58019    /// ````
58020    ///
58021    /// Sets the *delegate* property to the given value.
58022    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderGetCall<'a, C> {
58023        self._delegate = Some(new_value);
58024        self
58025    }
58026
58027    /// Set any additional parameter of the query string used in the request.
58028    /// It should be used to set parameters which are not yet available through their own
58029    /// setters.
58030    ///
58031    /// Please note that this method must not be used to set any of the known parameters
58032    /// which have their own setter method. If done anyway, the request will fail.
58033    ///
58034    /// # Additional Parameters
58035    ///
58036    /// * *alt* (query-string) - Data format for the response.
58037    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
58038    /// * *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.
58039    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
58040    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
58041    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
58042    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
58043    pub fn param<T>(mut self, name: T, value: T) -> OrderGetCall<'a, C>
58044    where
58045        T: AsRef<str>,
58046    {
58047        self._additional_params
58048            .insert(name.as_ref().to_string(), value.as_ref().to_string());
58049        self
58050    }
58051
58052    /// Identifies the authorization scope for the method you are building.
58053    ///
58054    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
58055    /// [`Scope::Dfatrafficking`].
58056    ///
58057    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
58058    /// tokens for more than one scope.
58059    ///
58060    /// Usually there is more than one suitable scope to authorize an operation, some of which may
58061    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
58062    /// sufficient, a read-write scope will do as well.
58063    pub fn add_scope<St>(mut self, scope: St) -> OrderGetCall<'a, C>
58064    where
58065        St: AsRef<str>,
58066    {
58067        self._scopes.insert(String::from(scope.as_ref()));
58068        self
58069    }
58070    /// Identifies the authorization scope(s) for the method you are building.
58071    ///
58072    /// See [`Self::add_scope()`] for details.
58073    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderGetCall<'a, C>
58074    where
58075        I: IntoIterator<Item = St>,
58076        St: AsRef<str>,
58077    {
58078        self._scopes
58079            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
58080        self
58081    }
58082
58083    /// Removes all scopes, and no default scope will be used either.
58084    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
58085    /// for details).
58086    pub fn clear_scopes(mut self) -> OrderGetCall<'a, C> {
58087        self._scopes.clear();
58088        self
58089    }
58090}
58091
58092/// Retrieves a list of orders, possibly filtered. This method supports paging.
58093///
58094/// A builder for the *list* method supported by a *order* resource.
58095/// It is not used directly, but through a [`OrderMethods`] instance.
58096///
58097/// # Example
58098///
58099/// Instantiate a resource method builder
58100///
58101/// ```test_harness,no_run
58102/// # extern crate hyper;
58103/// # extern crate hyper_rustls;
58104/// # extern crate google_dfareporting3d2 as dfareporting3d2;
58105/// # async fn dox() {
58106/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58107///
58108/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
58109/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
58110/// #     secret,
58111/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
58112/// # ).build().await.unwrap();
58113///
58114/// # let client = hyper_util::client::legacy::Client::builder(
58115/// #     hyper_util::rt::TokioExecutor::new()
58116/// # )
58117/// # .build(
58118/// #     hyper_rustls::HttpsConnectorBuilder::new()
58119/// #         .with_native_roots()
58120/// #         .unwrap()
58121/// #         .https_or_http()
58122/// #         .enable_http1()
58123/// #         .build()
58124/// # );
58125/// # let mut hub = Dfareporting::new(client, auth);
58126/// // You can configure optional parameters by calling the respective setters at will, and
58127/// // execute the final call using `doit()`.
58128/// // Values shown here are possibly random and not representative !
58129/// let result = hub.orders().list(-83, -83)
58130///              .sort_order("invidunt")
58131///              .sort_field("et")
58132///              .add_site_id(-22)
58133///              .search_string("dolor")
58134///              .page_token("erat")
58135///              .max_results(-84)
58136///              .add_ids(-76)
58137///              .doit().await;
58138/// # }
58139/// ```
58140pub struct OrderListCall<'a, C>
58141where
58142    C: 'a,
58143{
58144    hub: &'a Dfareporting<C>,
58145    _profile_id: i64,
58146    _project_id: i64,
58147    _sort_order: Option<String>,
58148    _sort_field: Option<String>,
58149    _site_id: Vec<i64>,
58150    _search_string: Option<String>,
58151    _page_token: Option<String>,
58152    _max_results: Option<i32>,
58153    _ids: Vec<i64>,
58154    _delegate: Option<&'a mut dyn common::Delegate>,
58155    _additional_params: HashMap<String, String>,
58156    _scopes: BTreeSet<String>,
58157}
58158
58159impl<'a, C> common::CallBuilder for OrderListCall<'a, C> {}
58160
58161impl<'a, C> OrderListCall<'a, C>
58162where
58163    C: common::Connector,
58164{
58165    /// Perform the operation you have build so far.
58166    pub async fn doit(mut self) -> common::Result<(common::Response, OrdersListResponse)> {
58167        use std::borrow::Cow;
58168        use std::io::{Read, Seek};
58169
58170        use common::{url::Params, ToParts};
58171        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
58172
58173        let mut dd = common::DefaultDelegate;
58174        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
58175        dlg.begin(common::MethodInfo {
58176            id: "dfareporting.orders.list",
58177            http_method: hyper::Method::GET,
58178        });
58179
58180        for &field in [
58181            "alt",
58182            "profileId",
58183            "projectId",
58184            "sortOrder",
58185            "sortField",
58186            "siteId",
58187            "searchString",
58188            "pageToken",
58189            "maxResults",
58190            "ids",
58191        ]
58192        .iter()
58193        {
58194            if self._additional_params.contains_key(field) {
58195                dlg.finished(false);
58196                return Err(common::Error::FieldClash(field));
58197            }
58198        }
58199
58200        let mut params = Params::with_capacity(11 + self._additional_params.len());
58201        params.push("profileId", self._profile_id.to_string());
58202        params.push("projectId", self._project_id.to_string());
58203        if let Some(value) = self._sort_order.as_ref() {
58204            params.push("sortOrder", value);
58205        }
58206        if let Some(value) = self._sort_field.as_ref() {
58207            params.push("sortField", value);
58208        }
58209        if !self._site_id.is_empty() {
58210            for f in self._site_id.iter() {
58211                params.push("siteId", f.to_string());
58212            }
58213        }
58214        if let Some(value) = self._search_string.as_ref() {
58215            params.push("searchString", value);
58216        }
58217        if let Some(value) = self._page_token.as_ref() {
58218            params.push("pageToken", value);
58219        }
58220        if let Some(value) = self._max_results.as_ref() {
58221            params.push("maxResults", value.to_string());
58222        }
58223        if !self._ids.is_empty() {
58224            for f in self._ids.iter() {
58225                params.push("ids", f.to_string());
58226            }
58227        }
58228
58229        params.extend(self._additional_params.iter());
58230
58231        params.push("alt", "json");
58232        let mut url =
58233            self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/orders";
58234        if self._scopes.is_empty() {
58235            self._scopes
58236                .insert(Scope::Dfatrafficking.as_ref().to_string());
58237        }
58238
58239        #[allow(clippy::single_element_loop)]
58240        for &(find_this, param_name) in
58241            [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter()
58242        {
58243            url = params.uri_replacement(url, param_name, find_this, false);
58244        }
58245        {
58246            let to_remove = ["projectId", "profileId"];
58247            params.remove_params(&to_remove);
58248        }
58249
58250        let url = params.parse_with_url(&url);
58251
58252        loop {
58253            let token = match self
58254                .hub
58255                .auth
58256                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
58257                .await
58258            {
58259                Ok(token) => token,
58260                Err(e) => match dlg.token(e) {
58261                    Ok(token) => token,
58262                    Err(e) => {
58263                        dlg.finished(false);
58264                        return Err(common::Error::MissingToken(e));
58265                    }
58266                },
58267            };
58268            let mut req_result = {
58269                let client = &self.hub.client;
58270                dlg.pre_request();
58271                let mut req_builder = hyper::Request::builder()
58272                    .method(hyper::Method::GET)
58273                    .uri(url.as_str())
58274                    .header(USER_AGENT, self.hub._user_agent.clone());
58275
58276                if let Some(token) = token.as_ref() {
58277                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
58278                }
58279
58280                let request = req_builder
58281                    .header(CONTENT_LENGTH, 0_u64)
58282                    .body(common::to_body::<String>(None));
58283
58284                client.request(request.unwrap()).await
58285            };
58286
58287            match req_result {
58288                Err(err) => {
58289                    if let common::Retry::After(d) = dlg.http_error(&err) {
58290                        sleep(d).await;
58291                        continue;
58292                    }
58293                    dlg.finished(false);
58294                    return Err(common::Error::HttpError(err));
58295                }
58296                Ok(res) => {
58297                    let (mut parts, body) = res.into_parts();
58298                    let mut body = common::Body::new(body);
58299                    if !parts.status.is_success() {
58300                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58301                        let error = serde_json::from_str(&common::to_string(&bytes));
58302                        let response = common::to_response(parts, bytes.into());
58303
58304                        if let common::Retry::After(d) =
58305                            dlg.http_failure(&response, error.as_ref().ok())
58306                        {
58307                            sleep(d).await;
58308                            continue;
58309                        }
58310
58311                        dlg.finished(false);
58312
58313                        return Err(match error {
58314                            Ok(value) => common::Error::BadRequest(value),
58315                            _ => common::Error::Failure(response),
58316                        });
58317                    }
58318                    let response = {
58319                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58320                        let encoded = common::to_string(&bytes);
58321                        match serde_json::from_str(&encoded) {
58322                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
58323                            Err(error) => {
58324                                dlg.response_json_decode_error(&encoded, &error);
58325                                return Err(common::Error::JsonDecodeError(
58326                                    encoded.to_string(),
58327                                    error,
58328                                ));
58329                            }
58330                        }
58331                    };
58332
58333                    dlg.finished(true);
58334                    return Ok(response);
58335                }
58336            }
58337        }
58338    }
58339
58340    /// User profile ID associated with this request.
58341    ///
58342    /// Sets the *profile id* path property to the given value.
58343    ///
58344    /// Even though the property as already been set when instantiating this call,
58345    /// we provide this method for API completeness.
58346    pub fn profile_id(mut self, new_value: i64) -> OrderListCall<'a, C> {
58347        self._profile_id = new_value;
58348        self
58349    }
58350    /// Project ID for orders.
58351    ///
58352    /// Sets the *project id* path property to the given value.
58353    ///
58354    /// Even though the property as already been set when instantiating this call,
58355    /// we provide this method for API completeness.
58356    pub fn project_id(mut self, new_value: i64) -> OrderListCall<'a, C> {
58357        self._project_id = new_value;
58358        self
58359    }
58360    /// Order of sorted results.
58361    ///
58362    /// Sets the *sort order* query property to the given value.
58363    pub fn sort_order(mut self, new_value: &str) -> OrderListCall<'a, C> {
58364        self._sort_order = Some(new_value.to_string());
58365        self
58366    }
58367    /// Field by which to sort the list.
58368    ///
58369    /// Sets the *sort field* query property to the given value.
58370    pub fn sort_field(mut self, new_value: &str) -> OrderListCall<'a, C> {
58371        self._sort_field = Some(new_value.to_string());
58372        self
58373    }
58374    /// Select only orders that are associated with these site IDs.
58375    ///
58376    /// Append the given value to the *site id* query property.
58377    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
58378    pub fn add_site_id(mut self, new_value: i64) -> OrderListCall<'a, C> {
58379        self._site_id.push(new_value);
58380        self
58381    }
58382    /// Allows searching for orders by name or ID. Wildcards (*) are allowed. For example, "order*2015" will return orders with names like "order June 2015", "order April 2015", or simply "order 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "order" will match orders with name "my order", "order 2015", or simply "order".
58383    ///
58384    /// Sets the *search string* query property to the given value.
58385    pub fn search_string(mut self, new_value: &str) -> OrderListCall<'a, C> {
58386        self._search_string = Some(new_value.to_string());
58387        self
58388    }
58389    /// Value of the nextPageToken from the previous result page.
58390    ///
58391    /// Sets the *page token* query property to the given value.
58392    pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, C> {
58393        self._page_token = Some(new_value.to_string());
58394        self
58395    }
58396    /// Maximum number of results to return.
58397    ///
58398    /// Sets the *max results* query property to the given value.
58399    pub fn max_results(mut self, new_value: i32) -> OrderListCall<'a, C> {
58400        self._max_results = Some(new_value);
58401        self
58402    }
58403    /// Select only orders with these IDs.
58404    ///
58405    /// Append the given value to the *ids* query property.
58406    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
58407    pub fn add_ids(mut self, new_value: i64) -> OrderListCall<'a, C> {
58408        self._ids.push(new_value);
58409        self
58410    }
58411    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
58412    /// while executing the actual API request.
58413    ///
58414    /// ````text
58415    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
58416    /// ````
58417    ///
58418    /// Sets the *delegate* property to the given value.
58419    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OrderListCall<'a, C> {
58420        self._delegate = Some(new_value);
58421        self
58422    }
58423
58424    /// Set any additional parameter of the query string used in the request.
58425    /// It should be used to set parameters which are not yet available through their own
58426    /// setters.
58427    ///
58428    /// Please note that this method must not be used to set any of the known parameters
58429    /// which have their own setter method. If done anyway, the request will fail.
58430    ///
58431    /// # Additional Parameters
58432    ///
58433    /// * *alt* (query-string) - Data format for the response.
58434    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
58435    /// * *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.
58436    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
58437    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
58438    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
58439    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
58440    pub fn param<T>(mut self, name: T, value: T) -> OrderListCall<'a, C>
58441    where
58442        T: AsRef<str>,
58443    {
58444        self._additional_params
58445            .insert(name.as_ref().to_string(), value.as_ref().to_string());
58446        self
58447    }
58448
58449    /// Identifies the authorization scope for the method you are building.
58450    ///
58451    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
58452    /// [`Scope::Dfatrafficking`].
58453    ///
58454    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
58455    /// tokens for more than one scope.
58456    ///
58457    /// Usually there is more than one suitable scope to authorize an operation, some of which may
58458    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
58459    /// sufficient, a read-write scope will do as well.
58460    pub fn add_scope<St>(mut self, scope: St) -> OrderListCall<'a, C>
58461    where
58462        St: AsRef<str>,
58463    {
58464        self._scopes.insert(String::from(scope.as_ref()));
58465        self
58466    }
58467    /// Identifies the authorization scope(s) for the method you are building.
58468    ///
58469    /// See [`Self::add_scope()`] for details.
58470    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrderListCall<'a, C>
58471    where
58472        I: IntoIterator<Item = St>,
58473        St: AsRef<str>,
58474    {
58475        self._scopes
58476            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
58477        self
58478    }
58479
58480    /// Removes all scopes, and no default scope will be used either.
58481    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
58482    /// for details).
58483    pub fn clear_scopes(mut self) -> OrderListCall<'a, C> {
58484        self._scopes.clear();
58485        self
58486    }
58487}
58488
58489/// Gets one placement group by ID.
58490///
58491/// A builder for the *get* method supported by a *placementGroup* resource.
58492/// It is not used directly, but through a [`PlacementGroupMethods`] instance.
58493///
58494/// # Example
58495///
58496/// Instantiate a resource method builder
58497///
58498/// ```test_harness,no_run
58499/// # extern crate hyper;
58500/// # extern crate hyper_rustls;
58501/// # extern crate google_dfareporting3d2 as dfareporting3d2;
58502/// # async fn dox() {
58503/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58504///
58505/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
58506/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
58507/// #     secret,
58508/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
58509/// # ).build().await.unwrap();
58510///
58511/// # let client = hyper_util::client::legacy::Client::builder(
58512/// #     hyper_util::rt::TokioExecutor::new()
58513/// # )
58514/// # .build(
58515/// #     hyper_rustls::HttpsConnectorBuilder::new()
58516/// #         .with_native_roots()
58517/// #         .unwrap()
58518/// #         .https_or_http()
58519/// #         .enable_http1()
58520/// #         .build()
58521/// # );
58522/// # let mut hub = Dfareporting::new(client, auth);
58523/// // You can configure optional parameters by calling the respective setters at will, and
58524/// // execute the final call using `doit()`.
58525/// // Values shown here are possibly random and not representative !
58526/// let result = hub.placement_groups().get(-17, -68)
58527///              .doit().await;
58528/// # }
58529/// ```
58530pub struct PlacementGroupGetCall<'a, C>
58531where
58532    C: 'a,
58533{
58534    hub: &'a Dfareporting<C>,
58535    _profile_id: i64,
58536    _id: i64,
58537    _delegate: Option<&'a mut dyn common::Delegate>,
58538    _additional_params: HashMap<String, String>,
58539    _scopes: BTreeSet<String>,
58540}
58541
58542impl<'a, C> common::CallBuilder for PlacementGroupGetCall<'a, C> {}
58543
58544impl<'a, C> PlacementGroupGetCall<'a, C>
58545where
58546    C: common::Connector,
58547{
58548    /// Perform the operation you have build so far.
58549    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementGroup)> {
58550        use std::borrow::Cow;
58551        use std::io::{Read, Seek};
58552
58553        use common::{url::Params, ToParts};
58554        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
58555
58556        let mut dd = common::DefaultDelegate;
58557        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
58558        dlg.begin(common::MethodInfo {
58559            id: "dfareporting.placementGroups.get",
58560            http_method: hyper::Method::GET,
58561        });
58562
58563        for &field in ["alt", "profileId", "id"].iter() {
58564            if self._additional_params.contains_key(field) {
58565                dlg.finished(false);
58566                return Err(common::Error::FieldClash(field));
58567            }
58568        }
58569
58570        let mut params = Params::with_capacity(4 + self._additional_params.len());
58571        params.push("profileId", self._profile_id.to_string());
58572        params.push("id", self._id.to_string());
58573
58574        params.extend(self._additional_params.iter());
58575
58576        params.push("alt", "json");
58577        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups/{id}";
58578        if self._scopes.is_empty() {
58579            self._scopes
58580                .insert(Scope::Dfatrafficking.as_ref().to_string());
58581        }
58582
58583        #[allow(clippy::single_element_loop)]
58584        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
58585            url = params.uri_replacement(url, param_name, find_this, false);
58586        }
58587        {
58588            let to_remove = ["id", "profileId"];
58589            params.remove_params(&to_remove);
58590        }
58591
58592        let url = params.parse_with_url(&url);
58593
58594        loop {
58595            let token = match self
58596                .hub
58597                .auth
58598                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
58599                .await
58600            {
58601                Ok(token) => token,
58602                Err(e) => match dlg.token(e) {
58603                    Ok(token) => token,
58604                    Err(e) => {
58605                        dlg.finished(false);
58606                        return Err(common::Error::MissingToken(e));
58607                    }
58608                },
58609            };
58610            let mut req_result = {
58611                let client = &self.hub.client;
58612                dlg.pre_request();
58613                let mut req_builder = hyper::Request::builder()
58614                    .method(hyper::Method::GET)
58615                    .uri(url.as_str())
58616                    .header(USER_AGENT, self.hub._user_agent.clone());
58617
58618                if let Some(token) = token.as_ref() {
58619                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
58620                }
58621
58622                let request = req_builder
58623                    .header(CONTENT_LENGTH, 0_u64)
58624                    .body(common::to_body::<String>(None));
58625
58626                client.request(request.unwrap()).await
58627            };
58628
58629            match req_result {
58630                Err(err) => {
58631                    if let common::Retry::After(d) = dlg.http_error(&err) {
58632                        sleep(d).await;
58633                        continue;
58634                    }
58635                    dlg.finished(false);
58636                    return Err(common::Error::HttpError(err));
58637                }
58638                Ok(res) => {
58639                    let (mut parts, body) = res.into_parts();
58640                    let mut body = common::Body::new(body);
58641                    if !parts.status.is_success() {
58642                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58643                        let error = serde_json::from_str(&common::to_string(&bytes));
58644                        let response = common::to_response(parts, bytes.into());
58645
58646                        if let common::Retry::After(d) =
58647                            dlg.http_failure(&response, error.as_ref().ok())
58648                        {
58649                            sleep(d).await;
58650                            continue;
58651                        }
58652
58653                        dlg.finished(false);
58654
58655                        return Err(match error {
58656                            Ok(value) => common::Error::BadRequest(value),
58657                            _ => common::Error::Failure(response),
58658                        });
58659                    }
58660                    let response = {
58661                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58662                        let encoded = common::to_string(&bytes);
58663                        match serde_json::from_str(&encoded) {
58664                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
58665                            Err(error) => {
58666                                dlg.response_json_decode_error(&encoded, &error);
58667                                return Err(common::Error::JsonDecodeError(
58668                                    encoded.to_string(),
58669                                    error,
58670                                ));
58671                            }
58672                        }
58673                    };
58674
58675                    dlg.finished(true);
58676                    return Ok(response);
58677                }
58678            }
58679        }
58680    }
58681
58682    /// User profile ID associated with this request.
58683    ///
58684    /// Sets the *profile id* path property to the given value.
58685    ///
58686    /// Even though the property as already been set when instantiating this call,
58687    /// we provide this method for API completeness.
58688    pub fn profile_id(mut self, new_value: i64) -> PlacementGroupGetCall<'a, C> {
58689        self._profile_id = new_value;
58690        self
58691    }
58692    /// Placement group ID.
58693    ///
58694    /// Sets the *id* path property to the given value.
58695    ///
58696    /// Even though the property as already been set when instantiating this call,
58697    /// we provide this method for API completeness.
58698    pub fn id(mut self, new_value: i64) -> PlacementGroupGetCall<'a, C> {
58699        self._id = new_value;
58700        self
58701    }
58702    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
58703    /// while executing the actual API request.
58704    ///
58705    /// ````text
58706    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
58707    /// ````
58708    ///
58709    /// Sets the *delegate* property to the given value.
58710    pub fn delegate(
58711        mut self,
58712        new_value: &'a mut dyn common::Delegate,
58713    ) -> PlacementGroupGetCall<'a, C> {
58714        self._delegate = Some(new_value);
58715        self
58716    }
58717
58718    /// Set any additional parameter of the query string used in the request.
58719    /// It should be used to set parameters which are not yet available through their own
58720    /// setters.
58721    ///
58722    /// Please note that this method must not be used to set any of the known parameters
58723    /// which have their own setter method. If done anyway, the request will fail.
58724    ///
58725    /// # Additional Parameters
58726    ///
58727    /// * *alt* (query-string) - Data format for the response.
58728    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
58729    /// * *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.
58730    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
58731    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
58732    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
58733    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
58734    pub fn param<T>(mut self, name: T, value: T) -> PlacementGroupGetCall<'a, C>
58735    where
58736        T: AsRef<str>,
58737    {
58738        self._additional_params
58739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
58740        self
58741    }
58742
58743    /// Identifies the authorization scope for the method you are building.
58744    ///
58745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
58746    /// [`Scope::Dfatrafficking`].
58747    ///
58748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
58749    /// tokens for more than one scope.
58750    ///
58751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
58752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
58753    /// sufficient, a read-write scope will do as well.
58754    pub fn add_scope<St>(mut self, scope: St) -> PlacementGroupGetCall<'a, C>
58755    where
58756        St: AsRef<str>,
58757    {
58758        self._scopes.insert(String::from(scope.as_ref()));
58759        self
58760    }
58761    /// Identifies the authorization scope(s) for the method you are building.
58762    ///
58763    /// See [`Self::add_scope()`] for details.
58764    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGroupGetCall<'a, C>
58765    where
58766        I: IntoIterator<Item = St>,
58767        St: AsRef<str>,
58768    {
58769        self._scopes
58770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
58771        self
58772    }
58773
58774    /// Removes all scopes, and no default scope will be used either.
58775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
58776    /// for details).
58777    pub fn clear_scopes(mut self) -> PlacementGroupGetCall<'a, C> {
58778        self._scopes.clear();
58779        self
58780    }
58781}
58782
58783/// Inserts a new placement group.
58784///
58785/// A builder for the *insert* method supported by a *placementGroup* resource.
58786/// It is not used directly, but through a [`PlacementGroupMethods`] instance.
58787///
58788/// # Example
58789///
58790/// Instantiate a resource method builder
58791///
58792/// ```test_harness,no_run
58793/// # extern crate hyper;
58794/// # extern crate hyper_rustls;
58795/// # extern crate google_dfareporting3d2 as dfareporting3d2;
58796/// use dfareporting3d2::api::PlacementGroup;
58797/// # async fn dox() {
58798/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58799///
58800/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
58801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
58802/// #     secret,
58803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
58804/// # ).build().await.unwrap();
58805///
58806/// # let client = hyper_util::client::legacy::Client::builder(
58807/// #     hyper_util::rt::TokioExecutor::new()
58808/// # )
58809/// # .build(
58810/// #     hyper_rustls::HttpsConnectorBuilder::new()
58811/// #         .with_native_roots()
58812/// #         .unwrap()
58813/// #         .https_or_http()
58814/// #         .enable_http1()
58815/// #         .build()
58816/// # );
58817/// # let mut hub = Dfareporting::new(client, auth);
58818/// // As the method needs a request, you would usually fill it with the desired information
58819/// // into the respective structure. Some of the parts shown here might not be applicable !
58820/// // Values shown here are possibly random and not representative !
58821/// let mut req = PlacementGroup::default();
58822///
58823/// // You can configure optional parameters by calling the respective setters at will, and
58824/// // execute the final call using `doit()`.
58825/// // Values shown here are possibly random and not representative !
58826/// let result = hub.placement_groups().insert(req, -52)
58827///              .doit().await;
58828/// # }
58829/// ```
58830pub struct PlacementGroupInsertCall<'a, C>
58831where
58832    C: 'a,
58833{
58834    hub: &'a Dfareporting<C>,
58835    _request: PlacementGroup,
58836    _profile_id: i64,
58837    _delegate: Option<&'a mut dyn common::Delegate>,
58838    _additional_params: HashMap<String, String>,
58839    _scopes: BTreeSet<String>,
58840}
58841
58842impl<'a, C> common::CallBuilder for PlacementGroupInsertCall<'a, C> {}
58843
58844impl<'a, C> PlacementGroupInsertCall<'a, C>
58845where
58846    C: common::Connector,
58847{
58848    /// Perform the operation you have build so far.
58849    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementGroup)> {
58850        use std::borrow::Cow;
58851        use std::io::{Read, Seek};
58852
58853        use common::{url::Params, ToParts};
58854        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
58855
58856        let mut dd = common::DefaultDelegate;
58857        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
58858        dlg.begin(common::MethodInfo {
58859            id: "dfareporting.placementGroups.insert",
58860            http_method: hyper::Method::POST,
58861        });
58862
58863        for &field in ["alt", "profileId"].iter() {
58864            if self._additional_params.contains_key(field) {
58865                dlg.finished(false);
58866                return Err(common::Error::FieldClash(field));
58867            }
58868        }
58869
58870        let mut params = Params::with_capacity(4 + self._additional_params.len());
58871        params.push("profileId", self._profile_id.to_string());
58872
58873        params.extend(self._additional_params.iter());
58874
58875        params.push("alt", "json");
58876        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups";
58877        if self._scopes.is_empty() {
58878            self._scopes
58879                .insert(Scope::Dfatrafficking.as_ref().to_string());
58880        }
58881
58882        #[allow(clippy::single_element_loop)]
58883        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
58884            url = params.uri_replacement(url, param_name, find_this, false);
58885        }
58886        {
58887            let to_remove = ["profileId"];
58888            params.remove_params(&to_remove);
58889        }
58890
58891        let url = params.parse_with_url(&url);
58892
58893        let mut json_mime_type = mime::APPLICATION_JSON;
58894        let mut request_value_reader = {
58895            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
58896            common::remove_json_null_values(&mut value);
58897            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
58898            serde_json::to_writer(&mut dst, &value).unwrap();
58899            dst
58900        };
58901        let request_size = request_value_reader
58902            .seek(std::io::SeekFrom::End(0))
58903            .unwrap();
58904        request_value_reader
58905            .seek(std::io::SeekFrom::Start(0))
58906            .unwrap();
58907
58908        loop {
58909            let token = match self
58910                .hub
58911                .auth
58912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
58913                .await
58914            {
58915                Ok(token) => token,
58916                Err(e) => match dlg.token(e) {
58917                    Ok(token) => token,
58918                    Err(e) => {
58919                        dlg.finished(false);
58920                        return Err(common::Error::MissingToken(e));
58921                    }
58922                },
58923            };
58924            request_value_reader
58925                .seek(std::io::SeekFrom::Start(0))
58926                .unwrap();
58927            let mut req_result = {
58928                let client = &self.hub.client;
58929                dlg.pre_request();
58930                let mut req_builder = hyper::Request::builder()
58931                    .method(hyper::Method::POST)
58932                    .uri(url.as_str())
58933                    .header(USER_AGENT, self.hub._user_agent.clone());
58934
58935                if let Some(token) = token.as_ref() {
58936                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
58937                }
58938
58939                let request = req_builder
58940                    .header(CONTENT_TYPE, json_mime_type.to_string())
58941                    .header(CONTENT_LENGTH, request_size as u64)
58942                    .body(common::to_body(
58943                        request_value_reader.get_ref().clone().into(),
58944                    ));
58945
58946                client.request(request.unwrap()).await
58947            };
58948
58949            match req_result {
58950                Err(err) => {
58951                    if let common::Retry::After(d) = dlg.http_error(&err) {
58952                        sleep(d).await;
58953                        continue;
58954                    }
58955                    dlg.finished(false);
58956                    return Err(common::Error::HttpError(err));
58957                }
58958                Ok(res) => {
58959                    let (mut parts, body) = res.into_parts();
58960                    let mut body = common::Body::new(body);
58961                    if !parts.status.is_success() {
58962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58963                        let error = serde_json::from_str(&common::to_string(&bytes));
58964                        let response = common::to_response(parts, bytes.into());
58965
58966                        if let common::Retry::After(d) =
58967                            dlg.http_failure(&response, error.as_ref().ok())
58968                        {
58969                            sleep(d).await;
58970                            continue;
58971                        }
58972
58973                        dlg.finished(false);
58974
58975                        return Err(match error {
58976                            Ok(value) => common::Error::BadRequest(value),
58977                            _ => common::Error::Failure(response),
58978                        });
58979                    }
58980                    let response = {
58981                        let bytes = common::to_bytes(body).await.unwrap_or_default();
58982                        let encoded = common::to_string(&bytes);
58983                        match serde_json::from_str(&encoded) {
58984                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
58985                            Err(error) => {
58986                                dlg.response_json_decode_error(&encoded, &error);
58987                                return Err(common::Error::JsonDecodeError(
58988                                    encoded.to_string(),
58989                                    error,
58990                                ));
58991                            }
58992                        }
58993                    };
58994
58995                    dlg.finished(true);
58996                    return Ok(response);
58997                }
58998            }
58999        }
59000    }
59001
59002    ///
59003    /// Sets the *request* property to the given value.
59004    ///
59005    /// Even though the property as already been set when instantiating this call,
59006    /// we provide this method for API completeness.
59007    pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupInsertCall<'a, C> {
59008        self._request = new_value;
59009        self
59010    }
59011    /// User profile ID associated with this request.
59012    ///
59013    /// Sets the *profile id* path property to the given value.
59014    ///
59015    /// Even though the property as already been set when instantiating this call,
59016    /// we provide this method for API completeness.
59017    pub fn profile_id(mut self, new_value: i64) -> PlacementGroupInsertCall<'a, C> {
59018        self._profile_id = new_value;
59019        self
59020    }
59021    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
59022    /// while executing the actual API request.
59023    ///
59024    /// ````text
59025    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
59026    /// ````
59027    ///
59028    /// Sets the *delegate* property to the given value.
59029    pub fn delegate(
59030        mut self,
59031        new_value: &'a mut dyn common::Delegate,
59032    ) -> PlacementGroupInsertCall<'a, C> {
59033        self._delegate = Some(new_value);
59034        self
59035    }
59036
59037    /// Set any additional parameter of the query string used in the request.
59038    /// It should be used to set parameters which are not yet available through their own
59039    /// setters.
59040    ///
59041    /// Please note that this method must not be used to set any of the known parameters
59042    /// which have their own setter method. If done anyway, the request will fail.
59043    ///
59044    /// # Additional Parameters
59045    ///
59046    /// * *alt* (query-string) - Data format for the response.
59047    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
59048    /// * *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.
59049    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
59050    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
59051    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
59052    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
59053    pub fn param<T>(mut self, name: T, value: T) -> PlacementGroupInsertCall<'a, C>
59054    where
59055        T: AsRef<str>,
59056    {
59057        self._additional_params
59058            .insert(name.as_ref().to_string(), value.as_ref().to_string());
59059        self
59060    }
59061
59062    /// Identifies the authorization scope for the method you are building.
59063    ///
59064    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
59065    /// [`Scope::Dfatrafficking`].
59066    ///
59067    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
59068    /// tokens for more than one scope.
59069    ///
59070    /// Usually there is more than one suitable scope to authorize an operation, some of which may
59071    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
59072    /// sufficient, a read-write scope will do as well.
59073    pub fn add_scope<St>(mut self, scope: St) -> PlacementGroupInsertCall<'a, C>
59074    where
59075        St: AsRef<str>,
59076    {
59077        self._scopes.insert(String::from(scope.as_ref()));
59078        self
59079    }
59080    /// Identifies the authorization scope(s) for the method you are building.
59081    ///
59082    /// See [`Self::add_scope()`] for details.
59083    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGroupInsertCall<'a, C>
59084    where
59085        I: IntoIterator<Item = St>,
59086        St: AsRef<str>,
59087    {
59088        self._scopes
59089            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
59090        self
59091    }
59092
59093    /// Removes all scopes, and no default scope will be used either.
59094    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
59095    /// for details).
59096    pub fn clear_scopes(mut self) -> PlacementGroupInsertCall<'a, C> {
59097        self._scopes.clear();
59098        self
59099    }
59100}
59101
59102/// Retrieves a list of placement groups, possibly filtered. This method supports paging.
59103///
59104/// A builder for the *list* method supported by a *placementGroup* resource.
59105/// It is not used directly, but through a [`PlacementGroupMethods`] instance.
59106///
59107/// # Example
59108///
59109/// Instantiate a resource method builder
59110///
59111/// ```test_harness,no_run
59112/// # extern crate hyper;
59113/// # extern crate hyper_rustls;
59114/// # extern crate google_dfareporting3d2 as dfareporting3d2;
59115/// # async fn dox() {
59116/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
59117///
59118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
59119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
59120/// #     secret,
59121/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
59122/// # ).build().await.unwrap();
59123///
59124/// # let client = hyper_util::client::legacy::Client::builder(
59125/// #     hyper_util::rt::TokioExecutor::new()
59126/// # )
59127/// # .build(
59128/// #     hyper_rustls::HttpsConnectorBuilder::new()
59129/// #         .with_native_roots()
59130/// #         .unwrap()
59131/// #         .https_or_http()
59132/// #         .enable_http1()
59133/// #         .build()
59134/// # );
59135/// # let mut hub = Dfareporting::new(client, auth);
59136/// // You can configure optional parameters by calling the respective setters at will, and
59137/// // execute the final call using `doit()`.
59138/// // Values shown here are possibly random and not representative !
59139/// let result = hub.placement_groups().list(-40)
59140///              .sort_order("sanctus")
59141///              .sort_field("sed")
59142///              .add_site_ids(-54)
59143///              .search_string("et")
59144///              .add_pricing_types("et")
59145///              .add_placement_strategy_ids(-81)
59146///              .placement_group_type("eos")
59147///              .page_token("nonumy")
59148///              .min_start_date("ea")
59149///              .min_end_date("aliquyam")
59150///              .max_start_date("nonumy")
59151///              .max_results(-15)
59152///              .max_end_date("rebum.")
59153///              .add_ids(-40)
59154///              .add_directory_site_ids(-69)
59155///              .add_content_category_ids(-82)
59156///              .add_campaign_ids(-8)
59157///              .archived(false)
59158///              .add_advertiser_ids(-4)
59159///              .doit().await;
59160/// # }
59161/// ```
59162pub struct PlacementGroupListCall<'a, C>
59163where
59164    C: 'a,
59165{
59166    hub: &'a Dfareporting<C>,
59167    _profile_id: i64,
59168    _sort_order: Option<String>,
59169    _sort_field: Option<String>,
59170    _site_ids: Vec<i64>,
59171    _search_string: Option<String>,
59172    _pricing_types: Vec<String>,
59173    _placement_strategy_ids: Vec<i64>,
59174    _placement_group_type: Option<String>,
59175    _page_token: Option<String>,
59176    _min_start_date: Option<String>,
59177    _min_end_date: Option<String>,
59178    _max_start_date: Option<String>,
59179    _max_results: Option<i32>,
59180    _max_end_date: Option<String>,
59181    _ids: Vec<i64>,
59182    _directory_site_ids: Vec<i64>,
59183    _content_category_ids: Vec<i64>,
59184    _campaign_ids: Vec<i64>,
59185    _archived: Option<bool>,
59186    _advertiser_ids: Vec<i64>,
59187    _delegate: Option<&'a mut dyn common::Delegate>,
59188    _additional_params: HashMap<String, String>,
59189    _scopes: BTreeSet<String>,
59190}
59191
59192impl<'a, C> common::CallBuilder for PlacementGroupListCall<'a, C> {}
59193
59194impl<'a, C> PlacementGroupListCall<'a, C>
59195where
59196    C: common::Connector,
59197{
59198    /// Perform the operation you have build so far.
59199    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementGroupsListResponse)> {
59200        use std::borrow::Cow;
59201        use std::io::{Read, Seek};
59202
59203        use common::{url::Params, ToParts};
59204        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
59205
59206        let mut dd = common::DefaultDelegate;
59207        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
59208        dlg.begin(common::MethodInfo {
59209            id: "dfareporting.placementGroups.list",
59210            http_method: hyper::Method::GET,
59211        });
59212
59213        for &field in [
59214            "alt",
59215            "profileId",
59216            "sortOrder",
59217            "sortField",
59218            "siteIds",
59219            "searchString",
59220            "pricingTypes",
59221            "placementStrategyIds",
59222            "placementGroupType",
59223            "pageToken",
59224            "minStartDate",
59225            "minEndDate",
59226            "maxStartDate",
59227            "maxResults",
59228            "maxEndDate",
59229            "ids",
59230            "directorySiteIds",
59231            "contentCategoryIds",
59232            "campaignIds",
59233            "archived",
59234            "advertiserIds",
59235        ]
59236        .iter()
59237        {
59238            if self._additional_params.contains_key(field) {
59239                dlg.finished(false);
59240                return Err(common::Error::FieldClash(field));
59241            }
59242        }
59243
59244        let mut params = Params::with_capacity(22 + self._additional_params.len());
59245        params.push("profileId", self._profile_id.to_string());
59246        if let Some(value) = self._sort_order.as_ref() {
59247            params.push("sortOrder", value);
59248        }
59249        if let Some(value) = self._sort_field.as_ref() {
59250            params.push("sortField", value);
59251        }
59252        if !self._site_ids.is_empty() {
59253            for f in self._site_ids.iter() {
59254                params.push("siteIds", f.to_string());
59255            }
59256        }
59257        if let Some(value) = self._search_string.as_ref() {
59258            params.push("searchString", value);
59259        }
59260        if !self._pricing_types.is_empty() {
59261            for f in self._pricing_types.iter() {
59262                params.push("pricingTypes", f);
59263            }
59264        }
59265        if !self._placement_strategy_ids.is_empty() {
59266            for f in self._placement_strategy_ids.iter() {
59267                params.push("placementStrategyIds", f.to_string());
59268            }
59269        }
59270        if let Some(value) = self._placement_group_type.as_ref() {
59271            params.push("placementGroupType", value);
59272        }
59273        if let Some(value) = self._page_token.as_ref() {
59274            params.push("pageToken", value);
59275        }
59276        if let Some(value) = self._min_start_date.as_ref() {
59277            params.push("minStartDate", value);
59278        }
59279        if let Some(value) = self._min_end_date.as_ref() {
59280            params.push("minEndDate", value);
59281        }
59282        if let Some(value) = self._max_start_date.as_ref() {
59283            params.push("maxStartDate", value);
59284        }
59285        if let Some(value) = self._max_results.as_ref() {
59286            params.push("maxResults", value.to_string());
59287        }
59288        if let Some(value) = self._max_end_date.as_ref() {
59289            params.push("maxEndDate", value);
59290        }
59291        if !self._ids.is_empty() {
59292            for f in self._ids.iter() {
59293                params.push("ids", f.to_string());
59294            }
59295        }
59296        if !self._directory_site_ids.is_empty() {
59297            for f in self._directory_site_ids.iter() {
59298                params.push("directorySiteIds", f.to_string());
59299            }
59300        }
59301        if !self._content_category_ids.is_empty() {
59302            for f in self._content_category_ids.iter() {
59303                params.push("contentCategoryIds", f.to_string());
59304            }
59305        }
59306        if !self._campaign_ids.is_empty() {
59307            for f in self._campaign_ids.iter() {
59308                params.push("campaignIds", f.to_string());
59309            }
59310        }
59311        if let Some(value) = self._archived.as_ref() {
59312            params.push("archived", value.to_string());
59313        }
59314        if !self._advertiser_ids.is_empty() {
59315            for f in self._advertiser_ids.iter() {
59316                params.push("advertiserIds", f.to_string());
59317            }
59318        }
59319
59320        params.extend(self._additional_params.iter());
59321
59322        params.push("alt", "json");
59323        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups";
59324        if self._scopes.is_empty() {
59325            self._scopes
59326                .insert(Scope::Dfatrafficking.as_ref().to_string());
59327        }
59328
59329        #[allow(clippy::single_element_loop)]
59330        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
59331            url = params.uri_replacement(url, param_name, find_this, false);
59332        }
59333        {
59334            let to_remove = ["profileId"];
59335            params.remove_params(&to_remove);
59336        }
59337
59338        let url = params.parse_with_url(&url);
59339
59340        loop {
59341            let token = match self
59342                .hub
59343                .auth
59344                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
59345                .await
59346            {
59347                Ok(token) => token,
59348                Err(e) => match dlg.token(e) {
59349                    Ok(token) => token,
59350                    Err(e) => {
59351                        dlg.finished(false);
59352                        return Err(common::Error::MissingToken(e));
59353                    }
59354                },
59355            };
59356            let mut req_result = {
59357                let client = &self.hub.client;
59358                dlg.pre_request();
59359                let mut req_builder = hyper::Request::builder()
59360                    .method(hyper::Method::GET)
59361                    .uri(url.as_str())
59362                    .header(USER_AGENT, self.hub._user_agent.clone());
59363
59364                if let Some(token) = token.as_ref() {
59365                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
59366                }
59367
59368                let request = req_builder
59369                    .header(CONTENT_LENGTH, 0_u64)
59370                    .body(common::to_body::<String>(None));
59371
59372                client.request(request.unwrap()).await
59373            };
59374
59375            match req_result {
59376                Err(err) => {
59377                    if let common::Retry::After(d) = dlg.http_error(&err) {
59378                        sleep(d).await;
59379                        continue;
59380                    }
59381                    dlg.finished(false);
59382                    return Err(common::Error::HttpError(err));
59383                }
59384                Ok(res) => {
59385                    let (mut parts, body) = res.into_parts();
59386                    let mut body = common::Body::new(body);
59387                    if !parts.status.is_success() {
59388                        let bytes = common::to_bytes(body).await.unwrap_or_default();
59389                        let error = serde_json::from_str(&common::to_string(&bytes));
59390                        let response = common::to_response(parts, bytes.into());
59391
59392                        if let common::Retry::After(d) =
59393                            dlg.http_failure(&response, error.as_ref().ok())
59394                        {
59395                            sleep(d).await;
59396                            continue;
59397                        }
59398
59399                        dlg.finished(false);
59400
59401                        return Err(match error {
59402                            Ok(value) => common::Error::BadRequest(value),
59403                            _ => common::Error::Failure(response),
59404                        });
59405                    }
59406                    let response = {
59407                        let bytes = common::to_bytes(body).await.unwrap_or_default();
59408                        let encoded = common::to_string(&bytes);
59409                        match serde_json::from_str(&encoded) {
59410                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
59411                            Err(error) => {
59412                                dlg.response_json_decode_error(&encoded, &error);
59413                                return Err(common::Error::JsonDecodeError(
59414                                    encoded.to_string(),
59415                                    error,
59416                                ));
59417                            }
59418                        }
59419                    };
59420
59421                    dlg.finished(true);
59422                    return Ok(response);
59423                }
59424            }
59425        }
59426    }
59427
59428    /// User profile ID associated with this request.
59429    ///
59430    /// Sets the *profile id* path property to the given value.
59431    ///
59432    /// Even though the property as already been set when instantiating this call,
59433    /// we provide this method for API completeness.
59434    pub fn profile_id(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59435        self._profile_id = new_value;
59436        self
59437    }
59438    /// Order of sorted results.
59439    ///
59440    /// Sets the *sort order* query property to the given value.
59441    pub fn sort_order(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59442        self._sort_order = Some(new_value.to_string());
59443        self
59444    }
59445    /// Field by which to sort the list.
59446    ///
59447    /// Sets the *sort field* query property to the given value.
59448    pub fn sort_field(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59449        self._sort_field = Some(new_value.to_string());
59450        self
59451    }
59452    /// Select only placement groups that are associated with these sites.
59453    ///
59454    /// Append the given value to the *site ids* query property.
59455    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59456    pub fn add_site_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59457        self._site_ids.push(new_value);
59458        self
59459    }
59460    /// Allows searching for placement groups by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placement groups with names like "placement group June 2015", "placement group May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementgroup" will match placement groups with name "my placementgroup", "placementgroup 2015", or simply "placementgroup".
59461    ///
59462    /// Sets the *search string* query property to the given value.
59463    pub fn search_string(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59464        self._search_string = Some(new_value.to_string());
59465        self
59466    }
59467    /// Select only placement groups with these pricing types.
59468    ///
59469    /// Append the given value to the *pricing types* query property.
59470    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59471    pub fn add_pricing_types(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59472        self._pricing_types.push(new_value.to_string());
59473        self
59474    }
59475    /// Select only placement groups that are associated with these placement strategies.
59476    ///
59477    /// Append the given value to the *placement strategy ids* query property.
59478    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59479    pub fn add_placement_strategy_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59480        self._placement_strategy_ids.push(new_value);
59481        self
59482    }
59483    /// Select only placement groups belonging with this group type. A package is a simple group of placements that acts as a single pricing point for a group of tags. A roadblock is a group of placements that not only acts as a single pricing point but also assumes that all the tags in it will be served at the same time. A roadblock requires one of its assigned placements to be marked as primary for reporting.
59484    ///
59485    /// Sets the *placement group type* query property to the given value.
59486    pub fn placement_group_type(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59487        self._placement_group_type = Some(new_value.to_string());
59488        self
59489    }
59490    /// Value of the nextPageToken from the previous result page.
59491    ///
59492    /// Sets the *page token* query property to the given value.
59493    pub fn page_token(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59494        self._page_token = Some(new_value.to_string());
59495        self
59496    }
59497    /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd".
59498    ///
59499    /// Sets the *min start date* query property to the given value.
59500    pub fn min_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59501        self._min_start_date = Some(new_value.to_string());
59502        self
59503    }
59504    /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd".
59505    ///
59506    /// Sets the *min end date* query property to the given value.
59507    pub fn min_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59508        self._min_end_date = Some(new_value.to_string());
59509        self
59510    }
59511    /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd".
59512    ///
59513    /// Sets the *max start date* query property to the given value.
59514    pub fn max_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59515        self._max_start_date = Some(new_value.to_string());
59516        self
59517    }
59518    /// Maximum number of results to return.
59519    ///
59520    /// Sets the *max results* query property to the given value.
59521    pub fn max_results(mut self, new_value: i32) -> PlacementGroupListCall<'a, C> {
59522        self._max_results = Some(new_value);
59523        self
59524    }
59525    /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd".
59526    ///
59527    /// Sets the *max end date* query property to the given value.
59528    pub fn max_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, C> {
59529        self._max_end_date = Some(new_value.to_string());
59530        self
59531    }
59532    /// Select only placement groups with these IDs.
59533    ///
59534    /// Append the given value to the *ids* query property.
59535    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59536    pub fn add_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59537        self._ids.push(new_value);
59538        self
59539    }
59540    /// Select only placement groups that are associated with these directory sites.
59541    ///
59542    /// Append the given value to the *directory site ids* query property.
59543    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59544    pub fn add_directory_site_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59545        self._directory_site_ids.push(new_value);
59546        self
59547    }
59548    /// Select only placement groups that are associated with these content categories.
59549    ///
59550    /// Append the given value to the *content category ids* query property.
59551    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59552    pub fn add_content_category_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59553        self._content_category_ids.push(new_value);
59554        self
59555    }
59556    /// Select only placement groups that belong to these campaigns.
59557    ///
59558    /// Append the given value to the *campaign ids* query property.
59559    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59560    pub fn add_campaign_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59561        self._campaign_ids.push(new_value);
59562        self
59563    }
59564    /// Select only archived placements. Don't set this field to select both archived and non-archived placements.
59565    ///
59566    /// Sets the *archived* query property to the given value.
59567    pub fn archived(mut self, new_value: bool) -> PlacementGroupListCall<'a, C> {
59568        self._archived = Some(new_value);
59569        self
59570    }
59571    /// Select only placement groups that belong to these advertisers.
59572    ///
59573    /// Append the given value to the *advertiser ids* query property.
59574    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
59575    pub fn add_advertiser_ids(mut self, new_value: i64) -> PlacementGroupListCall<'a, C> {
59576        self._advertiser_ids.push(new_value);
59577        self
59578    }
59579    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
59580    /// while executing the actual API request.
59581    ///
59582    /// ````text
59583    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
59584    /// ````
59585    ///
59586    /// Sets the *delegate* property to the given value.
59587    pub fn delegate(
59588        mut self,
59589        new_value: &'a mut dyn common::Delegate,
59590    ) -> PlacementGroupListCall<'a, C> {
59591        self._delegate = Some(new_value);
59592        self
59593    }
59594
59595    /// Set any additional parameter of the query string used in the request.
59596    /// It should be used to set parameters which are not yet available through their own
59597    /// setters.
59598    ///
59599    /// Please note that this method must not be used to set any of the known parameters
59600    /// which have their own setter method. If done anyway, the request will fail.
59601    ///
59602    /// # Additional Parameters
59603    ///
59604    /// * *alt* (query-string) - Data format for the response.
59605    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
59606    /// * *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.
59607    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
59608    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
59609    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
59610    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
59611    pub fn param<T>(mut self, name: T, value: T) -> PlacementGroupListCall<'a, C>
59612    where
59613        T: AsRef<str>,
59614    {
59615        self._additional_params
59616            .insert(name.as_ref().to_string(), value.as_ref().to_string());
59617        self
59618    }
59619
59620    /// Identifies the authorization scope for the method you are building.
59621    ///
59622    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
59623    /// [`Scope::Dfatrafficking`].
59624    ///
59625    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
59626    /// tokens for more than one scope.
59627    ///
59628    /// Usually there is more than one suitable scope to authorize an operation, some of which may
59629    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
59630    /// sufficient, a read-write scope will do as well.
59631    pub fn add_scope<St>(mut self, scope: St) -> PlacementGroupListCall<'a, C>
59632    where
59633        St: AsRef<str>,
59634    {
59635        self._scopes.insert(String::from(scope.as_ref()));
59636        self
59637    }
59638    /// Identifies the authorization scope(s) for the method you are building.
59639    ///
59640    /// See [`Self::add_scope()`] for details.
59641    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGroupListCall<'a, C>
59642    where
59643        I: IntoIterator<Item = St>,
59644        St: AsRef<str>,
59645    {
59646        self._scopes
59647            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
59648        self
59649    }
59650
59651    /// Removes all scopes, and no default scope will be used either.
59652    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
59653    /// for details).
59654    pub fn clear_scopes(mut self) -> PlacementGroupListCall<'a, C> {
59655        self._scopes.clear();
59656        self
59657    }
59658}
59659
59660/// Updates an existing placement group. This method supports patch semantics.
59661///
59662/// A builder for the *patch* method supported by a *placementGroup* resource.
59663/// It is not used directly, but through a [`PlacementGroupMethods`] instance.
59664///
59665/// # Example
59666///
59667/// Instantiate a resource method builder
59668///
59669/// ```test_harness,no_run
59670/// # extern crate hyper;
59671/// # extern crate hyper_rustls;
59672/// # extern crate google_dfareporting3d2 as dfareporting3d2;
59673/// use dfareporting3d2::api::PlacementGroup;
59674/// # async fn dox() {
59675/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
59676///
59677/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
59678/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
59679/// #     secret,
59680/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
59681/// # ).build().await.unwrap();
59682///
59683/// # let client = hyper_util::client::legacy::Client::builder(
59684/// #     hyper_util::rt::TokioExecutor::new()
59685/// # )
59686/// # .build(
59687/// #     hyper_rustls::HttpsConnectorBuilder::new()
59688/// #         .with_native_roots()
59689/// #         .unwrap()
59690/// #         .https_or_http()
59691/// #         .enable_http1()
59692/// #         .build()
59693/// # );
59694/// # let mut hub = Dfareporting::new(client, auth);
59695/// // As the method needs a request, you would usually fill it with the desired information
59696/// // into the respective structure. Some of the parts shown here might not be applicable !
59697/// // Values shown here are possibly random and not representative !
59698/// let mut req = PlacementGroup::default();
59699///
59700/// // You can configure optional parameters by calling the respective setters at will, and
59701/// // execute the final call using `doit()`.
59702/// // Values shown here are possibly random and not representative !
59703/// let result = hub.placement_groups().patch(req, -75, -83)
59704///              .doit().await;
59705/// # }
59706/// ```
59707pub struct PlacementGroupPatchCall<'a, C>
59708where
59709    C: 'a,
59710{
59711    hub: &'a Dfareporting<C>,
59712    _request: PlacementGroup,
59713    _profile_id: i64,
59714    _id: i64,
59715    _delegate: Option<&'a mut dyn common::Delegate>,
59716    _additional_params: HashMap<String, String>,
59717    _scopes: BTreeSet<String>,
59718}
59719
59720impl<'a, C> common::CallBuilder for PlacementGroupPatchCall<'a, C> {}
59721
59722impl<'a, C> PlacementGroupPatchCall<'a, C>
59723where
59724    C: common::Connector,
59725{
59726    /// Perform the operation you have build so far.
59727    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementGroup)> {
59728        use std::borrow::Cow;
59729        use std::io::{Read, Seek};
59730
59731        use common::{url::Params, ToParts};
59732        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
59733
59734        let mut dd = common::DefaultDelegate;
59735        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
59736        dlg.begin(common::MethodInfo {
59737            id: "dfareporting.placementGroups.patch",
59738            http_method: hyper::Method::PATCH,
59739        });
59740
59741        for &field in ["alt", "profileId", "id"].iter() {
59742            if self._additional_params.contains_key(field) {
59743                dlg.finished(false);
59744                return Err(common::Error::FieldClash(field));
59745            }
59746        }
59747
59748        let mut params = Params::with_capacity(5 + self._additional_params.len());
59749        params.push("profileId", self._profile_id.to_string());
59750        params.push("id", self._id.to_string());
59751
59752        params.extend(self._additional_params.iter());
59753
59754        params.push("alt", "json");
59755        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups";
59756        if self._scopes.is_empty() {
59757            self._scopes
59758                .insert(Scope::Dfatrafficking.as_ref().to_string());
59759        }
59760
59761        #[allow(clippy::single_element_loop)]
59762        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
59763            url = params.uri_replacement(url, param_name, find_this, false);
59764        }
59765        {
59766            let to_remove = ["profileId"];
59767            params.remove_params(&to_remove);
59768        }
59769
59770        let url = params.parse_with_url(&url);
59771
59772        let mut json_mime_type = mime::APPLICATION_JSON;
59773        let mut request_value_reader = {
59774            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
59775            common::remove_json_null_values(&mut value);
59776            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
59777            serde_json::to_writer(&mut dst, &value).unwrap();
59778            dst
59779        };
59780        let request_size = request_value_reader
59781            .seek(std::io::SeekFrom::End(0))
59782            .unwrap();
59783        request_value_reader
59784            .seek(std::io::SeekFrom::Start(0))
59785            .unwrap();
59786
59787        loop {
59788            let token = match self
59789                .hub
59790                .auth
59791                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
59792                .await
59793            {
59794                Ok(token) => token,
59795                Err(e) => match dlg.token(e) {
59796                    Ok(token) => token,
59797                    Err(e) => {
59798                        dlg.finished(false);
59799                        return Err(common::Error::MissingToken(e));
59800                    }
59801                },
59802            };
59803            request_value_reader
59804                .seek(std::io::SeekFrom::Start(0))
59805                .unwrap();
59806            let mut req_result = {
59807                let client = &self.hub.client;
59808                dlg.pre_request();
59809                let mut req_builder = hyper::Request::builder()
59810                    .method(hyper::Method::PATCH)
59811                    .uri(url.as_str())
59812                    .header(USER_AGENT, self.hub._user_agent.clone());
59813
59814                if let Some(token) = token.as_ref() {
59815                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
59816                }
59817
59818                let request = req_builder
59819                    .header(CONTENT_TYPE, json_mime_type.to_string())
59820                    .header(CONTENT_LENGTH, request_size as u64)
59821                    .body(common::to_body(
59822                        request_value_reader.get_ref().clone().into(),
59823                    ));
59824
59825                client.request(request.unwrap()).await
59826            };
59827
59828            match req_result {
59829                Err(err) => {
59830                    if let common::Retry::After(d) = dlg.http_error(&err) {
59831                        sleep(d).await;
59832                        continue;
59833                    }
59834                    dlg.finished(false);
59835                    return Err(common::Error::HttpError(err));
59836                }
59837                Ok(res) => {
59838                    let (mut parts, body) = res.into_parts();
59839                    let mut body = common::Body::new(body);
59840                    if !parts.status.is_success() {
59841                        let bytes = common::to_bytes(body).await.unwrap_or_default();
59842                        let error = serde_json::from_str(&common::to_string(&bytes));
59843                        let response = common::to_response(parts, bytes.into());
59844
59845                        if let common::Retry::After(d) =
59846                            dlg.http_failure(&response, error.as_ref().ok())
59847                        {
59848                            sleep(d).await;
59849                            continue;
59850                        }
59851
59852                        dlg.finished(false);
59853
59854                        return Err(match error {
59855                            Ok(value) => common::Error::BadRequest(value),
59856                            _ => common::Error::Failure(response),
59857                        });
59858                    }
59859                    let response = {
59860                        let bytes = common::to_bytes(body).await.unwrap_or_default();
59861                        let encoded = common::to_string(&bytes);
59862                        match serde_json::from_str(&encoded) {
59863                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
59864                            Err(error) => {
59865                                dlg.response_json_decode_error(&encoded, &error);
59866                                return Err(common::Error::JsonDecodeError(
59867                                    encoded.to_string(),
59868                                    error,
59869                                ));
59870                            }
59871                        }
59872                    };
59873
59874                    dlg.finished(true);
59875                    return Ok(response);
59876                }
59877            }
59878        }
59879    }
59880
59881    ///
59882    /// Sets the *request* property to the given value.
59883    ///
59884    /// Even though the property as already been set when instantiating this call,
59885    /// we provide this method for API completeness.
59886    pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupPatchCall<'a, C> {
59887        self._request = new_value;
59888        self
59889    }
59890    /// User profile ID associated with this request.
59891    ///
59892    /// Sets the *profile id* path property to the given value.
59893    ///
59894    /// Even though the property as already been set when instantiating this call,
59895    /// we provide this method for API completeness.
59896    pub fn profile_id(mut self, new_value: i64) -> PlacementGroupPatchCall<'a, C> {
59897        self._profile_id = new_value;
59898        self
59899    }
59900    /// Placement group ID.
59901    ///
59902    /// Sets the *id* query property to the given value.
59903    ///
59904    /// Even though the property as already been set when instantiating this call,
59905    /// we provide this method for API completeness.
59906    pub fn id(mut self, new_value: i64) -> PlacementGroupPatchCall<'a, C> {
59907        self._id = new_value;
59908        self
59909    }
59910    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
59911    /// while executing the actual API request.
59912    ///
59913    /// ````text
59914    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
59915    /// ````
59916    ///
59917    /// Sets the *delegate* property to the given value.
59918    pub fn delegate(
59919        mut self,
59920        new_value: &'a mut dyn common::Delegate,
59921    ) -> PlacementGroupPatchCall<'a, C> {
59922        self._delegate = Some(new_value);
59923        self
59924    }
59925
59926    /// Set any additional parameter of the query string used in the request.
59927    /// It should be used to set parameters which are not yet available through their own
59928    /// setters.
59929    ///
59930    /// Please note that this method must not be used to set any of the known parameters
59931    /// which have their own setter method. If done anyway, the request will fail.
59932    ///
59933    /// # Additional Parameters
59934    ///
59935    /// * *alt* (query-string) - Data format for the response.
59936    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
59937    /// * *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.
59938    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
59939    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
59940    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
59941    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
59942    pub fn param<T>(mut self, name: T, value: T) -> PlacementGroupPatchCall<'a, C>
59943    where
59944        T: AsRef<str>,
59945    {
59946        self._additional_params
59947            .insert(name.as_ref().to_string(), value.as_ref().to_string());
59948        self
59949    }
59950
59951    /// Identifies the authorization scope for the method you are building.
59952    ///
59953    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
59954    /// [`Scope::Dfatrafficking`].
59955    ///
59956    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
59957    /// tokens for more than one scope.
59958    ///
59959    /// Usually there is more than one suitable scope to authorize an operation, some of which may
59960    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
59961    /// sufficient, a read-write scope will do as well.
59962    pub fn add_scope<St>(mut self, scope: St) -> PlacementGroupPatchCall<'a, C>
59963    where
59964        St: AsRef<str>,
59965    {
59966        self._scopes.insert(String::from(scope.as_ref()));
59967        self
59968    }
59969    /// Identifies the authorization scope(s) for the method you are building.
59970    ///
59971    /// See [`Self::add_scope()`] for details.
59972    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGroupPatchCall<'a, C>
59973    where
59974        I: IntoIterator<Item = St>,
59975        St: AsRef<str>,
59976    {
59977        self._scopes
59978            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
59979        self
59980    }
59981
59982    /// Removes all scopes, and no default scope will be used either.
59983    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
59984    /// for details).
59985    pub fn clear_scopes(mut self) -> PlacementGroupPatchCall<'a, C> {
59986        self._scopes.clear();
59987        self
59988    }
59989}
59990
59991/// Updates an existing placement group.
59992///
59993/// A builder for the *update* method supported by a *placementGroup* resource.
59994/// It is not used directly, but through a [`PlacementGroupMethods`] instance.
59995///
59996/// # Example
59997///
59998/// Instantiate a resource method builder
59999///
60000/// ```test_harness,no_run
60001/// # extern crate hyper;
60002/// # extern crate hyper_rustls;
60003/// # extern crate google_dfareporting3d2 as dfareporting3d2;
60004/// use dfareporting3d2::api::PlacementGroup;
60005/// # async fn dox() {
60006/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60007///
60008/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
60009/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
60010/// #     secret,
60011/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
60012/// # ).build().await.unwrap();
60013///
60014/// # let client = hyper_util::client::legacy::Client::builder(
60015/// #     hyper_util::rt::TokioExecutor::new()
60016/// # )
60017/// # .build(
60018/// #     hyper_rustls::HttpsConnectorBuilder::new()
60019/// #         .with_native_roots()
60020/// #         .unwrap()
60021/// #         .https_or_http()
60022/// #         .enable_http1()
60023/// #         .build()
60024/// # );
60025/// # let mut hub = Dfareporting::new(client, auth);
60026/// // As the method needs a request, you would usually fill it with the desired information
60027/// // into the respective structure. Some of the parts shown here might not be applicable !
60028/// // Values shown here are possibly random and not representative !
60029/// let mut req = PlacementGroup::default();
60030///
60031/// // You can configure optional parameters by calling the respective setters at will, and
60032/// // execute the final call using `doit()`.
60033/// // Values shown here are possibly random and not representative !
60034/// let result = hub.placement_groups().update(req, -11)
60035///              .doit().await;
60036/// # }
60037/// ```
60038pub struct PlacementGroupUpdateCall<'a, C>
60039where
60040    C: 'a,
60041{
60042    hub: &'a Dfareporting<C>,
60043    _request: PlacementGroup,
60044    _profile_id: i64,
60045    _delegate: Option<&'a mut dyn common::Delegate>,
60046    _additional_params: HashMap<String, String>,
60047    _scopes: BTreeSet<String>,
60048}
60049
60050impl<'a, C> common::CallBuilder for PlacementGroupUpdateCall<'a, C> {}
60051
60052impl<'a, C> PlacementGroupUpdateCall<'a, C>
60053where
60054    C: common::Connector,
60055{
60056    /// Perform the operation you have build so far.
60057    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementGroup)> {
60058        use std::borrow::Cow;
60059        use std::io::{Read, Seek};
60060
60061        use common::{url::Params, ToParts};
60062        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
60063
60064        let mut dd = common::DefaultDelegate;
60065        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
60066        dlg.begin(common::MethodInfo {
60067            id: "dfareporting.placementGroups.update",
60068            http_method: hyper::Method::PUT,
60069        });
60070
60071        for &field in ["alt", "profileId"].iter() {
60072            if self._additional_params.contains_key(field) {
60073                dlg.finished(false);
60074                return Err(common::Error::FieldClash(field));
60075            }
60076        }
60077
60078        let mut params = Params::with_capacity(4 + self._additional_params.len());
60079        params.push("profileId", self._profile_id.to_string());
60080
60081        params.extend(self._additional_params.iter());
60082
60083        params.push("alt", "json");
60084        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups";
60085        if self._scopes.is_empty() {
60086            self._scopes
60087                .insert(Scope::Dfatrafficking.as_ref().to_string());
60088        }
60089
60090        #[allow(clippy::single_element_loop)]
60091        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
60092            url = params.uri_replacement(url, param_name, find_this, false);
60093        }
60094        {
60095            let to_remove = ["profileId"];
60096            params.remove_params(&to_remove);
60097        }
60098
60099        let url = params.parse_with_url(&url);
60100
60101        let mut json_mime_type = mime::APPLICATION_JSON;
60102        let mut request_value_reader = {
60103            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
60104            common::remove_json_null_values(&mut value);
60105            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
60106            serde_json::to_writer(&mut dst, &value).unwrap();
60107            dst
60108        };
60109        let request_size = request_value_reader
60110            .seek(std::io::SeekFrom::End(0))
60111            .unwrap();
60112        request_value_reader
60113            .seek(std::io::SeekFrom::Start(0))
60114            .unwrap();
60115
60116        loop {
60117            let token = match self
60118                .hub
60119                .auth
60120                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
60121                .await
60122            {
60123                Ok(token) => token,
60124                Err(e) => match dlg.token(e) {
60125                    Ok(token) => token,
60126                    Err(e) => {
60127                        dlg.finished(false);
60128                        return Err(common::Error::MissingToken(e));
60129                    }
60130                },
60131            };
60132            request_value_reader
60133                .seek(std::io::SeekFrom::Start(0))
60134                .unwrap();
60135            let mut req_result = {
60136                let client = &self.hub.client;
60137                dlg.pre_request();
60138                let mut req_builder = hyper::Request::builder()
60139                    .method(hyper::Method::PUT)
60140                    .uri(url.as_str())
60141                    .header(USER_AGENT, self.hub._user_agent.clone());
60142
60143                if let Some(token) = token.as_ref() {
60144                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
60145                }
60146
60147                let request = req_builder
60148                    .header(CONTENT_TYPE, json_mime_type.to_string())
60149                    .header(CONTENT_LENGTH, request_size as u64)
60150                    .body(common::to_body(
60151                        request_value_reader.get_ref().clone().into(),
60152                    ));
60153
60154                client.request(request.unwrap()).await
60155            };
60156
60157            match req_result {
60158                Err(err) => {
60159                    if let common::Retry::After(d) = dlg.http_error(&err) {
60160                        sleep(d).await;
60161                        continue;
60162                    }
60163                    dlg.finished(false);
60164                    return Err(common::Error::HttpError(err));
60165                }
60166                Ok(res) => {
60167                    let (mut parts, body) = res.into_parts();
60168                    let mut body = common::Body::new(body);
60169                    if !parts.status.is_success() {
60170                        let bytes = common::to_bytes(body).await.unwrap_or_default();
60171                        let error = serde_json::from_str(&common::to_string(&bytes));
60172                        let response = common::to_response(parts, bytes.into());
60173
60174                        if let common::Retry::After(d) =
60175                            dlg.http_failure(&response, error.as_ref().ok())
60176                        {
60177                            sleep(d).await;
60178                            continue;
60179                        }
60180
60181                        dlg.finished(false);
60182
60183                        return Err(match error {
60184                            Ok(value) => common::Error::BadRequest(value),
60185                            _ => common::Error::Failure(response),
60186                        });
60187                    }
60188                    let response = {
60189                        let bytes = common::to_bytes(body).await.unwrap_or_default();
60190                        let encoded = common::to_string(&bytes);
60191                        match serde_json::from_str(&encoded) {
60192                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
60193                            Err(error) => {
60194                                dlg.response_json_decode_error(&encoded, &error);
60195                                return Err(common::Error::JsonDecodeError(
60196                                    encoded.to_string(),
60197                                    error,
60198                                ));
60199                            }
60200                        }
60201                    };
60202
60203                    dlg.finished(true);
60204                    return Ok(response);
60205                }
60206            }
60207        }
60208    }
60209
60210    ///
60211    /// Sets the *request* property to the given value.
60212    ///
60213    /// Even though the property as already been set when instantiating this call,
60214    /// we provide this method for API completeness.
60215    pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupUpdateCall<'a, C> {
60216        self._request = new_value;
60217        self
60218    }
60219    /// User profile ID associated with this request.
60220    ///
60221    /// Sets the *profile id* path property to the given value.
60222    ///
60223    /// Even though the property as already been set when instantiating this call,
60224    /// we provide this method for API completeness.
60225    pub fn profile_id(mut self, new_value: i64) -> PlacementGroupUpdateCall<'a, C> {
60226        self._profile_id = new_value;
60227        self
60228    }
60229    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
60230    /// while executing the actual API request.
60231    ///
60232    /// ````text
60233    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
60234    /// ````
60235    ///
60236    /// Sets the *delegate* property to the given value.
60237    pub fn delegate(
60238        mut self,
60239        new_value: &'a mut dyn common::Delegate,
60240    ) -> PlacementGroupUpdateCall<'a, C> {
60241        self._delegate = Some(new_value);
60242        self
60243    }
60244
60245    /// Set any additional parameter of the query string used in the request.
60246    /// It should be used to set parameters which are not yet available through their own
60247    /// setters.
60248    ///
60249    /// Please note that this method must not be used to set any of the known parameters
60250    /// which have their own setter method. If done anyway, the request will fail.
60251    ///
60252    /// # Additional Parameters
60253    ///
60254    /// * *alt* (query-string) - Data format for the response.
60255    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
60256    /// * *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.
60257    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
60258    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
60259    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
60260    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
60261    pub fn param<T>(mut self, name: T, value: T) -> PlacementGroupUpdateCall<'a, C>
60262    where
60263        T: AsRef<str>,
60264    {
60265        self._additional_params
60266            .insert(name.as_ref().to_string(), value.as_ref().to_string());
60267        self
60268    }
60269
60270    /// Identifies the authorization scope for the method you are building.
60271    ///
60272    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
60273    /// [`Scope::Dfatrafficking`].
60274    ///
60275    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
60276    /// tokens for more than one scope.
60277    ///
60278    /// Usually there is more than one suitable scope to authorize an operation, some of which may
60279    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
60280    /// sufficient, a read-write scope will do as well.
60281    pub fn add_scope<St>(mut self, scope: St) -> PlacementGroupUpdateCall<'a, C>
60282    where
60283        St: AsRef<str>,
60284    {
60285        self._scopes.insert(String::from(scope.as_ref()));
60286        self
60287    }
60288    /// Identifies the authorization scope(s) for the method you are building.
60289    ///
60290    /// See [`Self::add_scope()`] for details.
60291    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGroupUpdateCall<'a, C>
60292    where
60293        I: IntoIterator<Item = St>,
60294        St: AsRef<str>,
60295    {
60296        self._scopes
60297            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
60298        self
60299    }
60300
60301    /// Removes all scopes, and no default scope will be used either.
60302    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
60303    /// for details).
60304    pub fn clear_scopes(mut self) -> PlacementGroupUpdateCall<'a, C> {
60305        self._scopes.clear();
60306        self
60307    }
60308}
60309
60310/// Deletes an existing placement strategy.
60311///
60312/// A builder for the *delete* method supported by a *placementStrategy* resource.
60313/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
60314///
60315/// # Example
60316///
60317/// Instantiate a resource method builder
60318///
60319/// ```test_harness,no_run
60320/// # extern crate hyper;
60321/// # extern crate hyper_rustls;
60322/// # extern crate google_dfareporting3d2 as dfareporting3d2;
60323/// # async fn dox() {
60324/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60325///
60326/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
60327/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
60328/// #     secret,
60329/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
60330/// # ).build().await.unwrap();
60331///
60332/// # let client = hyper_util::client::legacy::Client::builder(
60333/// #     hyper_util::rt::TokioExecutor::new()
60334/// # )
60335/// # .build(
60336/// #     hyper_rustls::HttpsConnectorBuilder::new()
60337/// #         .with_native_roots()
60338/// #         .unwrap()
60339/// #         .https_or_http()
60340/// #         .enable_http1()
60341/// #         .build()
60342/// # );
60343/// # let mut hub = Dfareporting::new(client, auth);
60344/// // You can configure optional parameters by calling the respective setters at will, and
60345/// // execute the final call using `doit()`.
60346/// // Values shown here are possibly random and not representative !
60347/// let result = hub.placement_strategies().delete(-12, -81)
60348///              .doit().await;
60349/// # }
60350/// ```
60351pub struct PlacementStrategyDeleteCall<'a, C>
60352where
60353    C: 'a,
60354{
60355    hub: &'a Dfareporting<C>,
60356    _profile_id: i64,
60357    _id: i64,
60358    _delegate: Option<&'a mut dyn common::Delegate>,
60359    _additional_params: HashMap<String, String>,
60360    _scopes: BTreeSet<String>,
60361}
60362
60363impl<'a, C> common::CallBuilder for PlacementStrategyDeleteCall<'a, C> {}
60364
60365impl<'a, C> PlacementStrategyDeleteCall<'a, C>
60366where
60367    C: common::Connector,
60368{
60369    /// Perform the operation you have build so far.
60370    pub async fn doit(mut self) -> common::Result<common::Response> {
60371        use std::borrow::Cow;
60372        use std::io::{Read, Seek};
60373
60374        use common::{url::Params, ToParts};
60375        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
60376
60377        let mut dd = common::DefaultDelegate;
60378        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
60379        dlg.begin(common::MethodInfo {
60380            id: "dfareporting.placementStrategies.delete",
60381            http_method: hyper::Method::DELETE,
60382        });
60383
60384        for &field in ["profileId", "id"].iter() {
60385            if self._additional_params.contains_key(field) {
60386                dlg.finished(false);
60387                return Err(common::Error::FieldClash(field));
60388            }
60389        }
60390
60391        let mut params = Params::with_capacity(3 + self._additional_params.len());
60392        params.push("profileId", self._profile_id.to_string());
60393        params.push("id", self._id.to_string());
60394
60395        params.extend(self._additional_params.iter());
60396
60397        let mut url =
60398            self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies/{id}";
60399        if self._scopes.is_empty() {
60400            self._scopes
60401                .insert(Scope::Dfatrafficking.as_ref().to_string());
60402        }
60403
60404        #[allow(clippy::single_element_loop)]
60405        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
60406            url = params.uri_replacement(url, param_name, find_this, false);
60407        }
60408        {
60409            let to_remove = ["id", "profileId"];
60410            params.remove_params(&to_remove);
60411        }
60412
60413        let url = params.parse_with_url(&url);
60414
60415        loop {
60416            let token = match self
60417                .hub
60418                .auth
60419                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
60420                .await
60421            {
60422                Ok(token) => token,
60423                Err(e) => match dlg.token(e) {
60424                    Ok(token) => token,
60425                    Err(e) => {
60426                        dlg.finished(false);
60427                        return Err(common::Error::MissingToken(e));
60428                    }
60429                },
60430            };
60431            let mut req_result = {
60432                let client = &self.hub.client;
60433                dlg.pre_request();
60434                let mut req_builder = hyper::Request::builder()
60435                    .method(hyper::Method::DELETE)
60436                    .uri(url.as_str())
60437                    .header(USER_AGENT, self.hub._user_agent.clone());
60438
60439                if let Some(token) = token.as_ref() {
60440                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
60441                }
60442
60443                let request = req_builder
60444                    .header(CONTENT_LENGTH, 0_u64)
60445                    .body(common::to_body::<String>(None));
60446
60447                client.request(request.unwrap()).await
60448            };
60449
60450            match req_result {
60451                Err(err) => {
60452                    if let common::Retry::After(d) = dlg.http_error(&err) {
60453                        sleep(d).await;
60454                        continue;
60455                    }
60456                    dlg.finished(false);
60457                    return Err(common::Error::HttpError(err));
60458                }
60459                Ok(res) => {
60460                    let (mut parts, body) = res.into_parts();
60461                    let mut body = common::Body::new(body);
60462                    if !parts.status.is_success() {
60463                        let bytes = common::to_bytes(body).await.unwrap_or_default();
60464                        let error = serde_json::from_str(&common::to_string(&bytes));
60465                        let response = common::to_response(parts, bytes.into());
60466
60467                        if let common::Retry::After(d) =
60468                            dlg.http_failure(&response, error.as_ref().ok())
60469                        {
60470                            sleep(d).await;
60471                            continue;
60472                        }
60473
60474                        dlg.finished(false);
60475
60476                        return Err(match error {
60477                            Ok(value) => common::Error::BadRequest(value),
60478                            _ => common::Error::Failure(response),
60479                        });
60480                    }
60481                    let response = common::Response::from_parts(parts, body);
60482
60483                    dlg.finished(true);
60484                    return Ok(response);
60485                }
60486            }
60487        }
60488    }
60489
60490    /// User profile ID associated with this request.
60491    ///
60492    /// Sets the *profile id* path property to the given value.
60493    ///
60494    /// Even though the property as already been set when instantiating this call,
60495    /// we provide this method for API completeness.
60496    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyDeleteCall<'a, C> {
60497        self._profile_id = new_value;
60498        self
60499    }
60500    /// Placement strategy ID.
60501    ///
60502    /// Sets the *id* path property to the given value.
60503    ///
60504    /// Even though the property as already been set when instantiating this call,
60505    /// we provide this method for API completeness.
60506    pub fn id(mut self, new_value: i64) -> PlacementStrategyDeleteCall<'a, C> {
60507        self._id = new_value;
60508        self
60509    }
60510    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
60511    /// while executing the actual API request.
60512    ///
60513    /// ````text
60514    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
60515    /// ````
60516    ///
60517    /// Sets the *delegate* property to the given value.
60518    pub fn delegate(
60519        mut self,
60520        new_value: &'a mut dyn common::Delegate,
60521    ) -> PlacementStrategyDeleteCall<'a, C> {
60522        self._delegate = Some(new_value);
60523        self
60524    }
60525
60526    /// Set any additional parameter of the query string used in the request.
60527    /// It should be used to set parameters which are not yet available through their own
60528    /// setters.
60529    ///
60530    /// Please note that this method must not be used to set any of the known parameters
60531    /// which have their own setter method. If done anyway, the request will fail.
60532    ///
60533    /// # Additional Parameters
60534    ///
60535    /// * *alt* (query-string) - Data format for the response.
60536    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
60537    /// * *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.
60538    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
60539    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
60540    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
60541    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
60542    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyDeleteCall<'a, C>
60543    where
60544        T: AsRef<str>,
60545    {
60546        self._additional_params
60547            .insert(name.as_ref().to_string(), value.as_ref().to_string());
60548        self
60549    }
60550
60551    /// Identifies the authorization scope for the method you are building.
60552    ///
60553    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
60554    /// [`Scope::Dfatrafficking`].
60555    ///
60556    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
60557    /// tokens for more than one scope.
60558    ///
60559    /// Usually there is more than one suitable scope to authorize an operation, some of which may
60560    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
60561    /// sufficient, a read-write scope will do as well.
60562    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyDeleteCall<'a, C>
60563    where
60564        St: AsRef<str>,
60565    {
60566        self._scopes.insert(String::from(scope.as_ref()));
60567        self
60568    }
60569    /// Identifies the authorization scope(s) for the method you are building.
60570    ///
60571    /// See [`Self::add_scope()`] for details.
60572    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyDeleteCall<'a, C>
60573    where
60574        I: IntoIterator<Item = St>,
60575        St: AsRef<str>,
60576    {
60577        self._scopes
60578            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
60579        self
60580    }
60581
60582    /// Removes all scopes, and no default scope will be used either.
60583    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
60584    /// for details).
60585    pub fn clear_scopes(mut self) -> PlacementStrategyDeleteCall<'a, C> {
60586        self._scopes.clear();
60587        self
60588    }
60589}
60590
60591/// Gets one placement strategy by ID.
60592///
60593/// A builder for the *get* method supported by a *placementStrategy* resource.
60594/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
60595///
60596/// # Example
60597///
60598/// Instantiate a resource method builder
60599///
60600/// ```test_harness,no_run
60601/// # extern crate hyper;
60602/// # extern crate hyper_rustls;
60603/// # extern crate google_dfareporting3d2 as dfareporting3d2;
60604/// # async fn dox() {
60605/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60606///
60607/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
60608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
60609/// #     secret,
60610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
60611/// # ).build().await.unwrap();
60612///
60613/// # let client = hyper_util::client::legacy::Client::builder(
60614/// #     hyper_util::rt::TokioExecutor::new()
60615/// # )
60616/// # .build(
60617/// #     hyper_rustls::HttpsConnectorBuilder::new()
60618/// #         .with_native_roots()
60619/// #         .unwrap()
60620/// #         .https_or_http()
60621/// #         .enable_http1()
60622/// #         .build()
60623/// # );
60624/// # let mut hub = Dfareporting::new(client, auth);
60625/// // You can configure optional parameters by calling the respective setters at will, and
60626/// // execute the final call using `doit()`.
60627/// // Values shown here are possibly random and not representative !
60628/// let result = hub.placement_strategies().get(-82, -96)
60629///              .doit().await;
60630/// # }
60631/// ```
60632pub struct PlacementStrategyGetCall<'a, C>
60633where
60634    C: 'a,
60635{
60636    hub: &'a Dfareporting<C>,
60637    _profile_id: i64,
60638    _id: i64,
60639    _delegate: Option<&'a mut dyn common::Delegate>,
60640    _additional_params: HashMap<String, String>,
60641    _scopes: BTreeSet<String>,
60642}
60643
60644impl<'a, C> common::CallBuilder for PlacementStrategyGetCall<'a, C> {}
60645
60646impl<'a, C> PlacementStrategyGetCall<'a, C>
60647where
60648    C: common::Connector,
60649{
60650    /// Perform the operation you have build so far.
60651    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementStrategy)> {
60652        use std::borrow::Cow;
60653        use std::io::{Read, Seek};
60654
60655        use common::{url::Params, ToParts};
60656        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
60657
60658        let mut dd = common::DefaultDelegate;
60659        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
60660        dlg.begin(common::MethodInfo {
60661            id: "dfareporting.placementStrategies.get",
60662            http_method: hyper::Method::GET,
60663        });
60664
60665        for &field in ["alt", "profileId", "id"].iter() {
60666            if self._additional_params.contains_key(field) {
60667                dlg.finished(false);
60668                return Err(common::Error::FieldClash(field));
60669            }
60670        }
60671
60672        let mut params = Params::with_capacity(4 + self._additional_params.len());
60673        params.push("profileId", self._profile_id.to_string());
60674        params.push("id", self._id.to_string());
60675
60676        params.extend(self._additional_params.iter());
60677
60678        params.push("alt", "json");
60679        let mut url =
60680            self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies/{id}";
60681        if self._scopes.is_empty() {
60682            self._scopes
60683                .insert(Scope::Dfatrafficking.as_ref().to_string());
60684        }
60685
60686        #[allow(clippy::single_element_loop)]
60687        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
60688            url = params.uri_replacement(url, param_name, find_this, false);
60689        }
60690        {
60691            let to_remove = ["id", "profileId"];
60692            params.remove_params(&to_remove);
60693        }
60694
60695        let url = params.parse_with_url(&url);
60696
60697        loop {
60698            let token = match self
60699                .hub
60700                .auth
60701                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
60702                .await
60703            {
60704                Ok(token) => token,
60705                Err(e) => match dlg.token(e) {
60706                    Ok(token) => token,
60707                    Err(e) => {
60708                        dlg.finished(false);
60709                        return Err(common::Error::MissingToken(e));
60710                    }
60711                },
60712            };
60713            let mut req_result = {
60714                let client = &self.hub.client;
60715                dlg.pre_request();
60716                let mut req_builder = hyper::Request::builder()
60717                    .method(hyper::Method::GET)
60718                    .uri(url.as_str())
60719                    .header(USER_AGENT, self.hub._user_agent.clone());
60720
60721                if let Some(token) = token.as_ref() {
60722                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
60723                }
60724
60725                let request = req_builder
60726                    .header(CONTENT_LENGTH, 0_u64)
60727                    .body(common::to_body::<String>(None));
60728
60729                client.request(request.unwrap()).await
60730            };
60731
60732            match req_result {
60733                Err(err) => {
60734                    if let common::Retry::After(d) = dlg.http_error(&err) {
60735                        sleep(d).await;
60736                        continue;
60737                    }
60738                    dlg.finished(false);
60739                    return Err(common::Error::HttpError(err));
60740                }
60741                Ok(res) => {
60742                    let (mut parts, body) = res.into_parts();
60743                    let mut body = common::Body::new(body);
60744                    if !parts.status.is_success() {
60745                        let bytes = common::to_bytes(body).await.unwrap_or_default();
60746                        let error = serde_json::from_str(&common::to_string(&bytes));
60747                        let response = common::to_response(parts, bytes.into());
60748
60749                        if let common::Retry::After(d) =
60750                            dlg.http_failure(&response, error.as_ref().ok())
60751                        {
60752                            sleep(d).await;
60753                            continue;
60754                        }
60755
60756                        dlg.finished(false);
60757
60758                        return Err(match error {
60759                            Ok(value) => common::Error::BadRequest(value),
60760                            _ => common::Error::Failure(response),
60761                        });
60762                    }
60763                    let response = {
60764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
60765                        let encoded = common::to_string(&bytes);
60766                        match serde_json::from_str(&encoded) {
60767                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
60768                            Err(error) => {
60769                                dlg.response_json_decode_error(&encoded, &error);
60770                                return Err(common::Error::JsonDecodeError(
60771                                    encoded.to_string(),
60772                                    error,
60773                                ));
60774                            }
60775                        }
60776                    };
60777
60778                    dlg.finished(true);
60779                    return Ok(response);
60780                }
60781            }
60782        }
60783    }
60784
60785    /// User profile ID associated with this request.
60786    ///
60787    /// Sets the *profile id* path property to the given value.
60788    ///
60789    /// Even though the property as already been set when instantiating this call,
60790    /// we provide this method for API completeness.
60791    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyGetCall<'a, C> {
60792        self._profile_id = new_value;
60793        self
60794    }
60795    /// Placement strategy ID.
60796    ///
60797    /// Sets the *id* path property to the given value.
60798    ///
60799    /// Even though the property as already been set when instantiating this call,
60800    /// we provide this method for API completeness.
60801    pub fn id(mut self, new_value: i64) -> PlacementStrategyGetCall<'a, C> {
60802        self._id = new_value;
60803        self
60804    }
60805    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
60806    /// while executing the actual API request.
60807    ///
60808    /// ````text
60809    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
60810    /// ````
60811    ///
60812    /// Sets the *delegate* property to the given value.
60813    pub fn delegate(
60814        mut self,
60815        new_value: &'a mut dyn common::Delegate,
60816    ) -> PlacementStrategyGetCall<'a, C> {
60817        self._delegate = Some(new_value);
60818        self
60819    }
60820
60821    /// Set any additional parameter of the query string used in the request.
60822    /// It should be used to set parameters which are not yet available through their own
60823    /// setters.
60824    ///
60825    /// Please note that this method must not be used to set any of the known parameters
60826    /// which have their own setter method. If done anyway, the request will fail.
60827    ///
60828    /// # Additional Parameters
60829    ///
60830    /// * *alt* (query-string) - Data format for the response.
60831    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
60832    /// * *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.
60833    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
60834    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
60835    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
60836    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
60837    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyGetCall<'a, C>
60838    where
60839        T: AsRef<str>,
60840    {
60841        self._additional_params
60842            .insert(name.as_ref().to_string(), value.as_ref().to_string());
60843        self
60844    }
60845
60846    /// Identifies the authorization scope for the method you are building.
60847    ///
60848    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
60849    /// [`Scope::Dfatrafficking`].
60850    ///
60851    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
60852    /// tokens for more than one scope.
60853    ///
60854    /// Usually there is more than one suitable scope to authorize an operation, some of which may
60855    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
60856    /// sufficient, a read-write scope will do as well.
60857    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyGetCall<'a, C>
60858    where
60859        St: AsRef<str>,
60860    {
60861        self._scopes.insert(String::from(scope.as_ref()));
60862        self
60863    }
60864    /// Identifies the authorization scope(s) for the method you are building.
60865    ///
60866    /// See [`Self::add_scope()`] for details.
60867    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyGetCall<'a, C>
60868    where
60869        I: IntoIterator<Item = St>,
60870        St: AsRef<str>,
60871    {
60872        self._scopes
60873            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
60874        self
60875    }
60876
60877    /// Removes all scopes, and no default scope will be used either.
60878    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
60879    /// for details).
60880    pub fn clear_scopes(mut self) -> PlacementStrategyGetCall<'a, C> {
60881        self._scopes.clear();
60882        self
60883    }
60884}
60885
60886/// Inserts a new placement strategy.
60887///
60888/// A builder for the *insert* method supported by a *placementStrategy* resource.
60889/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
60890///
60891/// # Example
60892///
60893/// Instantiate a resource method builder
60894///
60895/// ```test_harness,no_run
60896/// # extern crate hyper;
60897/// # extern crate hyper_rustls;
60898/// # extern crate google_dfareporting3d2 as dfareporting3d2;
60899/// use dfareporting3d2::api::PlacementStrategy;
60900/// # async fn dox() {
60901/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
60902///
60903/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
60904/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
60905/// #     secret,
60906/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
60907/// # ).build().await.unwrap();
60908///
60909/// # let client = hyper_util::client::legacy::Client::builder(
60910/// #     hyper_util::rt::TokioExecutor::new()
60911/// # )
60912/// # .build(
60913/// #     hyper_rustls::HttpsConnectorBuilder::new()
60914/// #         .with_native_roots()
60915/// #         .unwrap()
60916/// #         .https_or_http()
60917/// #         .enable_http1()
60918/// #         .build()
60919/// # );
60920/// # let mut hub = Dfareporting::new(client, auth);
60921/// // As the method needs a request, you would usually fill it with the desired information
60922/// // into the respective structure. Some of the parts shown here might not be applicable !
60923/// // Values shown here are possibly random and not representative !
60924/// let mut req = PlacementStrategy::default();
60925///
60926/// // You can configure optional parameters by calling the respective setters at will, and
60927/// // execute the final call using `doit()`.
60928/// // Values shown here are possibly random and not representative !
60929/// let result = hub.placement_strategies().insert(req, -17)
60930///              .doit().await;
60931/// # }
60932/// ```
60933pub struct PlacementStrategyInsertCall<'a, C>
60934where
60935    C: 'a,
60936{
60937    hub: &'a Dfareporting<C>,
60938    _request: PlacementStrategy,
60939    _profile_id: i64,
60940    _delegate: Option<&'a mut dyn common::Delegate>,
60941    _additional_params: HashMap<String, String>,
60942    _scopes: BTreeSet<String>,
60943}
60944
60945impl<'a, C> common::CallBuilder for PlacementStrategyInsertCall<'a, C> {}
60946
60947impl<'a, C> PlacementStrategyInsertCall<'a, C>
60948where
60949    C: common::Connector,
60950{
60951    /// Perform the operation you have build so far.
60952    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementStrategy)> {
60953        use std::borrow::Cow;
60954        use std::io::{Read, Seek};
60955
60956        use common::{url::Params, ToParts};
60957        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
60958
60959        let mut dd = common::DefaultDelegate;
60960        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
60961        dlg.begin(common::MethodInfo {
60962            id: "dfareporting.placementStrategies.insert",
60963            http_method: hyper::Method::POST,
60964        });
60965
60966        for &field in ["alt", "profileId"].iter() {
60967            if self._additional_params.contains_key(field) {
60968                dlg.finished(false);
60969                return Err(common::Error::FieldClash(field));
60970            }
60971        }
60972
60973        let mut params = Params::with_capacity(4 + self._additional_params.len());
60974        params.push("profileId", self._profile_id.to_string());
60975
60976        params.extend(self._additional_params.iter());
60977
60978        params.push("alt", "json");
60979        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies";
60980        if self._scopes.is_empty() {
60981            self._scopes
60982                .insert(Scope::Dfatrafficking.as_ref().to_string());
60983        }
60984
60985        #[allow(clippy::single_element_loop)]
60986        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
60987            url = params.uri_replacement(url, param_name, find_this, false);
60988        }
60989        {
60990            let to_remove = ["profileId"];
60991            params.remove_params(&to_remove);
60992        }
60993
60994        let url = params.parse_with_url(&url);
60995
60996        let mut json_mime_type = mime::APPLICATION_JSON;
60997        let mut request_value_reader = {
60998            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
60999            common::remove_json_null_values(&mut value);
61000            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
61001            serde_json::to_writer(&mut dst, &value).unwrap();
61002            dst
61003        };
61004        let request_size = request_value_reader
61005            .seek(std::io::SeekFrom::End(0))
61006            .unwrap();
61007        request_value_reader
61008            .seek(std::io::SeekFrom::Start(0))
61009            .unwrap();
61010
61011        loop {
61012            let token = match self
61013                .hub
61014                .auth
61015                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
61016                .await
61017            {
61018                Ok(token) => token,
61019                Err(e) => match dlg.token(e) {
61020                    Ok(token) => token,
61021                    Err(e) => {
61022                        dlg.finished(false);
61023                        return Err(common::Error::MissingToken(e));
61024                    }
61025                },
61026            };
61027            request_value_reader
61028                .seek(std::io::SeekFrom::Start(0))
61029                .unwrap();
61030            let mut req_result = {
61031                let client = &self.hub.client;
61032                dlg.pre_request();
61033                let mut req_builder = hyper::Request::builder()
61034                    .method(hyper::Method::POST)
61035                    .uri(url.as_str())
61036                    .header(USER_AGENT, self.hub._user_agent.clone());
61037
61038                if let Some(token) = token.as_ref() {
61039                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
61040                }
61041
61042                let request = req_builder
61043                    .header(CONTENT_TYPE, json_mime_type.to_string())
61044                    .header(CONTENT_LENGTH, request_size as u64)
61045                    .body(common::to_body(
61046                        request_value_reader.get_ref().clone().into(),
61047                    ));
61048
61049                client.request(request.unwrap()).await
61050            };
61051
61052            match req_result {
61053                Err(err) => {
61054                    if let common::Retry::After(d) = dlg.http_error(&err) {
61055                        sleep(d).await;
61056                        continue;
61057                    }
61058                    dlg.finished(false);
61059                    return Err(common::Error::HttpError(err));
61060                }
61061                Ok(res) => {
61062                    let (mut parts, body) = res.into_parts();
61063                    let mut body = common::Body::new(body);
61064                    if !parts.status.is_success() {
61065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61066                        let error = serde_json::from_str(&common::to_string(&bytes));
61067                        let response = common::to_response(parts, bytes.into());
61068
61069                        if let common::Retry::After(d) =
61070                            dlg.http_failure(&response, error.as_ref().ok())
61071                        {
61072                            sleep(d).await;
61073                            continue;
61074                        }
61075
61076                        dlg.finished(false);
61077
61078                        return Err(match error {
61079                            Ok(value) => common::Error::BadRequest(value),
61080                            _ => common::Error::Failure(response),
61081                        });
61082                    }
61083                    let response = {
61084                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61085                        let encoded = common::to_string(&bytes);
61086                        match serde_json::from_str(&encoded) {
61087                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
61088                            Err(error) => {
61089                                dlg.response_json_decode_error(&encoded, &error);
61090                                return Err(common::Error::JsonDecodeError(
61091                                    encoded.to_string(),
61092                                    error,
61093                                ));
61094                            }
61095                        }
61096                    };
61097
61098                    dlg.finished(true);
61099                    return Ok(response);
61100                }
61101            }
61102        }
61103    }
61104
61105    ///
61106    /// Sets the *request* property to the given value.
61107    ///
61108    /// Even though the property as already been set when instantiating this call,
61109    /// we provide this method for API completeness.
61110    pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyInsertCall<'a, C> {
61111        self._request = new_value;
61112        self
61113    }
61114    /// User profile ID associated with this request.
61115    ///
61116    /// Sets the *profile id* path property to the given value.
61117    ///
61118    /// Even though the property as already been set when instantiating this call,
61119    /// we provide this method for API completeness.
61120    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyInsertCall<'a, C> {
61121        self._profile_id = new_value;
61122        self
61123    }
61124    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
61125    /// while executing the actual API request.
61126    ///
61127    /// ````text
61128    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
61129    /// ````
61130    ///
61131    /// Sets the *delegate* property to the given value.
61132    pub fn delegate(
61133        mut self,
61134        new_value: &'a mut dyn common::Delegate,
61135    ) -> PlacementStrategyInsertCall<'a, C> {
61136        self._delegate = Some(new_value);
61137        self
61138    }
61139
61140    /// Set any additional parameter of the query string used in the request.
61141    /// It should be used to set parameters which are not yet available through their own
61142    /// setters.
61143    ///
61144    /// Please note that this method must not be used to set any of the known parameters
61145    /// which have their own setter method. If done anyway, the request will fail.
61146    ///
61147    /// # Additional Parameters
61148    ///
61149    /// * *alt* (query-string) - Data format for the response.
61150    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
61151    /// * *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.
61152    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
61153    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
61154    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
61155    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
61156    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyInsertCall<'a, C>
61157    where
61158        T: AsRef<str>,
61159    {
61160        self._additional_params
61161            .insert(name.as_ref().to_string(), value.as_ref().to_string());
61162        self
61163    }
61164
61165    /// Identifies the authorization scope for the method you are building.
61166    ///
61167    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
61168    /// [`Scope::Dfatrafficking`].
61169    ///
61170    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
61171    /// tokens for more than one scope.
61172    ///
61173    /// Usually there is more than one suitable scope to authorize an operation, some of which may
61174    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
61175    /// sufficient, a read-write scope will do as well.
61176    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyInsertCall<'a, C>
61177    where
61178        St: AsRef<str>,
61179    {
61180        self._scopes.insert(String::from(scope.as_ref()));
61181        self
61182    }
61183    /// Identifies the authorization scope(s) for the method you are building.
61184    ///
61185    /// See [`Self::add_scope()`] for details.
61186    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyInsertCall<'a, C>
61187    where
61188        I: IntoIterator<Item = St>,
61189        St: AsRef<str>,
61190    {
61191        self._scopes
61192            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
61193        self
61194    }
61195
61196    /// Removes all scopes, and no default scope will be used either.
61197    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
61198    /// for details).
61199    pub fn clear_scopes(mut self) -> PlacementStrategyInsertCall<'a, C> {
61200        self._scopes.clear();
61201        self
61202    }
61203}
61204
61205/// Retrieves a list of placement strategies, possibly filtered. This method supports paging.
61206///
61207/// A builder for the *list* method supported by a *placementStrategy* resource.
61208/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
61209///
61210/// # Example
61211///
61212/// Instantiate a resource method builder
61213///
61214/// ```test_harness,no_run
61215/// # extern crate hyper;
61216/// # extern crate hyper_rustls;
61217/// # extern crate google_dfareporting3d2 as dfareporting3d2;
61218/// # async fn dox() {
61219/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
61220///
61221/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
61222/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
61223/// #     secret,
61224/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
61225/// # ).build().await.unwrap();
61226///
61227/// # let client = hyper_util::client::legacy::Client::builder(
61228/// #     hyper_util::rt::TokioExecutor::new()
61229/// # )
61230/// # .build(
61231/// #     hyper_rustls::HttpsConnectorBuilder::new()
61232/// #         .with_native_roots()
61233/// #         .unwrap()
61234/// #         .https_or_http()
61235/// #         .enable_http1()
61236/// #         .build()
61237/// # );
61238/// # let mut hub = Dfareporting::new(client, auth);
61239/// // You can configure optional parameters by calling the respective setters at will, and
61240/// // execute the final call using `doit()`.
61241/// // Values shown here are possibly random and not representative !
61242/// let result = hub.placement_strategies().list(-101)
61243///              .sort_order("elitr")
61244///              .sort_field("justo")
61245///              .search_string("Lorem")
61246///              .page_token("labore")
61247///              .max_results(-62)
61248///              .add_ids(-76)
61249///              .doit().await;
61250/// # }
61251/// ```
61252pub struct PlacementStrategyListCall<'a, C>
61253where
61254    C: 'a,
61255{
61256    hub: &'a Dfareporting<C>,
61257    _profile_id: i64,
61258    _sort_order: Option<String>,
61259    _sort_field: Option<String>,
61260    _search_string: Option<String>,
61261    _page_token: Option<String>,
61262    _max_results: Option<i32>,
61263    _ids: Vec<i64>,
61264    _delegate: Option<&'a mut dyn common::Delegate>,
61265    _additional_params: HashMap<String, String>,
61266    _scopes: BTreeSet<String>,
61267}
61268
61269impl<'a, C> common::CallBuilder for PlacementStrategyListCall<'a, C> {}
61270
61271impl<'a, C> PlacementStrategyListCall<'a, C>
61272where
61273    C: common::Connector,
61274{
61275    /// Perform the operation you have build so far.
61276    pub async fn doit(
61277        mut self,
61278    ) -> common::Result<(common::Response, PlacementStrategiesListResponse)> {
61279        use std::borrow::Cow;
61280        use std::io::{Read, Seek};
61281
61282        use common::{url::Params, ToParts};
61283        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
61284
61285        let mut dd = common::DefaultDelegate;
61286        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
61287        dlg.begin(common::MethodInfo {
61288            id: "dfareporting.placementStrategies.list",
61289            http_method: hyper::Method::GET,
61290        });
61291
61292        for &field in [
61293            "alt",
61294            "profileId",
61295            "sortOrder",
61296            "sortField",
61297            "searchString",
61298            "pageToken",
61299            "maxResults",
61300            "ids",
61301        ]
61302        .iter()
61303        {
61304            if self._additional_params.contains_key(field) {
61305                dlg.finished(false);
61306                return Err(common::Error::FieldClash(field));
61307            }
61308        }
61309
61310        let mut params = Params::with_capacity(9 + self._additional_params.len());
61311        params.push("profileId", self._profile_id.to_string());
61312        if let Some(value) = self._sort_order.as_ref() {
61313            params.push("sortOrder", value);
61314        }
61315        if let Some(value) = self._sort_field.as_ref() {
61316            params.push("sortField", value);
61317        }
61318        if let Some(value) = self._search_string.as_ref() {
61319            params.push("searchString", value);
61320        }
61321        if let Some(value) = self._page_token.as_ref() {
61322            params.push("pageToken", value);
61323        }
61324        if let Some(value) = self._max_results.as_ref() {
61325            params.push("maxResults", value.to_string());
61326        }
61327        if !self._ids.is_empty() {
61328            for f in self._ids.iter() {
61329                params.push("ids", f.to_string());
61330            }
61331        }
61332
61333        params.extend(self._additional_params.iter());
61334
61335        params.push("alt", "json");
61336        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies";
61337        if self._scopes.is_empty() {
61338            self._scopes
61339                .insert(Scope::Dfatrafficking.as_ref().to_string());
61340        }
61341
61342        #[allow(clippy::single_element_loop)]
61343        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
61344            url = params.uri_replacement(url, param_name, find_this, false);
61345        }
61346        {
61347            let to_remove = ["profileId"];
61348            params.remove_params(&to_remove);
61349        }
61350
61351        let url = params.parse_with_url(&url);
61352
61353        loop {
61354            let token = match self
61355                .hub
61356                .auth
61357                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
61358                .await
61359            {
61360                Ok(token) => token,
61361                Err(e) => match dlg.token(e) {
61362                    Ok(token) => token,
61363                    Err(e) => {
61364                        dlg.finished(false);
61365                        return Err(common::Error::MissingToken(e));
61366                    }
61367                },
61368            };
61369            let mut req_result = {
61370                let client = &self.hub.client;
61371                dlg.pre_request();
61372                let mut req_builder = hyper::Request::builder()
61373                    .method(hyper::Method::GET)
61374                    .uri(url.as_str())
61375                    .header(USER_AGENT, self.hub._user_agent.clone());
61376
61377                if let Some(token) = token.as_ref() {
61378                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
61379                }
61380
61381                let request = req_builder
61382                    .header(CONTENT_LENGTH, 0_u64)
61383                    .body(common::to_body::<String>(None));
61384
61385                client.request(request.unwrap()).await
61386            };
61387
61388            match req_result {
61389                Err(err) => {
61390                    if let common::Retry::After(d) = dlg.http_error(&err) {
61391                        sleep(d).await;
61392                        continue;
61393                    }
61394                    dlg.finished(false);
61395                    return Err(common::Error::HttpError(err));
61396                }
61397                Ok(res) => {
61398                    let (mut parts, body) = res.into_parts();
61399                    let mut body = common::Body::new(body);
61400                    if !parts.status.is_success() {
61401                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61402                        let error = serde_json::from_str(&common::to_string(&bytes));
61403                        let response = common::to_response(parts, bytes.into());
61404
61405                        if let common::Retry::After(d) =
61406                            dlg.http_failure(&response, error.as_ref().ok())
61407                        {
61408                            sleep(d).await;
61409                            continue;
61410                        }
61411
61412                        dlg.finished(false);
61413
61414                        return Err(match error {
61415                            Ok(value) => common::Error::BadRequest(value),
61416                            _ => common::Error::Failure(response),
61417                        });
61418                    }
61419                    let response = {
61420                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61421                        let encoded = common::to_string(&bytes);
61422                        match serde_json::from_str(&encoded) {
61423                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
61424                            Err(error) => {
61425                                dlg.response_json_decode_error(&encoded, &error);
61426                                return Err(common::Error::JsonDecodeError(
61427                                    encoded.to_string(),
61428                                    error,
61429                                ));
61430                            }
61431                        }
61432                    };
61433
61434                    dlg.finished(true);
61435                    return Ok(response);
61436                }
61437            }
61438        }
61439    }
61440
61441    /// User profile ID associated with this request.
61442    ///
61443    /// Sets the *profile id* path property to the given value.
61444    ///
61445    /// Even though the property as already been set when instantiating this call,
61446    /// we provide this method for API completeness.
61447    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyListCall<'a, C> {
61448        self._profile_id = new_value;
61449        self
61450    }
61451    /// Order of sorted results.
61452    ///
61453    /// Sets the *sort order* query property to the given value.
61454    pub fn sort_order(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C> {
61455        self._sort_order = Some(new_value.to_string());
61456        self
61457    }
61458    /// Field by which to sort the list.
61459    ///
61460    /// Sets the *sort field* query property to the given value.
61461    pub fn sort_field(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C> {
61462        self._sort_field = Some(new_value.to_string());
61463        self
61464    }
61465    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "placementstrategy*2015" will return objects with names like "placementstrategy June 2015", "placementstrategy April 2015", or simply "placementstrategy 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placementstrategy" will match objects with name "my placementstrategy", "placementstrategy 2015", or simply "placementstrategy".
61466    ///
61467    /// Sets the *search string* query property to the given value.
61468    pub fn search_string(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C> {
61469        self._search_string = Some(new_value.to_string());
61470        self
61471    }
61472    /// Value of the nextPageToken from the previous result page.
61473    ///
61474    /// Sets the *page token* query property to the given value.
61475    pub fn page_token(mut self, new_value: &str) -> PlacementStrategyListCall<'a, C> {
61476        self._page_token = Some(new_value.to_string());
61477        self
61478    }
61479    /// Maximum number of results to return.
61480    ///
61481    /// Sets the *max results* query property to the given value.
61482    pub fn max_results(mut self, new_value: i32) -> PlacementStrategyListCall<'a, C> {
61483        self._max_results = Some(new_value);
61484        self
61485    }
61486    /// Select only placement strategies with these IDs.
61487    ///
61488    /// Append the given value to the *ids* query property.
61489    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
61490    pub fn add_ids(mut self, new_value: i64) -> PlacementStrategyListCall<'a, C> {
61491        self._ids.push(new_value);
61492        self
61493    }
61494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
61495    /// while executing the actual API request.
61496    ///
61497    /// ````text
61498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
61499    /// ````
61500    ///
61501    /// Sets the *delegate* property to the given value.
61502    pub fn delegate(
61503        mut self,
61504        new_value: &'a mut dyn common::Delegate,
61505    ) -> PlacementStrategyListCall<'a, C> {
61506        self._delegate = Some(new_value);
61507        self
61508    }
61509
61510    /// Set any additional parameter of the query string used in the request.
61511    /// It should be used to set parameters which are not yet available through their own
61512    /// setters.
61513    ///
61514    /// Please note that this method must not be used to set any of the known parameters
61515    /// which have their own setter method. If done anyway, the request will fail.
61516    ///
61517    /// # Additional Parameters
61518    ///
61519    /// * *alt* (query-string) - Data format for the response.
61520    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
61521    /// * *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.
61522    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
61523    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
61524    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
61525    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
61526    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyListCall<'a, C>
61527    where
61528        T: AsRef<str>,
61529    {
61530        self._additional_params
61531            .insert(name.as_ref().to_string(), value.as_ref().to_string());
61532        self
61533    }
61534
61535    /// Identifies the authorization scope for the method you are building.
61536    ///
61537    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
61538    /// [`Scope::Dfatrafficking`].
61539    ///
61540    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
61541    /// tokens for more than one scope.
61542    ///
61543    /// Usually there is more than one suitable scope to authorize an operation, some of which may
61544    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
61545    /// sufficient, a read-write scope will do as well.
61546    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyListCall<'a, C>
61547    where
61548        St: AsRef<str>,
61549    {
61550        self._scopes.insert(String::from(scope.as_ref()));
61551        self
61552    }
61553    /// Identifies the authorization scope(s) for the method you are building.
61554    ///
61555    /// See [`Self::add_scope()`] for details.
61556    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyListCall<'a, C>
61557    where
61558        I: IntoIterator<Item = St>,
61559        St: AsRef<str>,
61560    {
61561        self._scopes
61562            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
61563        self
61564    }
61565
61566    /// Removes all scopes, and no default scope will be used either.
61567    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
61568    /// for details).
61569    pub fn clear_scopes(mut self) -> PlacementStrategyListCall<'a, C> {
61570        self._scopes.clear();
61571        self
61572    }
61573}
61574
61575/// Updates an existing placement strategy. This method supports patch semantics.
61576///
61577/// A builder for the *patch* method supported by a *placementStrategy* resource.
61578/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
61579///
61580/// # Example
61581///
61582/// Instantiate a resource method builder
61583///
61584/// ```test_harness,no_run
61585/// # extern crate hyper;
61586/// # extern crate hyper_rustls;
61587/// # extern crate google_dfareporting3d2 as dfareporting3d2;
61588/// use dfareporting3d2::api::PlacementStrategy;
61589/// # async fn dox() {
61590/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
61591///
61592/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
61593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
61594/// #     secret,
61595/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
61596/// # ).build().await.unwrap();
61597///
61598/// # let client = hyper_util::client::legacy::Client::builder(
61599/// #     hyper_util::rt::TokioExecutor::new()
61600/// # )
61601/// # .build(
61602/// #     hyper_rustls::HttpsConnectorBuilder::new()
61603/// #         .with_native_roots()
61604/// #         .unwrap()
61605/// #         .https_or_http()
61606/// #         .enable_http1()
61607/// #         .build()
61608/// # );
61609/// # let mut hub = Dfareporting::new(client, auth);
61610/// // As the method needs a request, you would usually fill it with the desired information
61611/// // into the respective structure. Some of the parts shown here might not be applicable !
61612/// // Values shown here are possibly random and not representative !
61613/// let mut req = PlacementStrategy::default();
61614///
61615/// // You can configure optional parameters by calling the respective setters at will, and
61616/// // execute the final call using `doit()`.
61617/// // Values shown here are possibly random and not representative !
61618/// let result = hub.placement_strategies().patch(req, -17, -93)
61619///              .doit().await;
61620/// # }
61621/// ```
61622pub struct PlacementStrategyPatchCall<'a, C>
61623where
61624    C: 'a,
61625{
61626    hub: &'a Dfareporting<C>,
61627    _request: PlacementStrategy,
61628    _profile_id: i64,
61629    _id: i64,
61630    _delegate: Option<&'a mut dyn common::Delegate>,
61631    _additional_params: HashMap<String, String>,
61632    _scopes: BTreeSet<String>,
61633}
61634
61635impl<'a, C> common::CallBuilder for PlacementStrategyPatchCall<'a, C> {}
61636
61637impl<'a, C> PlacementStrategyPatchCall<'a, C>
61638where
61639    C: common::Connector,
61640{
61641    /// Perform the operation you have build so far.
61642    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementStrategy)> {
61643        use std::borrow::Cow;
61644        use std::io::{Read, Seek};
61645
61646        use common::{url::Params, ToParts};
61647        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
61648
61649        let mut dd = common::DefaultDelegate;
61650        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
61651        dlg.begin(common::MethodInfo {
61652            id: "dfareporting.placementStrategies.patch",
61653            http_method: hyper::Method::PATCH,
61654        });
61655
61656        for &field in ["alt", "profileId", "id"].iter() {
61657            if self._additional_params.contains_key(field) {
61658                dlg.finished(false);
61659                return Err(common::Error::FieldClash(field));
61660            }
61661        }
61662
61663        let mut params = Params::with_capacity(5 + self._additional_params.len());
61664        params.push("profileId", self._profile_id.to_string());
61665        params.push("id", self._id.to_string());
61666
61667        params.extend(self._additional_params.iter());
61668
61669        params.push("alt", "json");
61670        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies";
61671        if self._scopes.is_empty() {
61672            self._scopes
61673                .insert(Scope::Dfatrafficking.as_ref().to_string());
61674        }
61675
61676        #[allow(clippy::single_element_loop)]
61677        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
61678            url = params.uri_replacement(url, param_name, find_this, false);
61679        }
61680        {
61681            let to_remove = ["profileId"];
61682            params.remove_params(&to_remove);
61683        }
61684
61685        let url = params.parse_with_url(&url);
61686
61687        let mut json_mime_type = mime::APPLICATION_JSON;
61688        let mut request_value_reader = {
61689            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
61690            common::remove_json_null_values(&mut value);
61691            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
61692            serde_json::to_writer(&mut dst, &value).unwrap();
61693            dst
61694        };
61695        let request_size = request_value_reader
61696            .seek(std::io::SeekFrom::End(0))
61697            .unwrap();
61698        request_value_reader
61699            .seek(std::io::SeekFrom::Start(0))
61700            .unwrap();
61701
61702        loop {
61703            let token = match self
61704                .hub
61705                .auth
61706                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
61707                .await
61708            {
61709                Ok(token) => token,
61710                Err(e) => match dlg.token(e) {
61711                    Ok(token) => token,
61712                    Err(e) => {
61713                        dlg.finished(false);
61714                        return Err(common::Error::MissingToken(e));
61715                    }
61716                },
61717            };
61718            request_value_reader
61719                .seek(std::io::SeekFrom::Start(0))
61720                .unwrap();
61721            let mut req_result = {
61722                let client = &self.hub.client;
61723                dlg.pre_request();
61724                let mut req_builder = hyper::Request::builder()
61725                    .method(hyper::Method::PATCH)
61726                    .uri(url.as_str())
61727                    .header(USER_AGENT, self.hub._user_agent.clone());
61728
61729                if let Some(token) = token.as_ref() {
61730                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
61731                }
61732
61733                let request = req_builder
61734                    .header(CONTENT_TYPE, json_mime_type.to_string())
61735                    .header(CONTENT_LENGTH, request_size as u64)
61736                    .body(common::to_body(
61737                        request_value_reader.get_ref().clone().into(),
61738                    ));
61739
61740                client.request(request.unwrap()).await
61741            };
61742
61743            match req_result {
61744                Err(err) => {
61745                    if let common::Retry::After(d) = dlg.http_error(&err) {
61746                        sleep(d).await;
61747                        continue;
61748                    }
61749                    dlg.finished(false);
61750                    return Err(common::Error::HttpError(err));
61751                }
61752                Ok(res) => {
61753                    let (mut parts, body) = res.into_parts();
61754                    let mut body = common::Body::new(body);
61755                    if !parts.status.is_success() {
61756                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61757                        let error = serde_json::from_str(&common::to_string(&bytes));
61758                        let response = common::to_response(parts, bytes.into());
61759
61760                        if let common::Retry::After(d) =
61761                            dlg.http_failure(&response, error.as_ref().ok())
61762                        {
61763                            sleep(d).await;
61764                            continue;
61765                        }
61766
61767                        dlg.finished(false);
61768
61769                        return Err(match error {
61770                            Ok(value) => common::Error::BadRequest(value),
61771                            _ => common::Error::Failure(response),
61772                        });
61773                    }
61774                    let response = {
61775                        let bytes = common::to_bytes(body).await.unwrap_or_default();
61776                        let encoded = common::to_string(&bytes);
61777                        match serde_json::from_str(&encoded) {
61778                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
61779                            Err(error) => {
61780                                dlg.response_json_decode_error(&encoded, &error);
61781                                return Err(common::Error::JsonDecodeError(
61782                                    encoded.to_string(),
61783                                    error,
61784                                ));
61785                            }
61786                        }
61787                    };
61788
61789                    dlg.finished(true);
61790                    return Ok(response);
61791                }
61792            }
61793        }
61794    }
61795
61796    ///
61797    /// Sets the *request* property to the given value.
61798    ///
61799    /// Even though the property as already been set when instantiating this call,
61800    /// we provide this method for API completeness.
61801    pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyPatchCall<'a, C> {
61802        self._request = new_value;
61803        self
61804    }
61805    /// User profile ID associated with this request.
61806    ///
61807    /// Sets the *profile id* path property to the given value.
61808    ///
61809    /// Even though the property as already been set when instantiating this call,
61810    /// we provide this method for API completeness.
61811    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyPatchCall<'a, C> {
61812        self._profile_id = new_value;
61813        self
61814    }
61815    /// Placement strategy ID.
61816    ///
61817    /// Sets the *id* query property to the given value.
61818    ///
61819    /// Even though the property as already been set when instantiating this call,
61820    /// we provide this method for API completeness.
61821    pub fn id(mut self, new_value: i64) -> PlacementStrategyPatchCall<'a, C> {
61822        self._id = new_value;
61823        self
61824    }
61825    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
61826    /// while executing the actual API request.
61827    ///
61828    /// ````text
61829    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
61830    /// ````
61831    ///
61832    /// Sets the *delegate* property to the given value.
61833    pub fn delegate(
61834        mut self,
61835        new_value: &'a mut dyn common::Delegate,
61836    ) -> PlacementStrategyPatchCall<'a, C> {
61837        self._delegate = Some(new_value);
61838        self
61839    }
61840
61841    /// Set any additional parameter of the query string used in the request.
61842    /// It should be used to set parameters which are not yet available through their own
61843    /// setters.
61844    ///
61845    /// Please note that this method must not be used to set any of the known parameters
61846    /// which have their own setter method. If done anyway, the request will fail.
61847    ///
61848    /// # Additional Parameters
61849    ///
61850    /// * *alt* (query-string) - Data format for the response.
61851    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
61852    /// * *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.
61853    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
61854    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
61855    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
61856    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
61857    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyPatchCall<'a, C>
61858    where
61859        T: AsRef<str>,
61860    {
61861        self._additional_params
61862            .insert(name.as_ref().to_string(), value.as_ref().to_string());
61863        self
61864    }
61865
61866    /// Identifies the authorization scope for the method you are building.
61867    ///
61868    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
61869    /// [`Scope::Dfatrafficking`].
61870    ///
61871    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
61872    /// tokens for more than one scope.
61873    ///
61874    /// Usually there is more than one suitable scope to authorize an operation, some of which may
61875    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
61876    /// sufficient, a read-write scope will do as well.
61877    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyPatchCall<'a, C>
61878    where
61879        St: AsRef<str>,
61880    {
61881        self._scopes.insert(String::from(scope.as_ref()));
61882        self
61883    }
61884    /// Identifies the authorization scope(s) for the method you are building.
61885    ///
61886    /// See [`Self::add_scope()`] for details.
61887    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyPatchCall<'a, C>
61888    where
61889        I: IntoIterator<Item = St>,
61890        St: AsRef<str>,
61891    {
61892        self._scopes
61893            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
61894        self
61895    }
61896
61897    /// Removes all scopes, and no default scope will be used either.
61898    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
61899    /// for details).
61900    pub fn clear_scopes(mut self) -> PlacementStrategyPatchCall<'a, C> {
61901        self._scopes.clear();
61902        self
61903    }
61904}
61905
61906/// Updates an existing placement strategy.
61907///
61908/// A builder for the *update* method supported by a *placementStrategy* resource.
61909/// It is not used directly, but through a [`PlacementStrategyMethods`] instance.
61910///
61911/// # Example
61912///
61913/// Instantiate a resource method builder
61914///
61915/// ```test_harness,no_run
61916/// # extern crate hyper;
61917/// # extern crate hyper_rustls;
61918/// # extern crate google_dfareporting3d2 as dfareporting3d2;
61919/// use dfareporting3d2::api::PlacementStrategy;
61920/// # async fn dox() {
61921/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
61922///
61923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
61924/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
61925/// #     secret,
61926/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
61927/// # ).build().await.unwrap();
61928///
61929/// # let client = hyper_util::client::legacy::Client::builder(
61930/// #     hyper_util::rt::TokioExecutor::new()
61931/// # )
61932/// # .build(
61933/// #     hyper_rustls::HttpsConnectorBuilder::new()
61934/// #         .with_native_roots()
61935/// #         .unwrap()
61936/// #         .https_or_http()
61937/// #         .enable_http1()
61938/// #         .build()
61939/// # );
61940/// # let mut hub = Dfareporting::new(client, auth);
61941/// // As the method needs a request, you would usually fill it with the desired information
61942/// // into the respective structure. Some of the parts shown here might not be applicable !
61943/// // Values shown here are possibly random and not representative !
61944/// let mut req = PlacementStrategy::default();
61945///
61946/// // You can configure optional parameters by calling the respective setters at will, and
61947/// // execute the final call using `doit()`.
61948/// // Values shown here are possibly random and not representative !
61949/// let result = hub.placement_strategies().update(req, -8)
61950///              .doit().await;
61951/// # }
61952/// ```
61953pub struct PlacementStrategyUpdateCall<'a, C>
61954where
61955    C: 'a,
61956{
61957    hub: &'a Dfareporting<C>,
61958    _request: PlacementStrategy,
61959    _profile_id: i64,
61960    _delegate: Option<&'a mut dyn common::Delegate>,
61961    _additional_params: HashMap<String, String>,
61962    _scopes: BTreeSet<String>,
61963}
61964
61965impl<'a, C> common::CallBuilder for PlacementStrategyUpdateCall<'a, C> {}
61966
61967impl<'a, C> PlacementStrategyUpdateCall<'a, C>
61968where
61969    C: common::Connector,
61970{
61971    /// Perform the operation you have build so far.
61972    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementStrategy)> {
61973        use std::borrow::Cow;
61974        use std::io::{Read, Seek};
61975
61976        use common::{url::Params, ToParts};
61977        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
61978
61979        let mut dd = common::DefaultDelegate;
61980        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
61981        dlg.begin(common::MethodInfo {
61982            id: "dfareporting.placementStrategies.update",
61983            http_method: hyper::Method::PUT,
61984        });
61985
61986        for &field in ["alt", "profileId"].iter() {
61987            if self._additional_params.contains_key(field) {
61988                dlg.finished(false);
61989                return Err(common::Error::FieldClash(field));
61990            }
61991        }
61992
61993        let mut params = Params::with_capacity(4 + self._additional_params.len());
61994        params.push("profileId", self._profile_id.to_string());
61995
61996        params.extend(self._additional_params.iter());
61997
61998        params.push("alt", "json");
61999        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies";
62000        if self._scopes.is_empty() {
62001            self._scopes
62002                .insert(Scope::Dfatrafficking.as_ref().to_string());
62003        }
62004
62005        #[allow(clippy::single_element_loop)]
62006        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
62007            url = params.uri_replacement(url, param_name, find_this, false);
62008        }
62009        {
62010            let to_remove = ["profileId"];
62011            params.remove_params(&to_remove);
62012        }
62013
62014        let url = params.parse_with_url(&url);
62015
62016        let mut json_mime_type = mime::APPLICATION_JSON;
62017        let mut request_value_reader = {
62018            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
62019            common::remove_json_null_values(&mut value);
62020            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
62021            serde_json::to_writer(&mut dst, &value).unwrap();
62022            dst
62023        };
62024        let request_size = request_value_reader
62025            .seek(std::io::SeekFrom::End(0))
62026            .unwrap();
62027        request_value_reader
62028            .seek(std::io::SeekFrom::Start(0))
62029            .unwrap();
62030
62031        loop {
62032            let token = match self
62033                .hub
62034                .auth
62035                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
62036                .await
62037            {
62038                Ok(token) => token,
62039                Err(e) => match dlg.token(e) {
62040                    Ok(token) => token,
62041                    Err(e) => {
62042                        dlg.finished(false);
62043                        return Err(common::Error::MissingToken(e));
62044                    }
62045                },
62046            };
62047            request_value_reader
62048                .seek(std::io::SeekFrom::Start(0))
62049                .unwrap();
62050            let mut req_result = {
62051                let client = &self.hub.client;
62052                dlg.pre_request();
62053                let mut req_builder = hyper::Request::builder()
62054                    .method(hyper::Method::PUT)
62055                    .uri(url.as_str())
62056                    .header(USER_AGENT, self.hub._user_agent.clone());
62057
62058                if let Some(token) = token.as_ref() {
62059                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
62060                }
62061
62062                let request = req_builder
62063                    .header(CONTENT_TYPE, json_mime_type.to_string())
62064                    .header(CONTENT_LENGTH, request_size as u64)
62065                    .body(common::to_body(
62066                        request_value_reader.get_ref().clone().into(),
62067                    ));
62068
62069                client.request(request.unwrap()).await
62070            };
62071
62072            match req_result {
62073                Err(err) => {
62074                    if let common::Retry::After(d) = dlg.http_error(&err) {
62075                        sleep(d).await;
62076                        continue;
62077                    }
62078                    dlg.finished(false);
62079                    return Err(common::Error::HttpError(err));
62080                }
62081                Ok(res) => {
62082                    let (mut parts, body) = res.into_parts();
62083                    let mut body = common::Body::new(body);
62084                    if !parts.status.is_success() {
62085                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62086                        let error = serde_json::from_str(&common::to_string(&bytes));
62087                        let response = common::to_response(parts, bytes.into());
62088
62089                        if let common::Retry::After(d) =
62090                            dlg.http_failure(&response, error.as_ref().ok())
62091                        {
62092                            sleep(d).await;
62093                            continue;
62094                        }
62095
62096                        dlg.finished(false);
62097
62098                        return Err(match error {
62099                            Ok(value) => common::Error::BadRequest(value),
62100                            _ => common::Error::Failure(response),
62101                        });
62102                    }
62103                    let response = {
62104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62105                        let encoded = common::to_string(&bytes);
62106                        match serde_json::from_str(&encoded) {
62107                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
62108                            Err(error) => {
62109                                dlg.response_json_decode_error(&encoded, &error);
62110                                return Err(common::Error::JsonDecodeError(
62111                                    encoded.to_string(),
62112                                    error,
62113                                ));
62114                            }
62115                        }
62116                    };
62117
62118                    dlg.finished(true);
62119                    return Ok(response);
62120                }
62121            }
62122        }
62123    }
62124
62125    ///
62126    /// Sets the *request* property to the given value.
62127    ///
62128    /// Even though the property as already been set when instantiating this call,
62129    /// we provide this method for API completeness.
62130    pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyUpdateCall<'a, C> {
62131        self._request = new_value;
62132        self
62133    }
62134    /// User profile ID associated with this request.
62135    ///
62136    /// Sets the *profile id* path property to the given value.
62137    ///
62138    /// Even though the property as already been set when instantiating this call,
62139    /// we provide this method for API completeness.
62140    pub fn profile_id(mut self, new_value: i64) -> PlacementStrategyUpdateCall<'a, C> {
62141        self._profile_id = new_value;
62142        self
62143    }
62144    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
62145    /// while executing the actual API request.
62146    ///
62147    /// ````text
62148    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
62149    /// ````
62150    ///
62151    /// Sets the *delegate* property to the given value.
62152    pub fn delegate(
62153        mut self,
62154        new_value: &'a mut dyn common::Delegate,
62155    ) -> PlacementStrategyUpdateCall<'a, C> {
62156        self._delegate = Some(new_value);
62157        self
62158    }
62159
62160    /// Set any additional parameter of the query string used in the request.
62161    /// It should be used to set parameters which are not yet available through their own
62162    /// setters.
62163    ///
62164    /// Please note that this method must not be used to set any of the known parameters
62165    /// which have their own setter method. If done anyway, the request will fail.
62166    ///
62167    /// # Additional Parameters
62168    ///
62169    /// * *alt* (query-string) - Data format for the response.
62170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
62171    /// * *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.
62172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
62173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
62174    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
62175    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
62176    pub fn param<T>(mut self, name: T, value: T) -> PlacementStrategyUpdateCall<'a, C>
62177    where
62178        T: AsRef<str>,
62179    {
62180        self._additional_params
62181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
62182        self
62183    }
62184
62185    /// Identifies the authorization scope for the method you are building.
62186    ///
62187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
62188    /// [`Scope::Dfatrafficking`].
62189    ///
62190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
62191    /// tokens for more than one scope.
62192    ///
62193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
62194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
62195    /// sufficient, a read-write scope will do as well.
62196    pub fn add_scope<St>(mut self, scope: St) -> PlacementStrategyUpdateCall<'a, C>
62197    where
62198        St: AsRef<str>,
62199    {
62200        self._scopes.insert(String::from(scope.as_ref()));
62201        self
62202    }
62203    /// Identifies the authorization scope(s) for the method you are building.
62204    ///
62205    /// See [`Self::add_scope()`] for details.
62206    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementStrategyUpdateCall<'a, C>
62207    where
62208        I: IntoIterator<Item = St>,
62209        St: AsRef<str>,
62210    {
62211        self._scopes
62212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
62213        self
62214    }
62215
62216    /// Removes all scopes, and no default scope will be used either.
62217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
62218    /// for details).
62219    pub fn clear_scopes(mut self) -> PlacementStrategyUpdateCall<'a, C> {
62220        self._scopes.clear();
62221        self
62222    }
62223}
62224
62225/// Generates tags for a placement.
62226///
62227/// A builder for the *generatetags* method supported by a *placement* resource.
62228/// It is not used directly, but through a [`PlacementMethods`] instance.
62229///
62230/// # Example
62231///
62232/// Instantiate a resource method builder
62233///
62234/// ```test_harness,no_run
62235/// # extern crate hyper;
62236/// # extern crate hyper_rustls;
62237/// # extern crate google_dfareporting3d2 as dfareporting3d2;
62238/// # async fn dox() {
62239/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
62240///
62241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
62242/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
62243/// #     secret,
62244/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
62245/// # ).build().await.unwrap();
62246///
62247/// # let client = hyper_util::client::legacy::Client::builder(
62248/// #     hyper_util::rt::TokioExecutor::new()
62249/// # )
62250/// # .build(
62251/// #     hyper_rustls::HttpsConnectorBuilder::new()
62252/// #         .with_native_roots()
62253/// #         .unwrap()
62254/// #         .https_or_http()
62255/// #         .enable_http1()
62256/// #         .build()
62257/// # );
62258/// # let mut hub = Dfareporting::new(client, auth);
62259/// // You can configure optional parameters by calling the respective setters at will, and
62260/// // execute the final call using `doit()`.
62261/// // Values shown here are possibly random and not representative !
62262/// let result = hub.placements().generatetags(-36)
62263///              .add_tag_formats("amet")
62264///              .add_placement_ids(-22)
62265///              .campaign_id(-34)
62266///              .doit().await;
62267/// # }
62268/// ```
62269pub struct PlacementGeneratetagCall<'a, C>
62270where
62271    C: 'a,
62272{
62273    hub: &'a Dfareporting<C>,
62274    _profile_id: i64,
62275    _tag_formats: Vec<String>,
62276    _placement_ids: Vec<i64>,
62277    _campaign_id: Option<i64>,
62278    _delegate: Option<&'a mut dyn common::Delegate>,
62279    _additional_params: HashMap<String, String>,
62280    _scopes: BTreeSet<String>,
62281}
62282
62283impl<'a, C> common::CallBuilder for PlacementGeneratetagCall<'a, C> {}
62284
62285impl<'a, C> PlacementGeneratetagCall<'a, C>
62286where
62287    C: common::Connector,
62288{
62289    /// Perform the operation you have build so far.
62290    pub async fn doit(
62291        mut self,
62292    ) -> common::Result<(common::Response, PlacementsGenerateTagsResponse)> {
62293        use std::borrow::Cow;
62294        use std::io::{Read, Seek};
62295
62296        use common::{url::Params, ToParts};
62297        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
62298
62299        let mut dd = common::DefaultDelegate;
62300        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
62301        dlg.begin(common::MethodInfo {
62302            id: "dfareporting.placements.generatetags",
62303            http_method: hyper::Method::POST,
62304        });
62305
62306        for &field in [
62307            "alt",
62308            "profileId",
62309            "tagFormats",
62310            "placementIds",
62311            "campaignId",
62312        ]
62313        .iter()
62314        {
62315            if self._additional_params.contains_key(field) {
62316                dlg.finished(false);
62317                return Err(common::Error::FieldClash(field));
62318            }
62319        }
62320
62321        let mut params = Params::with_capacity(6 + self._additional_params.len());
62322        params.push("profileId", self._profile_id.to_string());
62323        if !self._tag_formats.is_empty() {
62324            for f in self._tag_formats.iter() {
62325                params.push("tagFormats", f);
62326            }
62327        }
62328        if !self._placement_ids.is_empty() {
62329            for f in self._placement_ids.iter() {
62330                params.push("placementIds", f.to_string());
62331            }
62332        }
62333        if let Some(value) = self._campaign_id.as_ref() {
62334            params.push("campaignId", value.to_string());
62335        }
62336
62337        params.extend(self._additional_params.iter());
62338
62339        params.push("alt", "json");
62340        let mut url =
62341            self.hub._base_url.clone() + "userprofiles/{profileId}/placements/generatetags";
62342        if self._scopes.is_empty() {
62343            self._scopes
62344                .insert(Scope::Dfatrafficking.as_ref().to_string());
62345        }
62346
62347        #[allow(clippy::single_element_loop)]
62348        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
62349            url = params.uri_replacement(url, param_name, find_this, false);
62350        }
62351        {
62352            let to_remove = ["profileId"];
62353            params.remove_params(&to_remove);
62354        }
62355
62356        let url = params.parse_with_url(&url);
62357
62358        loop {
62359            let token = match self
62360                .hub
62361                .auth
62362                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
62363                .await
62364            {
62365                Ok(token) => token,
62366                Err(e) => match dlg.token(e) {
62367                    Ok(token) => token,
62368                    Err(e) => {
62369                        dlg.finished(false);
62370                        return Err(common::Error::MissingToken(e));
62371                    }
62372                },
62373            };
62374            let mut req_result = {
62375                let client = &self.hub.client;
62376                dlg.pre_request();
62377                let mut req_builder = hyper::Request::builder()
62378                    .method(hyper::Method::POST)
62379                    .uri(url.as_str())
62380                    .header(USER_AGENT, self.hub._user_agent.clone());
62381
62382                if let Some(token) = token.as_ref() {
62383                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
62384                }
62385
62386                let request = req_builder
62387                    .header(CONTENT_LENGTH, 0_u64)
62388                    .body(common::to_body::<String>(None));
62389
62390                client.request(request.unwrap()).await
62391            };
62392
62393            match req_result {
62394                Err(err) => {
62395                    if let common::Retry::After(d) = dlg.http_error(&err) {
62396                        sleep(d).await;
62397                        continue;
62398                    }
62399                    dlg.finished(false);
62400                    return Err(common::Error::HttpError(err));
62401                }
62402                Ok(res) => {
62403                    let (mut parts, body) = res.into_parts();
62404                    let mut body = common::Body::new(body);
62405                    if !parts.status.is_success() {
62406                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62407                        let error = serde_json::from_str(&common::to_string(&bytes));
62408                        let response = common::to_response(parts, bytes.into());
62409
62410                        if let common::Retry::After(d) =
62411                            dlg.http_failure(&response, error.as_ref().ok())
62412                        {
62413                            sleep(d).await;
62414                            continue;
62415                        }
62416
62417                        dlg.finished(false);
62418
62419                        return Err(match error {
62420                            Ok(value) => common::Error::BadRequest(value),
62421                            _ => common::Error::Failure(response),
62422                        });
62423                    }
62424                    let response = {
62425                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62426                        let encoded = common::to_string(&bytes);
62427                        match serde_json::from_str(&encoded) {
62428                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
62429                            Err(error) => {
62430                                dlg.response_json_decode_error(&encoded, &error);
62431                                return Err(common::Error::JsonDecodeError(
62432                                    encoded.to_string(),
62433                                    error,
62434                                ));
62435                            }
62436                        }
62437                    };
62438
62439                    dlg.finished(true);
62440                    return Ok(response);
62441                }
62442            }
62443        }
62444    }
62445
62446    /// User profile ID associated with this request.
62447    ///
62448    /// Sets the *profile id* path property to the given value.
62449    ///
62450    /// Even though the property as already been set when instantiating this call,
62451    /// we provide this method for API completeness.
62452    pub fn profile_id(mut self, new_value: i64) -> PlacementGeneratetagCall<'a, C> {
62453        self._profile_id = new_value;
62454        self
62455    }
62456    /// Tag formats to generate for these placements.
62457    ///
62458    /// Note: PLACEMENT_TAG_STANDARD can only be generated for 1x1 placements.
62459    ///
62460    /// Append the given value to the *tag formats* query property.
62461    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
62462    pub fn add_tag_formats(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, C> {
62463        self._tag_formats.push(new_value.to_string());
62464        self
62465    }
62466    /// Generate tags for these placements.
62467    ///
62468    /// Append the given value to the *placement ids* query property.
62469    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
62470    pub fn add_placement_ids(mut self, new_value: i64) -> PlacementGeneratetagCall<'a, C> {
62471        self._placement_ids.push(new_value);
62472        self
62473    }
62474    /// Generate placements belonging to this campaign. This is a required field.
62475    ///
62476    /// Sets the *campaign id* query property to the given value.
62477    pub fn campaign_id(mut self, new_value: i64) -> PlacementGeneratetagCall<'a, C> {
62478        self._campaign_id = Some(new_value);
62479        self
62480    }
62481    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
62482    /// while executing the actual API request.
62483    ///
62484    /// ````text
62485    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
62486    /// ````
62487    ///
62488    /// Sets the *delegate* property to the given value.
62489    pub fn delegate(
62490        mut self,
62491        new_value: &'a mut dyn common::Delegate,
62492    ) -> PlacementGeneratetagCall<'a, C> {
62493        self._delegate = Some(new_value);
62494        self
62495    }
62496
62497    /// Set any additional parameter of the query string used in the request.
62498    /// It should be used to set parameters which are not yet available through their own
62499    /// setters.
62500    ///
62501    /// Please note that this method must not be used to set any of the known parameters
62502    /// which have their own setter method. If done anyway, the request will fail.
62503    ///
62504    /// # Additional Parameters
62505    ///
62506    /// * *alt* (query-string) - Data format for the response.
62507    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
62508    /// * *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.
62509    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
62510    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
62511    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
62512    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
62513    pub fn param<T>(mut self, name: T, value: T) -> PlacementGeneratetagCall<'a, C>
62514    where
62515        T: AsRef<str>,
62516    {
62517        self._additional_params
62518            .insert(name.as_ref().to_string(), value.as_ref().to_string());
62519        self
62520    }
62521
62522    /// Identifies the authorization scope for the method you are building.
62523    ///
62524    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
62525    /// [`Scope::Dfatrafficking`].
62526    ///
62527    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
62528    /// tokens for more than one scope.
62529    ///
62530    /// Usually there is more than one suitable scope to authorize an operation, some of which may
62531    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
62532    /// sufficient, a read-write scope will do as well.
62533    pub fn add_scope<St>(mut self, scope: St) -> PlacementGeneratetagCall<'a, C>
62534    where
62535        St: AsRef<str>,
62536    {
62537        self._scopes.insert(String::from(scope.as_ref()));
62538        self
62539    }
62540    /// Identifies the authorization scope(s) for the method you are building.
62541    ///
62542    /// See [`Self::add_scope()`] for details.
62543    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGeneratetagCall<'a, C>
62544    where
62545        I: IntoIterator<Item = St>,
62546        St: AsRef<str>,
62547    {
62548        self._scopes
62549            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
62550        self
62551    }
62552
62553    /// Removes all scopes, and no default scope will be used either.
62554    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
62555    /// for details).
62556    pub fn clear_scopes(mut self) -> PlacementGeneratetagCall<'a, C> {
62557        self._scopes.clear();
62558        self
62559    }
62560}
62561
62562/// Gets one placement by ID.
62563///
62564/// A builder for the *get* method supported by a *placement* resource.
62565/// It is not used directly, but through a [`PlacementMethods`] instance.
62566///
62567/// # Example
62568///
62569/// Instantiate a resource method builder
62570///
62571/// ```test_harness,no_run
62572/// # extern crate hyper;
62573/// # extern crate hyper_rustls;
62574/// # extern crate google_dfareporting3d2 as dfareporting3d2;
62575/// # async fn dox() {
62576/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
62577///
62578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
62579/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
62580/// #     secret,
62581/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
62582/// # ).build().await.unwrap();
62583///
62584/// # let client = hyper_util::client::legacy::Client::builder(
62585/// #     hyper_util::rt::TokioExecutor::new()
62586/// # )
62587/// # .build(
62588/// #     hyper_rustls::HttpsConnectorBuilder::new()
62589/// #         .with_native_roots()
62590/// #         .unwrap()
62591/// #         .https_or_http()
62592/// #         .enable_http1()
62593/// #         .build()
62594/// # );
62595/// # let mut hub = Dfareporting::new(client, auth);
62596/// // You can configure optional parameters by calling the respective setters at will, and
62597/// // execute the final call using `doit()`.
62598/// // Values shown here are possibly random and not representative !
62599/// let result = hub.placements().get(-28, -53)
62600///              .doit().await;
62601/// # }
62602/// ```
62603pub struct PlacementGetCall<'a, C>
62604where
62605    C: 'a,
62606{
62607    hub: &'a Dfareporting<C>,
62608    _profile_id: i64,
62609    _id: i64,
62610    _delegate: Option<&'a mut dyn common::Delegate>,
62611    _additional_params: HashMap<String, String>,
62612    _scopes: BTreeSet<String>,
62613}
62614
62615impl<'a, C> common::CallBuilder for PlacementGetCall<'a, C> {}
62616
62617impl<'a, C> PlacementGetCall<'a, C>
62618where
62619    C: common::Connector,
62620{
62621    /// Perform the operation you have build so far.
62622    pub async fn doit(mut self) -> common::Result<(common::Response, Placement)> {
62623        use std::borrow::Cow;
62624        use std::io::{Read, Seek};
62625
62626        use common::{url::Params, ToParts};
62627        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
62628
62629        let mut dd = common::DefaultDelegate;
62630        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
62631        dlg.begin(common::MethodInfo {
62632            id: "dfareporting.placements.get",
62633            http_method: hyper::Method::GET,
62634        });
62635
62636        for &field in ["alt", "profileId", "id"].iter() {
62637            if self._additional_params.contains_key(field) {
62638                dlg.finished(false);
62639                return Err(common::Error::FieldClash(field));
62640            }
62641        }
62642
62643        let mut params = Params::with_capacity(4 + self._additional_params.len());
62644        params.push("profileId", self._profile_id.to_string());
62645        params.push("id", self._id.to_string());
62646
62647        params.extend(self._additional_params.iter());
62648
62649        params.push("alt", "json");
62650        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements/{id}";
62651        if self._scopes.is_empty() {
62652            self._scopes
62653                .insert(Scope::Dfatrafficking.as_ref().to_string());
62654        }
62655
62656        #[allow(clippy::single_element_loop)]
62657        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
62658            url = params.uri_replacement(url, param_name, find_this, false);
62659        }
62660        {
62661            let to_remove = ["id", "profileId"];
62662            params.remove_params(&to_remove);
62663        }
62664
62665        let url = params.parse_with_url(&url);
62666
62667        loop {
62668            let token = match self
62669                .hub
62670                .auth
62671                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
62672                .await
62673            {
62674                Ok(token) => token,
62675                Err(e) => match dlg.token(e) {
62676                    Ok(token) => token,
62677                    Err(e) => {
62678                        dlg.finished(false);
62679                        return Err(common::Error::MissingToken(e));
62680                    }
62681                },
62682            };
62683            let mut req_result = {
62684                let client = &self.hub.client;
62685                dlg.pre_request();
62686                let mut req_builder = hyper::Request::builder()
62687                    .method(hyper::Method::GET)
62688                    .uri(url.as_str())
62689                    .header(USER_AGENT, self.hub._user_agent.clone());
62690
62691                if let Some(token) = token.as_ref() {
62692                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
62693                }
62694
62695                let request = req_builder
62696                    .header(CONTENT_LENGTH, 0_u64)
62697                    .body(common::to_body::<String>(None));
62698
62699                client.request(request.unwrap()).await
62700            };
62701
62702            match req_result {
62703                Err(err) => {
62704                    if let common::Retry::After(d) = dlg.http_error(&err) {
62705                        sleep(d).await;
62706                        continue;
62707                    }
62708                    dlg.finished(false);
62709                    return Err(common::Error::HttpError(err));
62710                }
62711                Ok(res) => {
62712                    let (mut parts, body) = res.into_parts();
62713                    let mut body = common::Body::new(body);
62714                    if !parts.status.is_success() {
62715                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62716                        let error = serde_json::from_str(&common::to_string(&bytes));
62717                        let response = common::to_response(parts, bytes.into());
62718
62719                        if let common::Retry::After(d) =
62720                            dlg.http_failure(&response, error.as_ref().ok())
62721                        {
62722                            sleep(d).await;
62723                            continue;
62724                        }
62725
62726                        dlg.finished(false);
62727
62728                        return Err(match error {
62729                            Ok(value) => common::Error::BadRequest(value),
62730                            _ => common::Error::Failure(response),
62731                        });
62732                    }
62733                    let response = {
62734                        let bytes = common::to_bytes(body).await.unwrap_or_default();
62735                        let encoded = common::to_string(&bytes);
62736                        match serde_json::from_str(&encoded) {
62737                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
62738                            Err(error) => {
62739                                dlg.response_json_decode_error(&encoded, &error);
62740                                return Err(common::Error::JsonDecodeError(
62741                                    encoded.to_string(),
62742                                    error,
62743                                ));
62744                            }
62745                        }
62746                    };
62747
62748                    dlg.finished(true);
62749                    return Ok(response);
62750                }
62751            }
62752        }
62753    }
62754
62755    /// User profile ID associated with this request.
62756    ///
62757    /// Sets the *profile id* path property to the given value.
62758    ///
62759    /// Even though the property as already been set when instantiating this call,
62760    /// we provide this method for API completeness.
62761    pub fn profile_id(mut self, new_value: i64) -> PlacementGetCall<'a, C> {
62762        self._profile_id = new_value;
62763        self
62764    }
62765    /// Placement ID.
62766    ///
62767    /// Sets the *id* path property to the given value.
62768    ///
62769    /// Even though the property as already been set when instantiating this call,
62770    /// we provide this method for API completeness.
62771    pub fn id(mut self, new_value: i64) -> PlacementGetCall<'a, C> {
62772        self._id = new_value;
62773        self
62774    }
62775    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
62776    /// while executing the actual API request.
62777    ///
62778    /// ````text
62779    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
62780    /// ````
62781    ///
62782    /// Sets the *delegate* property to the given value.
62783    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PlacementGetCall<'a, C> {
62784        self._delegate = Some(new_value);
62785        self
62786    }
62787
62788    /// Set any additional parameter of the query string used in the request.
62789    /// It should be used to set parameters which are not yet available through their own
62790    /// setters.
62791    ///
62792    /// Please note that this method must not be used to set any of the known parameters
62793    /// which have their own setter method. If done anyway, the request will fail.
62794    ///
62795    /// # Additional Parameters
62796    ///
62797    /// * *alt* (query-string) - Data format for the response.
62798    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
62799    /// * *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.
62800    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
62801    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
62802    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
62803    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
62804    pub fn param<T>(mut self, name: T, value: T) -> PlacementGetCall<'a, C>
62805    where
62806        T: AsRef<str>,
62807    {
62808        self._additional_params
62809            .insert(name.as_ref().to_string(), value.as_ref().to_string());
62810        self
62811    }
62812
62813    /// Identifies the authorization scope for the method you are building.
62814    ///
62815    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
62816    /// [`Scope::Dfatrafficking`].
62817    ///
62818    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
62819    /// tokens for more than one scope.
62820    ///
62821    /// Usually there is more than one suitable scope to authorize an operation, some of which may
62822    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
62823    /// sufficient, a read-write scope will do as well.
62824    pub fn add_scope<St>(mut self, scope: St) -> PlacementGetCall<'a, C>
62825    where
62826        St: AsRef<str>,
62827    {
62828        self._scopes.insert(String::from(scope.as_ref()));
62829        self
62830    }
62831    /// Identifies the authorization scope(s) for the method you are building.
62832    ///
62833    /// See [`Self::add_scope()`] for details.
62834    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementGetCall<'a, C>
62835    where
62836        I: IntoIterator<Item = St>,
62837        St: AsRef<str>,
62838    {
62839        self._scopes
62840            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
62841        self
62842    }
62843
62844    /// Removes all scopes, and no default scope will be used either.
62845    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
62846    /// for details).
62847    pub fn clear_scopes(mut self) -> PlacementGetCall<'a, C> {
62848        self._scopes.clear();
62849        self
62850    }
62851}
62852
62853/// Inserts a new placement.
62854///
62855/// A builder for the *insert* method supported by a *placement* resource.
62856/// It is not used directly, but through a [`PlacementMethods`] instance.
62857///
62858/// # Example
62859///
62860/// Instantiate a resource method builder
62861///
62862/// ```test_harness,no_run
62863/// # extern crate hyper;
62864/// # extern crate hyper_rustls;
62865/// # extern crate google_dfareporting3d2 as dfareporting3d2;
62866/// use dfareporting3d2::api::Placement;
62867/// # async fn dox() {
62868/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
62869///
62870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
62871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
62872/// #     secret,
62873/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
62874/// # ).build().await.unwrap();
62875///
62876/// # let client = hyper_util::client::legacy::Client::builder(
62877/// #     hyper_util::rt::TokioExecutor::new()
62878/// # )
62879/// # .build(
62880/// #     hyper_rustls::HttpsConnectorBuilder::new()
62881/// #         .with_native_roots()
62882/// #         .unwrap()
62883/// #         .https_or_http()
62884/// #         .enable_http1()
62885/// #         .build()
62886/// # );
62887/// # let mut hub = Dfareporting::new(client, auth);
62888/// // As the method needs a request, you would usually fill it with the desired information
62889/// // into the respective structure. Some of the parts shown here might not be applicable !
62890/// // Values shown here are possibly random and not representative !
62891/// let mut req = Placement::default();
62892///
62893/// // You can configure optional parameters by calling the respective setters at will, and
62894/// // execute the final call using `doit()`.
62895/// // Values shown here are possibly random and not representative !
62896/// let result = hub.placements().insert(req, -8)
62897///              .doit().await;
62898/// # }
62899/// ```
62900pub struct PlacementInsertCall<'a, C>
62901where
62902    C: 'a,
62903{
62904    hub: &'a Dfareporting<C>,
62905    _request: Placement,
62906    _profile_id: i64,
62907    _delegate: Option<&'a mut dyn common::Delegate>,
62908    _additional_params: HashMap<String, String>,
62909    _scopes: BTreeSet<String>,
62910}
62911
62912impl<'a, C> common::CallBuilder for PlacementInsertCall<'a, C> {}
62913
62914impl<'a, C> PlacementInsertCall<'a, C>
62915where
62916    C: common::Connector,
62917{
62918    /// Perform the operation you have build so far.
62919    pub async fn doit(mut self) -> common::Result<(common::Response, Placement)> {
62920        use std::borrow::Cow;
62921        use std::io::{Read, Seek};
62922
62923        use common::{url::Params, ToParts};
62924        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
62925
62926        let mut dd = common::DefaultDelegate;
62927        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
62928        dlg.begin(common::MethodInfo {
62929            id: "dfareporting.placements.insert",
62930            http_method: hyper::Method::POST,
62931        });
62932
62933        for &field in ["alt", "profileId"].iter() {
62934            if self._additional_params.contains_key(field) {
62935                dlg.finished(false);
62936                return Err(common::Error::FieldClash(field));
62937            }
62938        }
62939
62940        let mut params = Params::with_capacity(4 + self._additional_params.len());
62941        params.push("profileId", self._profile_id.to_string());
62942
62943        params.extend(self._additional_params.iter());
62944
62945        params.push("alt", "json");
62946        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements";
62947        if self._scopes.is_empty() {
62948            self._scopes
62949                .insert(Scope::Dfatrafficking.as_ref().to_string());
62950        }
62951
62952        #[allow(clippy::single_element_loop)]
62953        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
62954            url = params.uri_replacement(url, param_name, find_this, false);
62955        }
62956        {
62957            let to_remove = ["profileId"];
62958            params.remove_params(&to_remove);
62959        }
62960
62961        let url = params.parse_with_url(&url);
62962
62963        let mut json_mime_type = mime::APPLICATION_JSON;
62964        let mut request_value_reader = {
62965            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
62966            common::remove_json_null_values(&mut value);
62967            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
62968            serde_json::to_writer(&mut dst, &value).unwrap();
62969            dst
62970        };
62971        let request_size = request_value_reader
62972            .seek(std::io::SeekFrom::End(0))
62973            .unwrap();
62974        request_value_reader
62975            .seek(std::io::SeekFrom::Start(0))
62976            .unwrap();
62977
62978        loop {
62979            let token = match self
62980                .hub
62981                .auth
62982                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
62983                .await
62984            {
62985                Ok(token) => token,
62986                Err(e) => match dlg.token(e) {
62987                    Ok(token) => token,
62988                    Err(e) => {
62989                        dlg.finished(false);
62990                        return Err(common::Error::MissingToken(e));
62991                    }
62992                },
62993            };
62994            request_value_reader
62995                .seek(std::io::SeekFrom::Start(0))
62996                .unwrap();
62997            let mut req_result = {
62998                let client = &self.hub.client;
62999                dlg.pre_request();
63000                let mut req_builder = hyper::Request::builder()
63001                    .method(hyper::Method::POST)
63002                    .uri(url.as_str())
63003                    .header(USER_AGENT, self.hub._user_agent.clone());
63004
63005                if let Some(token) = token.as_ref() {
63006                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
63007                }
63008
63009                let request = req_builder
63010                    .header(CONTENT_TYPE, json_mime_type.to_string())
63011                    .header(CONTENT_LENGTH, request_size as u64)
63012                    .body(common::to_body(
63013                        request_value_reader.get_ref().clone().into(),
63014                    ));
63015
63016                client.request(request.unwrap()).await
63017            };
63018
63019            match req_result {
63020                Err(err) => {
63021                    if let common::Retry::After(d) = dlg.http_error(&err) {
63022                        sleep(d).await;
63023                        continue;
63024                    }
63025                    dlg.finished(false);
63026                    return Err(common::Error::HttpError(err));
63027                }
63028                Ok(res) => {
63029                    let (mut parts, body) = res.into_parts();
63030                    let mut body = common::Body::new(body);
63031                    if !parts.status.is_success() {
63032                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63033                        let error = serde_json::from_str(&common::to_string(&bytes));
63034                        let response = common::to_response(parts, bytes.into());
63035
63036                        if let common::Retry::After(d) =
63037                            dlg.http_failure(&response, error.as_ref().ok())
63038                        {
63039                            sleep(d).await;
63040                            continue;
63041                        }
63042
63043                        dlg.finished(false);
63044
63045                        return Err(match error {
63046                            Ok(value) => common::Error::BadRequest(value),
63047                            _ => common::Error::Failure(response),
63048                        });
63049                    }
63050                    let response = {
63051                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63052                        let encoded = common::to_string(&bytes);
63053                        match serde_json::from_str(&encoded) {
63054                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
63055                            Err(error) => {
63056                                dlg.response_json_decode_error(&encoded, &error);
63057                                return Err(common::Error::JsonDecodeError(
63058                                    encoded.to_string(),
63059                                    error,
63060                                ));
63061                            }
63062                        }
63063                    };
63064
63065                    dlg.finished(true);
63066                    return Ok(response);
63067                }
63068            }
63069        }
63070    }
63071
63072    ///
63073    /// Sets the *request* property to the given value.
63074    ///
63075    /// Even though the property as already been set when instantiating this call,
63076    /// we provide this method for API completeness.
63077    pub fn request(mut self, new_value: Placement) -> PlacementInsertCall<'a, C> {
63078        self._request = new_value;
63079        self
63080    }
63081    /// User profile ID associated with this request.
63082    ///
63083    /// Sets the *profile id* path property to the given value.
63084    ///
63085    /// Even though the property as already been set when instantiating this call,
63086    /// we provide this method for API completeness.
63087    pub fn profile_id(mut self, new_value: i64) -> PlacementInsertCall<'a, C> {
63088        self._profile_id = new_value;
63089        self
63090    }
63091    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
63092    /// while executing the actual API request.
63093    ///
63094    /// ````text
63095    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
63096    /// ````
63097    ///
63098    /// Sets the *delegate* property to the given value.
63099    pub fn delegate(
63100        mut self,
63101        new_value: &'a mut dyn common::Delegate,
63102    ) -> PlacementInsertCall<'a, C> {
63103        self._delegate = Some(new_value);
63104        self
63105    }
63106
63107    /// Set any additional parameter of the query string used in the request.
63108    /// It should be used to set parameters which are not yet available through their own
63109    /// setters.
63110    ///
63111    /// Please note that this method must not be used to set any of the known parameters
63112    /// which have their own setter method. If done anyway, the request will fail.
63113    ///
63114    /// # Additional Parameters
63115    ///
63116    /// * *alt* (query-string) - Data format for the response.
63117    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
63118    /// * *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.
63119    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
63120    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
63121    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
63122    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
63123    pub fn param<T>(mut self, name: T, value: T) -> PlacementInsertCall<'a, C>
63124    where
63125        T: AsRef<str>,
63126    {
63127        self._additional_params
63128            .insert(name.as_ref().to_string(), value.as_ref().to_string());
63129        self
63130    }
63131
63132    /// Identifies the authorization scope for the method you are building.
63133    ///
63134    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
63135    /// [`Scope::Dfatrafficking`].
63136    ///
63137    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
63138    /// tokens for more than one scope.
63139    ///
63140    /// Usually there is more than one suitable scope to authorize an operation, some of which may
63141    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
63142    /// sufficient, a read-write scope will do as well.
63143    pub fn add_scope<St>(mut self, scope: St) -> PlacementInsertCall<'a, C>
63144    where
63145        St: AsRef<str>,
63146    {
63147        self._scopes.insert(String::from(scope.as_ref()));
63148        self
63149    }
63150    /// Identifies the authorization scope(s) for the method you are building.
63151    ///
63152    /// See [`Self::add_scope()`] for details.
63153    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementInsertCall<'a, C>
63154    where
63155        I: IntoIterator<Item = St>,
63156        St: AsRef<str>,
63157    {
63158        self._scopes
63159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
63160        self
63161    }
63162
63163    /// Removes all scopes, and no default scope will be used either.
63164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
63165    /// for details).
63166    pub fn clear_scopes(mut self) -> PlacementInsertCall<'a, C> {
63167        self._scopes.clear();
63168        self
63169    }
63170}
63171
63172/// Retrieves a list of placements, possibly filtered. This method supports paging.
63173///
63174/// A builder for the *list* method supported by a *placement* resource.
63175/// It is not used directly, but through a [`PlacementMethods`] instance.
63176///
63177/// # Example
63178///
63179/// Instantiate a resource method builder
63180///
63181/// ```test_harness,no_run
63182/// # extern crate hyper;
63183/// # extern crate hyper_rustls;
63184/// # extern crate google_dfareporting3d2 as dfareporting3d2;
63185/// # async fn dox() {
63186/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
63187///
63188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
63189/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63190/// #     secret,
63191/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
63192/// # ).build().await.unwrap();
63193///
63194/// # let client = hyper_util::client::legacy::Client::builder(
63195/// #     hyper_util::rt::TokioExecutor::new()
63196/// # )
63197/// # .build(
63198/// #     hyper_rustls::HttpsConnectorBuilder::new()
63199/// #         .with_native_roots()
63200/// #         .unwrap()
63201/// #         .https_or_http()
63202/// #         .enable_http1()
63203/// #         .build()
63204/// # );
63205/// # let mut hub = Dfareporting::new(client, auth);
63206/// // You can configure optional parameters by calling the respective setters at will, and
63207/// // execute the final call using `doit()`.
63208/// // Values shown here are possibly random and not representative !
63209/// let result = hub.placements().list(-50)
63210///              .sort_order("eirmod")
63211///              .sort_field("vero")
63212///              .add_size_ids(-78)
63213///              .add_site_ids(-10)
63214///              .search_string("ipsum")
63215///              .add_pricing_types("sea")
63216///              .add_placement_strategy_ids(-74)
63217///              .payment_source("gubergren")
63218///              .page_token("dolore")
63219///              .min_start_date("ea")
63220///              .min_end_date("elitr")
63221///              .max_start_date("takimata")
63222///              .max_results(-70)
63223///              .max_end_date("tempor")
63224///              .add_ids(-64)
63225///              .add_group_ids(-30)
63226///              .add_directory_site_ids(-61)
63227///              .add_content_category_ids(-65)
63228///              .add_compatibilities("sea")
63229///              .add_campaign_ids(-64)
63230///              .archived(false)
63231///              .add_advertiser_ids(-69)
63232///              .doit().await;
63233/// # }
63234/// ```
63235pub struct PlacementListCall<'a, C>
63236where
63237    C: 'a,
63238{
63239    hub: &'a Dfareporting<C>,
63240    _profile_id: i64,
63241    _sort_order: Option<String>,
63242    _sort_field: Option<String>,
63243    _size_ids: Vec<i64>,
63244    _site_ids: Vec<i64>,
63245    _search_string: Option<String>,
63246    _pricing_types: Vec<String>,
63247    _placement_strategy_ids: Vec<i64>,
63248    _payment_source: Option<String>,
63249    _page_token: Option<String>,
63250    _min_start_date: Option<String>,
63251    _min_end_date: Option<String>,
63252    _max_start_date: Option<String>,
63253    _max_results: Option<i32>,
63254    _max_end_date: Option<String>,
63255    _ids: Vec<i64>,
63256    _group_ids: Vec<i64>,
63257    _directory_site_ids: Vec<i64>,
63258    _content_category_ids: Vec<i64>,
63259    _compatibilities: Vec<String>,
63260    _campaign_ids: Vec<i64>,
63261    _archived: Option<bool>,
63262    _advertiser_ids: Vec<i64>,
63263    _delegate: Option<&'a mut dyn common::Delegate>,
63264    _additional_params: HashMap<String, String>,
63265    _scopes: BTreeSet<String>,
63266}
63267
63268impl<'a, C> common::CallBuilder for PlacementListCall<'a, C> {}
63269
63270impl<'a, C> PlacementListCall<'a, C>
63271where
63272    C: common::Connector,
63273{
63274    /// Perform the operation you have build so far.
63275    pub async fn doit(mut self) -> common::Result<(common::Response, PlacementsListResponse)> {
63276        use std::borrow::Cow;
63277        use std::io::{Read, Seek};
63278
63279        use common::{url::Params, ToParts};
63280        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
63281
63282        let mut dd = common::DefaultDelegate;
63283        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
63284        dlg.begin(common::MethodInfo {
63285            id: "dfareporting.placements.list",
63286            http_method: hyper::Method::GET,
63287        });
63288
63289        for &field in [
63290            "alt",
63291            "profileId",
63292            "sortOrder",
63293            "sortField",
63294            "sizeIds",
63295            "siteIds",
63296            "searchString",
63297            "pricingTypes",
63298            "placementStrategyIds",
63299            "paymentSource",
63300            "pageToken",
63301            "minStartDate",
63302            "minEndDate",
63303            "maxStartDate",
63304            "maxResults",
63305            "maxEndDate",
63306            "ids",
63307            "groupIds",
63308            "directorySiteIds",
63309            "contentCategoryIds",
63310            "compatibilities",
63311            "campaignIds",
63312            "archived",
63313            "advertiserIds",
63314        ]
63315        .iter()
63316        {
63317            if self._additional_params.contains_key(field) {
63318                dlg.finished(false);
63319                return Err(common::Error::FieldClash(field));
63320            }
63321        }
63322
63323        let mut params = Params::with_capacity(25 + self._additional_params.len());
63324        params.push("profileId", self._profile_id.to_string());
63325        if let Some(value) = self._sort_order.as_ref() {
63326            params.push("sortOrder", value);
63327        }
63328        if let Some(value) = self._sort_field.as_ref() {
63329            params.push("sortField", value);
63330        }
63331        if !self._size_ids.is_empty() {
63332            for f in self._size_ids.iter() {
63333                params.push("sizeIds", f.to_string());
63334            }
63335        }
63336        if !self._site_ids.is_empty() {
63337            for f in self._site_ids.iter() {
63338                params.push("siteIds", f.to_string());
63339            }
63340        }
63341        if let Some(value) = self._search_string.as_ref() {
63342            params.push("searchString", value);
63343        }
63344        if !self._pricing_types.is_empty() {
63345            for f in self._pricing_types.iter() {
63346                params.push("pricingTypes", f);
63347            }
63348        }
63349        if !self._placement_strategy_ids.is_empty() {
63350            for f in self._placement_strategy_ids.iter() {
63351                params.push("placementStrategyIds", f.to_string());
63352            }
63353        }
63354        if let Some(value) = self._payment_source.as_ref() {
63355            params.push("paymentSource", value);
63356        }
63357        if let Some(value) = self._page_token.as_ref() {
63358            params.push("pageToken", value);
63359        }
63360        if let Some(value) = self._min_start_date.as_ref() {
63361            params.push("minStartDate", value);
63362        }
63363        if let Some(value) = self._min_end_date.as_ref() {
63364            params.push("minEndDate", value);
63365        }
63366        if let Some(value) = self._max_start_date.as_ref() {
63367            params.push("maxStartDate", value);
63368        }
63369        if let Some(value) = self._max_results.as_ref() {
63370            params.push("maxResults", value.to_string());
63371        }
63372        if let Some(value) = self._max_end_date.as_ref() {
63373            params.push("maxEndDate", value);
63374        }
63375        if !self._ids.is_empty() {
63376            for f in self._ids.iter() {
63377                params.push("ids", f.to_string());
63378            }
63379        }
63380        if !self._group_ids.is_empty() {
63381            for f in self._group_ids.iter() {
63382                params.push("groupIds", f.to_string());
63383            }
63384        }
63385        if !self._directory_site_ids.is_empty() {
63386            for f in self._directory_site_ids.iter() {
63387                params.push("directorySiteIds", f.to_string());
63388            }
63389        }
63390        if !self._content_category_ids.is_empty() {
63391            for f in self._content_category_ids.iter() {
63392                params.push("contentCategoryIds", f.to_string());
63393            }
63394        }
63395        if !self._compatibilities.is_empty() {
63396            for f in self._compatibilities.iter() {
63397                params.push("compatibilities", f);
63398            }
63399        }
63400        if !self._campaign_ids.is_empty() {
63401            for f in self._campaign_ids.iter() {
63402                params.push("campaignIds", f.to_string());
63403            }
63404        }
63405        if let Some(value) = self._archived.as_ref() {
63406            params.push("archived", value.to_string());
63407        }
63408        if !self._advertiser_ids.is_empty() {
63409            for f in self._advertiser_ids.iter() {
63410                params.push("advertiserIds", f.to_string());
63411            }
63412        }
63413
63414        params.extend(self._additional_params.iter());
63415
63416        params.push("alt", "json");
63417        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements";
63418        if self._scopes.is_empty() {
63419            self._scopes
63420                .insert(Scope::Dfatrafficking.as_ref().to_string());
63421        }
63422
63423        #[allow(clippy::single_element_loop)]
63424        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
63425            url = params.uri_replacement(url, param_name, find_this, false);
63426        }
63427        {
63428            let to_remove = ["profileId"];
63429            params.remove_params(&to_remove);
63430        }
63431
63432        let url = params.parse_with_url(&url);
63433
63434        loop {
63435            let token = match self
63436                .hub
63437                .auth
63438                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
63439                .await
63440            {
63441                Ok(token) => token,
63442                Err(e) => match dlg.token(e) {
63443                    Ok(token) => token,
63444                    Err(e) => {
63445                        dlg.finished(false);
63446                        return Err(common::Error::MissingToken(e));
63447                    }
63448                },
63449            };
63450            let mut req_result = {
63451                let client = &self.hub.client;
63452                dlg.pre_request();
63453                let mut req_builder = hyper::Request::builder()
63454                    .method(hyper::Method::GET)
63455                    .uri(url.as_str())
63456                    .header(USER_AGENT, self.hub._user_agent.clone());
63457
63458                if let Some(token) = token.as_ref() {
63459                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
63460                }
63461
63462                let request = req_builder
63463                    .header(CONTENT_LENGTH, 0_u64)
63464                    .body(common::to_body::<String>(None));
63465
63466                client.request(request.unwrap()).await
63467            };
63468
63469            match req_result {
63470                Err(err) => {
63471                    if let common::Retry::After(d) = dlg.http_error(&err) {
63472                        sleep(d).await;
63473                        continue;
63474                    }
63475                    dlg.finished(false);
63476                    return Err(common::Error::HttpError(err));
63477                }
63478                Ok(res) => {
63479                    let (mut parts, body) = res.into_parts();
63480                    let mut body = common::Body::new(body);
63481                    if !parts.status.is_success() {
63482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63483                        let error = serde_json::from_str(&common::to_string(&bytes));
63484                        let response = common::to_response(parts, bytes.into());
63485
63486                        if let common::Retry::After(d) =
63487                            dlg.http_failure(&response, error.as_ref().ok())
63488                        {
63489                            sleep(d).await;
63490                            continue;
63491                        }
63492
63493                        dlg.finished(false);
63494
63495                        return Err(match error {
63496                            Ok(value) => common::Error::BadRequest(value),
63497                            _ => common::Error::Failure(response),
63498                        });
63499                    }
63500                    let response = {
63501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63502                        let encoded = common::to_string(&bytes);
63503                        match serde_json::from_str(&encoded) {
63504                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
63505                            Err(error) => {
63506                                dlg.response_json_decode_error(&encoded, &error);
63507                                return Err(common::Error::JsonDecodeError(
63508                                    encoded.to_string(),
63509                                    error,
63510                                ));
63511                            }
63512                        }
63513                    };
63514
63515                    dlg.finished(true);
63516                    return Ok(response);
63517                }
63518            }
63519        }
63520    }
63521
63522    /// User profile ID associated with this request.
63523    ///
63524    /// Sets the *profile id* path property to the given value.
63525    ///
63526    /// Even though the property as already been set when instantiating this call,
63527    /// we provide this method for API completeness.
63528    pub fn profile_id(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63529        self._profile_id = new_value;
63530        self
63531    }
63532    /// Order of sorted results.
63533    ///
63534    /// Sets the *sort order* query property to the given value.
63535    pub fn sort_order(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63536        self._sort_order = Some(new_value.to_string());
63537        self
63538    }
63539    /// Field by which to sort the list.
63540    ///
63541    /// Sets the *sort field* query property to the given value.
63542    pub fn sort_field(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63543        self._sort_field = Some(new_value.to_string());
63544        self
63545    }
63546    /// Select only placements that are associated with these sizes.
63547    ///
63548    /// Append the given value to the *size ids* query property.
63549    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63550    pub fn add_size_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63551        self._size_ids.push(new_value);
63552        self
63553    }
63554    /// Select only placements that are associated with these sites.
63555    ///
63556    /// Append the given value to the *site ids* query property.
63557    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63558    pub fn add_site_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63559        self._site_ids.push(new_value);
63560        self
63561    }
63562    /// Allows searching for placements by name or ID. Wildcards (*) are allowed. For example, "placement*2015" will return placements with names like "placement June 2015", "placement May 2015", or simply "placements 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "placement" will match placements with name "my placement", "placement 2015", or simply "placement".
63563    ///
63564    /// Sets the *search string* query property to the given value.
63565    pub fn search_string(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63566        self._search_string = Some(new_value.to_string());
63567        self
63568    }
63569    /// Select only placements with these pricing types.
63570    ///
63571    /// Append the given value to the *pricing types* query property.
63572    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63573    pub fn add_pricing_types(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63574        self._pricing_types.push(new_value.to_string());
63575        self
63576    }
63577    /// Select only placements that are associated with these placement strategies.
63578    ///
63579    /// Append the given value to the *placement strategy ids* query property.
63580    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63581    pub fn add_placement_strategy_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63582        self._placement_strategy_ids.push(new_value);
63583        self
63584    }
63585    /// Select only placements with this payment source.
63586    ///
63587    /// Sets the *payment source* query property to the given value.
63588    pub fn payment_source(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63589        self._payment_source = Some(new_value.to_string());
63590        self
63591    }
63592    /// Value of the nextPageToken from the previous result page.
63593    ///
63594    /// Sets the *page token* query property to the given value.
63595    pub fn page_token(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63596        self._page_token = Some(new_value.to_string());
63597        self
63598    }
63599    /// Select only placements or placement groups whose start date is on or after the specified minStartDate. The date should be formatted as "yyyy-MM-dd".
63600    ///
63601    /// Sets the *min start date* query property to the given value.
63602    pub fn min_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63603        self._min_start_date = Some(new_value.to_string());
63604        self
63605    }
63606    /// Select only placements or placement groups whose end date is on or after the specified minEndDate. The date should be formatted as "yyyy-MM-dd".
63607    ///
63608    /// Sets the *min end date* query property to the given value.
63609    pub fn min_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63610        self._min_end_date = Some(new_value.to_string());
63611        self
63612    }
63613    /// Select only placements or placement groups whose start date is on or before the specified maxStartDate. The date should be formatted as "yyyy-MM-dd".
63614    ///
63615    /// Sets the *max start date* query property to the given value.
63616    pub fn max_start_date(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63617        self._max_start_date = Some(new_value.to_string());
63618        self
63619    }
63620    /// Maximum number of results to return.
63621    ///
63622    /// Sets the *max results* query property to the given value.
63623    pub fn max_results(mut self, new_value: i32) -> PlacementListCall<'a, C> {
63624        self._max_results = Some(new_value);
63625        self
63626    }
63627    /// Select only placements or placement groups whose end date is on or before the specified maxEndDate. The date should be formatted as "yyyy-MM-dd".
63628    ///
63629    /// Sets the *max end date* query property to the given value.
63630    pub fn max_end_date(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63631        self._max_end_date = Some(new_value.to_string());
63632        self
63633    }
63634    /// Select only placements with these IDs.
63635    ///
63636    /// Append the given value to the *ids* query property.
63637    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63638    pub fn add_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63639        self._ids.push(new_value);
63640        self
63641    }
63642    /// Select only placements that belong to these placement groups.
63643    ///
63644    /// Append the given value to the *group ids* query property.
63645    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63646    pub fn add_group_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63647        self._group_ids.push(new_value);
63648        self
63649    }
63650    /// Select only placements that are associated with these directory sites.
63651    ///
63652    /// Append the given value to the *directory site ids* query property.
63653    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63654    pub fn add_directory_site_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63655        self._directory_site_ids.push(new_value);
63656        self
63657    }
63658    /// Select only placements that are associated with these content categories.
63659    ///
63660    /// Append the given value to the *content category ids* query property.
63661    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63662    pub fn add_content_category_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63663        self._content_category_ids.push(new_value);
63664        self
63665    }
63666    /// Select only placements that are associated with these compatibilities. DISPLAY and DISPLAY_INTERSTITIAL refer to rendering either on desktop or on mobile devices for regular or interstitial ads respectively. APP and APP_INTERSTITIAL are for rendering in mobile apps. IN_STREAM_VIDEO refers to rendering in in-stream video ads developed with the VAST standard.
63667    ///
63668    /// Append the given value to the *compatibilities* query property.
63669    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63670    pub fn add_compatibilities(mut self, new_value: &str) -> PlacementListCall<'a, C> {
63671        self._compatibilities.push(new_value.to_string());
63672        self
63673    }
63674    /// Select only placements that belong to these campaigns.
63675    ///
63676    /// Append the given value to the *campaign ids* query property.
63677    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63678    pub fn add_campaign_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63679        self._campaign_ids.push(new_value);
63680        self
63681    }
63682    /// Select only archived placements. Don't set this field to select both archived and non-archived placements.
63683    ///
63684    /// Sets the *archived* query property to the given value.
63685    pub fn archived(mut self, new_value: bool) -> PlacementListCall<'a, C> {
63686        self._archived = Some(new_value);
63687        self
63688    }
63689    /// Select only placements that belong to these advertisers.
63690    ///
63691    /// Append the given value to the *advertiser ids* query property.
63692    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
63693    pub fn add_advertiser_ids(mut self, new_value: i64) -> PlacementListCall<'a, C> {
63694        self._advertiser_ids.push(new_value);
63695        self
63696    }
63697    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
63698    /// while executing the actual API request.
63699    ///
63700    /// ````text
63701    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
63702    /// ````
63703    ///
63704    /// Sets the *delegate* property to the given value.
63705    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PlacementListCall<'a, C> {
63706        self._delegate = Some(new_value);
63707        self
63708    }
63709
63710    /// Set any additional parameter of the query string used in the request.
63711    /// It should be used to set parameters which are not yet available through their own
63712    /// setters.
63713    ///
63714    /// Please note that this method must not be used to set any of the known parameters
63715    /// which have their own setter method. If done anyway, the request will fail.
63716    ///
63717    /// # Additional Parameters
63718    ///
63719    /// * *alt* (query-string) - Data format for the response.
63720    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
63721    /// * *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.
63722    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
63723    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
63724    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
63725    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
63726    pub fn param<T>(mut self, name: T, value: T) -> PlacementListCall<'a, C>
63727    where
63728        T: AsRef<str>,
63729    {
63730        self._additional_params
63731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
63732        self
63733    }
63734
63735    /// Identifies the authorization scope for the method you are building.
63736    ///
63737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
63738    /// [`Scope::Dfatrafficking`].
63739    ///
63740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
63741    /// tokens for more than one scope.
63742    ///
63743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
63744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
63745    /// sufficient, a read-write scope will do as well.
63746    pub fn add_scope<St>(mut self, scope: St) -> PlacementListCall<'a, C>
63747    where
63748        St: AsRef<str>,
63749    {
63750        self._scopes.insert(String::from(scope.as_ref()));
63751        self
63752    }
63753    /// Identifies the authorization scope(s) for the method you are building.
63754    ///
63755    /// See [`Self::add_scope()`] for details.
63756    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementListCall<'a, C>
63757    where
63758        I: IntoIterator<Item = St>,
63759        St: AsRef<str>,
63760    {
63761        self._scopes
63762            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
63763        self
63764    }
63765
63766    /// Removes all scopes, and no default scope will be used either.
63767    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
63768    /// for details).
63769    pub fn clear_scopes(mut self) -> PlacementListCall<'a, C> {
63770        self._scopes.clear();
63771        self
63772    }
63773}
63774
63775/// Updates an existing placement. This method supports patch semantics.
63776///
63777/// A builder for the *patch* method supported by a *placement* resource.
63778/// It is not used directly, but through a [`PlacementMethods`] instance.
63779///
63780/// # Example
63781///
63782/// Instantiate a resource method builder
63783///
63784/// ```test_harness,no_run
63785/// # extern crate hyper;
63786/// # extern crate hyper_rustls;
63787/// # extern crate google_dfareporting3d2 as dfareporting3d2;
63788/// use dfareporting3d2::api::Placement;
63789/// # async fn dox() {
63790/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
63791///
63792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
63793/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63794/// #     secret,
63795/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
63796/// # ).build().await.unwrap();
63797///
63798/// # let client = hyper_util::client::legacy::Client::builder(
63799/// #     hyper_util::rt::TokioExecutor::new()
63800/// # )
63801/// # .build(
63802/// #     hyper_rustls::HttpsConnectorBuilder::new()
63803/// #         .with_native_roots()
63804/// #         .unwrap()
63805/// #         .https_or_http()
63806/// #         .enable_http1()
63807/// #         .build()
63808/// # );
63809/// # let mut hub = Dfareporting::new(client, auth);
63810/// // As the method needs a request, you would usually fill it with the desired information
63811/// // into the respective structure. Some of the parts shown here might not be applicable !
63812/// // Values shown here are possibly random and not representative !
63813/// let mut req = Placement::default();
63814///
63815/// // You can configure optional parameters by calling the respective setters at will, and
63816/// // execute the final call using `doit()`.
63817/// // Values shown here are possibly random and not representative !
63818/// let result = hub.placements().patch(req, -48, -60)
63819///              .doit().await;
63820/// # }
63821/// ```
63822pub struct PlacementPatchCall<'a, C>
63823where
63824    C: 'a,
63825{
63826    hub: &'a Dfareporting<C>,
63827    _request: Placement,
63828    _profile_id: i64,
63829    _id: i64,
63830    _delegate: Option<&'a mut dyn common::Delegate>,
63831    _additional_params: HashMap<String, String>,
63832    _scopes: BTreeSet<String>,
63833}
63834
63835impl<'a, C> common::CallBuilder for PlacementPatchCall<'a, C> {}
63836
63837impl<'a, C> PlacementPatchCall<'a, C>
63838where
63839    C: common::Connector,
63840{
63841    /// Perform the operation you have build so far.
63842    pub async fn doit(mut self) -> common::Result<(common::Response, Placement)> {
63843        use std::borrow::Cow;
63844        use std::io::{Read, Seek};
63845
63846        use common::{url::Params, ToParts};
63847        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
63848
63849        let mut dd = common::DefaultDelegate;
63850        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
63851        dlg.begin(common::MethodInfo {
63852            id: "dfareporting.placements.patch",
63853            http_method: hyper::Method::PATCH,
63854        });
63855
63856        for &field in ["alt", "profileId", "id"].iter() {
63857            if self._additional_params.contains_key(field) {
63858                dlg.finished(false);
63859                return Err(common::Error::FieldClash(field));
63860            }
63861        }
63862
63863        let mut params = Params::with_capacity(5 + self._additional_params.len());
63864        params.push("profileId", self._profile_id.to_string());
63865        params.push("id", self._id.to_string());
63866
63867        params.extend(self._additional_params.iter());
63868
63869        params.push("alt", "json");
63870        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements";
63871        if self._scopes.is_empty() {
63872            self._scopes
63873                .insert(Scope::Dfatrafficking.as_ref().to_string());
63874        }
63875
63876        #[allow(clippy::single_element_loop)]
63877        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
63878            url = params.uri_replacement(url, param_name, find_this, false);
63879        }
63880        {
63881            let to_remove = ["profileId"];
63882            params.remove_params(&to_remove);
63883        }
63884
63885        let url = params.parse_with_url(&url);
63886
63887        let mut json_mime_type = mime::APPLICATION_JSON;
63888        let mut request_value_reader = {
63889            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
63890            common::remove_json_null_values(&mut value);
63891            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
63892            serde_json::to_writer(&mut dst, &value).unwrap();
63893            dst
63894        };
63895        let request_size = request_value_reader
63896            .seek(std::io::SeekFrom::End(0))
63897            .unwrap();
63898        request_value_reader
63899            .seek(std::io::SeekFrom::Start(0))
63900            .unwrap();
63901
63902        loop {
63903            let token = match self
63904                .hub
63905                .auth
63906                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
63907                .await
63908            {
63909                Ok(token) => token,
63910                Err(e) => match dlg.token(e) {
63911                    Ok(token) => token,
63912                    Err(e) => {
63913                        dlg.finished(false);
63914                        return Err(common::Error::MissingToken(e));
63915                    }
63916                },
63917            };
63918            request_value_reader
63919                .seek(std::io::SeekFrom::Start(0))
63920                .unwrap();
63921            let mut req_result = {
63922                let client = &self.hub.client;
63923                dlg.pre_request();
63924                let mut req_builder = hyper::Request::builder()
63925                    .method(hyper::Method::PATCH)
63926                    .uri(url.as_str())
63927                    .header(USER_AGENT, self.hub._user_agent.clone());
63928
63929                if let Some(token) = token.as_ref() {
63930                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
63931                }
63932
63933                let request = req_builder
63934                    .header(CONTENT_TYPE, json_mime_type.to_string())
63935                    .header(CONTENT_LENGTH, request_size as u64)
63936                    .body(common::to_body(
63937                        request_value_reader.get_ref().clone().into(),
63938                    ));
63939
63940                client.request(request.unwrap()).await
63941            };
63942
63943            match req_result {
63944                Err(err) => {
63945                    if let common::Retry::After(d) = dlg.http_error(&err) {
63946                        sleep(d).await;
63947                        continue;
63948                    }
63949                    dlg.finished(false);
63950                    return Err(common::Error::HttpError(err));
63951                }
63952                Ok(res) => {
63953                    let (mut parts, body) = res.into_parts();
63954                    let mut body = common::Body::new(body);
63955                    if !parts.status.is_success() {
63956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63957                        let error = serde_json::from_str(&common::to_string(&bytes));
63958                        let response = common::to_response(parts, bytes.into());
63959
63960                        if let common::Retry::After(d) =
63961                            dlg.http_failure(&response, error.as_ref().ok())
63962                        {
63963                            sleep(d).await;
63964                            continue;
63965                        }
63966
63967                        dlg.finished(false);
63968
63969                        return Err(match error {
63970                            Ok(value) => common::Error::BadRequest(value),
63971                            _ => common::Error::Failure(response),
63972                        });
63973                    }
63974                    let response = {
63975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
63976                        let encoded = common::to_string(&bytes);
63977                        match serde_json::from_str(&encoded) {
63978                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
63979                            Err(error) => {
63980                                dlg.response_json_decode_error(&encoded, &error);
63981                                return Err(common::Error::JsonDecodeError(
63982                                    encoded.to_string(),
63983                                    error,
63984                                ));
63985                            }
63986                        }
63987                    };
63988
63989                    dlg.finished(true);
63990                    return Ok(response);
63991                }
63992            }
63993        }
63994    }
63995
63996    ///
63997    /// Sets the *request* property to the given value.
63998    ///
63999    /// Even though the property as already been set when instantiating this call,
64000    /// we provide this method for API completeness.
64001    pub fn request(mut self, new_value: Placement) -> PlacementPatchCall<'a, C> {
64002        self._request = new_value;
64003        self
64004    }
64005    /// User profile ID associated with this request.
64006    ///
64007    /// Sets the *profile id* path property to the given value.
64008    ///
64009    /// Even though the property as already been set when instantiating this call,
64010    /// we provide this method for API completeness.
64011    pub fn profile_id(mut self, new_value: i64) -> PlacementPatchCall<'a, C> {
64012        self._profile_id = new_value;
64013        self
64014    }
64015    /// Placement ID.
64016    ///
64017    /// Sets the *id* query property to the given value.
64018    ///
64019    /// Even though the property as already been set when instantiating this call,
64020    /// we provide this method for API completeness.
64021    pub fn id(mut self, new_value: i64) -> PlacementPatchCall<'a, C> {
64022        self._id = new_value;
64023        self
64024    }
64025    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
64026    /// while executing the actual API request.
64027    ///
64028    /// ````text
64029    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
64030    /// ````
64031    ///
64032    /// Sets the *delegate* property to the given value.
64033    pub fn delegate(
64034        mut self,
64035        new_value: &'a mut dyn common::Delegate,
64036    ) -> PlacementPatchCall<'a, C> {
64037        self._delegate = Some(new_value);
64038        self
64039    }
64040
64041    /// Set any additional parameter of the query string used in the request.
64042    /// It should be used to set parameters which are not yet available through their own
64043    /// setters.
64044    ///
64045    /// Please note that this method must not be used to set any of the known parameters
64046    /// which have their own setter method. If done anyway, the request will fail.
64047    ///
64048    /// # Additional Parameters
64049    ///
64050    /// * *alt* (query-string) - Data format for the response.
64051    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
64052    /// * *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.
64053    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
64054    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
64055    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
64056    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
64057    pub fn param<T>(mut self, name: T, value: T) -> PlacementPatchCall<'a, C>
64058    where
64059        T: AsRef<str>,
64060    {
64061        self._additional_params
64062            .insert(name.as_ref().to_string(), value.as_ref().to_string());
64063        self
64064    }
64065
64066    /// Identifies the authorization scope for the method you are building.
64067    ///
64068    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
64069    /// [`Scope::Dfatrafficking`].
64070    ///
64071    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
64072    /// tokens for more than one scope.
64073    ///
64074    /// Usually there is more than one suitable scope to authorize an operation, some of which may
64075    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
64076    /// sufficient, a read-write scope will do as well.
64077    pub fn add_scope<St>(mut self, scope: St) -> PlacementPatchCall<'a, C>
64078    where
64079        St: AsRef<str>,
64080    {
64081        self._scopes.insert(String::from(scope.as_ref()));
64082        self
64083    }
64084    /// Identifies the authorization scope(s) for the method you are building.
64085    ///
64086    /// See [`Self::add_scope()`] for details.
64087    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementPatchCall<'a, C>
64088    where
64089        I: IntoIterator<Item = St>,
64090        St: AsRef<str>,
64091    {
64092        self._scopes
64093            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
64094        self
64095    }
64096
64097    /// Removes all scopes, and no default scope will be used either.
64098    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
64099    /// for details).
64100    pub fn clear_scopes(mut self) -> PlacementPatchCall<'a, C> {
64101        self._scopes.clear();
64102        self
64103    }
64104}
64105
64106/// Updates an existing placement.
64107///
64108/// A builder for the *update* method supported by a *placement* resource.
64109/// It is not used directly, but through a [`PlacementMethods`] instance.
64110///
64111/// # Example
64112///
64113/// Instantiate a resource method builder
64114///
64115/// ```test_harness,no_run
64116/// # extern crate hyper;
64117/// # extern crate hyper_rustls;
64118/// # extern crate google_dfareporting3d2 as dfareporting3d2;
64119/// use dfareporting3d2::api::Placement;
64120/// # async fn dox() {
64121/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
64122///
64123/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
64124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
64125/// #     secret,
64126/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
64127/// # ).build().await.unwrap();
64128///
64129/// # let client = hyper_util::client::legacy::Client::builder(
64130/// #     hyper_util::rt::TokioExecutor::new()
64131/// # )
64132/// # .build(
64133/// #     hyper_rustls::HttpsConnectorBuilder::new()
64134/// #         .with_native_roots()
64135/// #         .unwrap()
64136/// #         .https_or_http()
64137/// #         .enable_http1()
64138/// #         .build()
64139/// # );
64140/// # let mut hub = Dfareporting::new(client, auth);
64141/// // As the method needs a request, you would usually fill it with the desired information
64142/// // into the respective structure. Some of the parts shown here might not be applicable !
64143/// // Values shown here are possibly random and not representative !
64144/// let mut req = Placement::default();
64145///
64146/// // You can configure optional parameters by calling the respective setters at will, and
64147/// // execute the final call using `doit()`.
64148/// // Values shown here are possibly random and not representative !
64149/// let result = hub.placements().update(req, -58)
64150///              .doit().await;
64151/// # }
64152/// ```
64153pub struct PlacementUpdateCall<'a, C>
64154where
64155    C: 'a,
64156{
64157    hub: &'a Dfareporting<C>,
64158    _request: Placement,
64159    _profile_id: i64,
64160    _delegate: Option<&'a mut dyn common::Delegate>,
64161    _additional_params: HashMap<String, String>,
64162    _scopes: BTreeSet<String>,
64163}
64164
64165impl<'a, C> common::CallBuilder for PlacementUpdateCall<'a, C> {}
64166
64167impl<'a, C> PlacementUpdateCall<'a, C>
64168where
64169    C: common::Connector,
64170{
64171    /// Perform the operation you have build so far.
64172    pub async fn doit(mut self) -> common::Result<(common::Response, Placement)> {
64173        use std::borrow::Cow;
64174        use std::io::{Read, Seek};
64175
64176        use common::{url::Params, ToParts};
64177        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
64178
64179        let mut dd = common::DefaultDelegate;
64180        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
64181        dlg.begin(common::MethodInfo {
64182            id: "dfareporting.placements.update",
64183            http_method: hyper::Method::PUT,
64184        });
64185
64186        for &field in ["alt", "profileId"].iter() {
64187            if self._additional_params.contains_key(field) {
64188                dlg.finished(false);
64189                return Err(common::Error::FieldClash(field));
64190            }
64191        }
64192
64193        let mut params = Params::with_capacity(4 + self._additional_params.len());
64194        params.push("profileId", self._profile_id.to_string());
64195
64196        params.extend(self._additional_params.iter());
64197
64198        params.push("alt", "json");
64199        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements";
64200        if self._scopes.is_empty() {
64201            self._scopes
64202                .insert(Scope::Dfatrafficking.as_ref().to_string());
64203        }
64204
64205        #[allow(clippy::single_element_loop)]
64206        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
64207            url = params.uri_replacement(url, param_name, find_this, false);
64208        }
64209        {
64210            let to_remove = ["profileId"];
64211            params.remove_params(&to_remove);
64212        }
64213
64214        let url = params.parse_with_url(&url);
64215
64216        let mut json_mime_type = mime::APPLICATION_JSON;
64217        let mut request_value_reader = {
64218            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
64219            common::remove_json_null_values(&mut value);
64220            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
64221            serde_json::to_writer(&mut dst, &value).unwrap();
64222            dst
64223        };
64224        let request_size = request_value_reader
64225            .seek(std::io::SeekFrom::End(0))
64226            .unwrap();
64227        request_value_reader
64228            .seek(std::io::SeekFrom::Start(0))
64229            .unwrap();
64230
64231        loop {
64232            let token = match self
64233                .hub
64234                .auth
64235                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
64236                .await
64237            {
64238                Ok(token) => token,
64239                Err(e) => match dlg.token(e) {
64240                    Ok(token) => token,
64241                    Err(e) => {
64242                        dlg.finished(false);
64243                        return Err(common::Error::MissingToken(e));
64244                    }
64245                },
64246            };
64247            request_value_reader
64248                .seek(std::io::SeekFrom::Start(0))
64249                .unwrap();
64250            let mut req_result = {
64251                let client = &self.hub.client;
64252                dlg.pre_request();
64253                let mut req_builder = hyper::Request::builder()
64254                    .method(hyper::Method::PUT)
64255                    .uri(url.as_str())
64256                    .header(USER_AGENT, self.hub._user_agent.clone());
64257
64258                if let Some(token) = token.as_ref() {
64259                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
64260                }
64261
64262                let request = req_builder
64263                    .header(CONTENT_TYPE, json_mime_type.to_string())
64264                    .header(CONTENT_LENGTH, request_size as u64)
64265                    .body(common::to_body(
64266                        request_value_reader.get_ref().clone().into(),
64267                    ));
64268
64269                client.request(request.unwrap()).await
64270            };
64271
64272            match req_result {
64273                Err(err) => {
64274                    if let common::Retry::After(d) = dlg.http_error(&err) {
64275                        sleep(d).await;
64276                        continue;
64277                    }
64278                    dlg.finished(false);
64279                    return Err(common::Error::HttpError(err));
64280                }
64281                Ok(res) => {
64282                    let (mut parts, body) = res.into_parts();
64283                    let mut body = common::Body::new(body);
64284                    if !parts.status.is_success() {
64285                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64286                        let error = serde_json::from_str(&common::to_string(&bytes));
64287                        let response = common::to_response(parts, bytes.into());
64288
64289                        if let common::Retry::After(d) =
64290                            dlg.http_failure(&response, error.as_ref().ok())
64291                        {
64292                            sleep(d).await;
64293                            continue;
64294                        }
64295
64296                        dlg.finished(false);
64297
64298                        return Err(match error {
64299                            Ok(value) => common::Error::BadRequest(value),
64300                            _ => common::Error::Failure(response),
64301                        });
64302                    }
64303                    let response = {
64304                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64305                        let encoded = common::to_string(&bytes);
64306                        match serde_json::from_str(&encoded) {
64307                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
64308                            Err(error) => {
64309                                dlg.response_json_decode_error(&encoded, &error);
64310                                return Err(common::Error::JsonDecodeError(
64311                                    encoded.to_string(),
64312                                    error,
64313                                ));
64314                            }
64315                        }
64316                    };
64317
64318                    dlg.finished(true);
64319                    return Ok(response);
64320                }
64321            }
64322        }
64323    }
64324
64325    ///
64326    /// Sets the *request* property to the given value.
64327    ///
64328    /// Even though the property as already been set when instantiating this call,
64329    /// we provide this method for API completeness.
64330    pub fn request(mut self, new_value: Placement) -> PlacementUpdateCall<'a, C> {
64331        self._request = new_value;
64332        self
64333    }
64334    /// User profile ID associated with this request.
64335    ///
64336    /// Sets the *profile id* path property to the given value.
64337    ///
64338    /// Even though the property as already been set when instantiating this call,
64339    /// we provide this method for API completeness.
64340    pub fn profile_id(mut self, new_value: i64) -> PlacementUpdateCall<'a, C> {
64341        self._profile_id = new_value;
64342        self
64343    }
64344    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
64345    /// while executing the actual API request.
64346    ///
64347    /// ````text
64348    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
64349    /// ````
64350    ///
64351    /// Sets the *delegate* property to the given value.
64352    pub fn delegate(
64353        mut self,
64354        new_value: &'a mut dyn common::Delegate,
64355    ) -> PlacementUpdateCall<'a, C> {
64356        self._delegate = Some(new_value);
64357        self
64358    }
64359
64360    /// Set any additional parameter of the query string used in the request.
64361    /// It should be used to set parameters which are not yet available through their own
64362    /// setters.
64363    ///
64364    /// Please note that this method must not be used to set any of the known parameters
64365    /// which have their own setter method. If done anyway, the request will fail.
64366    ///
64367    /// # Additional Parameters
64368    ///
64369    /// * *alt* (query-string) - Data format for the response.
64370    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
64371    /// * *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.
64372    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
64373    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
64374    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
64375    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
64376    pub fn param<T>(mut self, name: T, value: T) -> PlacementUpdateCall<'a, C>
64377    where
64378        T: AsRef<str>,
64379    {
64380        self._additional_params
64381            .insert(name.as_ref().to_string(), value.as_ref().to_string());
64382        self
64383    }
64384
64385    /// Identifies the authorization scope for the method you are building.
64386    ///
64387    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
64388    /// [`Scope::Dfatrafficking`].
64389    ///
64390    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
64391    /// tokens for more than one scope.
64392    ///
64393    /// Usually there is more than one suitable scope to authorize an operation, some of which may
64394    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
64395    /// sufficient, a read-write scope will do as well.
64396    pub fn add_scope<St>(mut self, scope: St) -> PlacementUpdateCall<'a, C>
64397    where
64398        St: AsRef<str>,
64399    {
64400        self._scopes.insert(String::from(scope.as_ref()));
64401        self
64402    }
64403    /// Identifies the authorization scope(s) for the method you are building.
64404    ///
64405    /// See [`Self::add_scope()`] for details.
64406    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlacementUpdateCall<'a, C>
64407    where
64408        I: IntoIterator<Item = St>,
64409        St: AsRef<str>,
64410    {
64411        self._scopes
64412            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
64413        self
64414    }
64415
64416    /// Removes all scopes, and no default scope will be used either.
64417    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
64418    /// for details).
64419    pub fn clear_scopes(mut self) -> PlacementUpdateCall<'a, C> {
64420        self._scopes.clear();
64421        self
64422    }
64423}
64424
64425/// Gets one platform type by ID.
64426///
64427/// A builder for the *get* method supported by a *platformType* resource.
64428/// It is not used directly, but through a [`PlatformTypeMethods`] instance.
64429///
64430/// # Example
64431///
64432/// Instantiate a resource method builder
64433///
64434/// ```test_harness,no_run
64435/// # extern crate hyper;
64436/// # extern crate hyper_rustls;
64437/// # extern crate google_dfareporting3d2 as dfareporting3d2;
64438/// # async fn dox() {
64439/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
64440///
64441/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
64442/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
64443/// #     secret,
64444/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
64445/// # ).build().await.unwrap();
64446///
64447/// # let client = hyper_util::client::legacy::Client::builder(
64448/// #     hyper_util::rt::TokioExecutor::new()
64449/// # )
64450/// # .build(
64451/// #     hyper_rustls::HttpsConnectorBuilder::new()
64452/// #         .with_native_roots()
64453/// #         .unwrap()
64454/// #         .https_or_http()
64455/// #         .enable_http1()
64456/// #         .build()
64457/// # );
64458/// # let mut hub = Dfareporting::new(client, auth);
64459/// // You can configure optional parameters by calling the respective setters at will, and
64460/// // execute the final call using `doit()`.
64461/// // Values shown here are possibly random and not representative !
64462/// let result = hub.platform_types().get(-13, -90)
64463///              .doit().await;
64464/// # }
64465/// ```
64466pub struct PlatformTypeGetCall<'a, C>
64467where
64468    C: 'a,
64469{
64470    hub: &'a Dfareporting<C>,
64471    _profile_id: i64,
64472    _id: i64,
64473    _delegate: Option<&'a mut dyn common::Delegate>,
64474    _additional_params: HashMap<String, String>,
64475    _scopes: BTreeSet<String>,
64476}
64477
64478impl<'a, C> common::CallBuilder for PlatformTypeGetCall<'a, C> {}
64479
64480impl<'a, C> PlatformTypeGetCall<'a, C>
64481where
64482    C: common::Connector,
64483{
64484    /// Perform the operation you have build so far.
64485    pub async fn doit(mut self) -> common::Result<(common::Response, PlatformType)> {
64486        use std::borrow::Cow;
64487        use std::io::{Read, Seek};
64488
64489        use common::{url::Params, ToParts};
64490        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
64491
64492        let mut dd = common::DefaultDelegate;
64493        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
64494        dlg.begin(common::MethodInfo {
64495            id: "dfareporting.platformTypes.get",
64496            http_method: hyper::Method::GET,
64497        });
64498
64499        for &field in ["alt", "profileId", "id"].iter() {
64500            if self._additional_params.contains_key(field) {
64501                dlg.finished(false);
64502                return Err(common::Error::FieldClash(field));
64503            }
64504        }
64505
64506        let mut params = Params::with_capacity(4 + self._additional_params.len());
64507        params.push("profileId", self._profile_id.to_string());
64508        params.push("id", self._id.to_string());
64509
64510        params.extend(self._additional_params.iter());
64511
64512        params.push("alt", "json");
64513        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/platformTypes/{id}";
64514        if self._scopes.is_empty() {
64515            self._scopes
64516                .insert(Scope::Dfatrafficking.as_ref().to_string());
64517        }
64518
64519        #[allow(clippy::single_element_loop)]
64520        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
64521            url = params.uri_replacement(url, param_name, find_this, false);
64522        }
64523        {
64524            let to_remove = ["id", "profileId"];
64525            params.remove_params(&to_remove);
64526        }
64527
64528        let url = params.parse_with_url(&url);
64529
64530        loop {
64531            let token = match self
64532                .hub
64533                .auth
64534                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
64535                .await
64536            {
64537                Ok(token) => token,
64538                Err(e) => match dlg.token(e) {
64539                    Ok(token) => token,
64540                    Err(e) => {
64541                        dlg.finished(false);
64542                        return Err(common::Error::MissingToken(e));
64543                    }
64544                },
64545            };
64546            let mut req_result = {
64547                let client = &self.hub.client;
64548                dlg.pre_request();
64549                let mut req_builder = hyper::Request::builder()
64550                    .method(hyper::Method::GET)
64551                    .uri(url.as_str())
64552                    .header(USER_AGENT, self.hub._user_agent.clone());
64553
64554                if let Some(token) = token.as_ref() {
64555                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
64556                }
64557
64558                let request = req_builder
64559                    .header(CONTENT_LENGTH, 0_u64)
64560                    .body(common::to_body::<String>(None));
64561
64562                client.request(request.unwrap()).await
64563            };
64564
64565            match req_result {
64566                Err(err) => {
64567                    if let common::Retry::After(d) = dlg.http_error(&err) {
64568                        sleep(d).await;
64569                        continue;
64570                    }
64571                    dlg.finished(false);
64572                    return Err(common::Error::HttpError(err));
64573                }
64574                Ok(res) => {
64575                    let (mut parts, body) = res.into_parts();
64576                    let mut body = common::Body::new(body);
64577                    if !parts.status.is_success() {
64578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64579                        let error = serde_json::from_str(&common::to_string(&bytes));
64580                        let response = common::to_response(parts, bytes.into());
64581
64582                        if let common::Retry::After(d) =
64583                            dlg.http_failure(&response, error.as_ref().ok())
64584                        {
64585                            sleep(d).await;
64586                            continue;
64587                        }
64588
64589                        dlg.finished(false);
64590
64591                        return Err(match error {
64592                            Ok(value) => common::Error::BadRequest(value),
64593                            _ => common::Error::Failure(response),
64594                        });
64595                    }
64596                    let response = {
64597                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64598                        let encoded = common::to_string(&bytes);
64599                        match serde_json::from_str(&encoded) {
64600                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
64601                            Err(error) => {
64602                                dlg.response_json_decode_error(&encoded, &error);
64603                                return Err(common::Error::JsonDecodeError(
64604                                    encoded.to_string(),
64605                                    error,
64606                                ));
64607                            }
64608                        }
64609                    };
64610
64611                    dlg.finished(true);
64612                    return Ok(response);
64613                }
64614            }
64615        }
64616    }
64617
64618    /// User profile ID associated with this request.
64619    ///
64620    /// Sets the *profile id* path property to the given value.
64621    ///
64622    /// Even though the property as already been set when instantiating this call,
64623    /// we provide this method for API completeness.
64624    pub fn profile_id(mut self, new_value: i64) -> PlatformTypeGetCall<'a, C> {
64625        self._profile_id = new_value;
64626        self
64627    }
64628    /// Platform type ID.
64629    ///
64630    /// Sets the *id* path property to the given value.
64631    ///
64632    /// Even though the property as already been set when instantiating this call,
64633    /// we provide this method for API completeness.
64634    pub fn id(mut self, new_value: i64) -> PlatformTypeGetCall<'a, C> {
64635        self._id = new_value;
64636        self
64637    }
64638    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
64639    /// while executing the actual API request.
64640    ///
64641    /// ````text
64642    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
64643    /// ````
64644    ///
64645    /// Sets the *delegate* property to the given value.
64646    pub fn delegate(
64647        mut self,
64648        new_value: &'a mut dyn common::Delegate,
64649    ) -> PlatformTypeGetCall<'a, C> {
64650        self._delegate = Some(new_value);
64651        self
64652    }
64653
64654    /// Set any additional parameter of the query string used in the request.
64655    /// It should be used to set parameters which are not yet available through their own
64656    /// setters.
64657    ///
64658    /// Please note that this method must not be used to set any of the known parameters
64659    /// which have their own setter method. If done anyway, the request will fail.
64660    ///
64661    /// # Additional Parameters
64662    ///
64663    /// * *alt* (query-string) - Data format for the response.
64664    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
64665    /// * *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.
64666    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
64667    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
64668    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
64669    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
64670    pub fn param<T>(mut self, name: T, value: T) -> PlatformTypeGetCall<'a, C>
64671    where
64672        T: AsRef<str>,
64673    {
64674        self._additional_params
64675            .insert(name.as_ref().to_string(), value.as_ref().to_string());
64676        self
64677    }
64678
64679    /// Identifies the authorization scope for the method you are building.
64680    ///
64681    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
64682    /// [`Scope::Dfatrafficking`].
64683    ///
64684    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
64685    /// tokens for more than one scope.
64686    ///
64687    /// Usually there is more than one suitable scope to authorize an operation, some of which may
64688    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
64689    /// sufficient, a read-write scope will do as well.
64690    pub fn add_scope<St>(mut self, scope: St) -> PlatformTypeGetCall<'a, C>
64691    where
64692        St: AsRef<str>,
64693    {
64694        self._scopes.insert(String::from(scope.as_ref()));
64695        self
64696    }
64697    /// Identifies the authorization scope(s) for the method you are building.
64698    ///
64699    /// See [`Self::add_scope()`] for details.
64700    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlatformTypeGetCall<'a, C>
64701    where
64702        I: IntoIterator<Item = St>,
64703        St: AsRef<str>,
64704    {
64705        self._scopes
64706            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
64707        self
64708    }
64709
64710    /// Removes all scopes, and no default scope will be used either.
64711    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
64712    /// for details).
64713    pub fn clear_scopes(mut self) -> PlatformTypeGetCall<'a, C> {
64714        self._scopes.clear();
64715        self
64716    }
64717}
64718
64719/// Retrieves a list of platform types.
64720///
64721/// A builder for the *list* method supported by a *platformType* resource.
64722/// It is not used directly, but through a [`PlatformTypeMethods`] instance.
64723///
64724/// # Example
64725///
64726/// Instantiate a resource method builder
64727///
64728/// ```test_harness,no_run
64729/// # extern crate hyper;
64730/// # extern crate hyper_rustls;
64731/// # extern crate google_dfareporting3d2 as dfareporting3d2;
64732/// # async fn dox() {
64733/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
64734///
64735/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
64736/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
64737/// #     secret,
64738/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
64739/// # ).build().await.unwrap();
64740///
64741/// # let client = hyper_util::client::legacy::Client::builder(
64742/// #     hyper_util::rt::TokioExecutor::new()
64743/// # )
64744/// # .build(
64745/// #     hyper_rustls::HttpsConnectorBuilder::new()
64746/// #         .with_native_roots()
64747/// #         .unwrap()
64748/// #         .https_or_http()
64749/// #         .enable_http1()
64750/// #         .build()
64751/// # );
64752/// # let mut hub = Dfareporting::new(client, auth);
64753/// // You can configure optional parameters by calling the respective setters at will, and
64754/// // execute the final call using `doit()`.
64755/// // Values shown here are possibly random and not representative !
64756/// let result = hub.platform_types().list(-19)
64757///              .doit().await;
64758/// # }
64759/// ```
64760pub struct PlatformTypeListCall<'a, C>
64761where
64762    C: 'a,
64763{
64764    hub: &'a Dfareporting<C>,
64765    _profile_id: i64,
64766    _delegate: Option<&'a mut dyn common::Delegate>,
64767    _additional_params: HashMap<String, String>,
64768    _scopes: BTreeSet<String>,
64769}
64770
64771impl<'a, C> common::CallBuilder for PlatformTypeListCall<'a, C> {}
64772
64773impl<'a, C> PlatformTypeListCall<'a, C>
64774where
64775    C: common::Connector,
64776{
64777    /// Perform the operation you have build so far.
64778    pub async fn doit(mut self) -> common::Result<(common::Response, PlatformTypesListResponse)> {
64779        use std::borrow::Cow;
64780        use std::io::{Read, Seek};
64781
64782        use common::{url::Params, ToParts};
64783        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
64784
64785        let mut dd = common::DefaultDelegate;
64786        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
64787        dlg.begin(common::MethodInfo {
64788            id: "dfareporting.platformTypes.list",
64789            http_method: hyper::Method::GET,
64790        });
64791
64792        for &field in ["alt", "profileId"].iter() {
64793            if self._additional_params.contains_key(field) {
64794                dlg.finished(false);
64795                return Err(common::Error::FieldClash(field));
64796            }
64797        }
64798
64799        let mut params = Params::with_capacity(3 + self._additional_params.len());
64800        params.push("profileId", self._profile_id.to_string());
64801
64802        params.extend(self._additional_params.iter());
64803
64804        params.push("alt", "json");
64805        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/platformTypes";
64806        if self._scopes.is_empty() {
64807            self._scopes
64808                .insert(Scope::Dfatrafficking.as_ref().to_string());
64809        }
64810
64811        #[allow(clippy::single_element_loop)]
64812        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
64813            url = params.uri_replacement(url, param_name, find_this, false);
64814        }
64815        {
64816            let to_remove = ["profileId"];
64817            params.remove_params(&to_remove);
64818        }
64819
64820        let url = params.parse_with_url(&url);
64821
64822        loop {
64823            let token = match self
64824                .hub
64825                .auth
64826                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
64827                .await
64828            {
64829                Ok(token) => token,
64830                Err(e) => match dlg.token(e) {
64831                    Ok(token) => token,
64832                    Err(e) => {
64833                        dlg.finished(false);
64834                        return Err(common::Error::MissingToken(e));
64835                    }
64836                },
64837            };
64838            let mut req_result = {
64839                let client = &self.hub.client;
64840                dlg.pre_request();
64841                let mut req_builder = hyper::Request::builder()
64842                    .method(hyper::Method::GET)
64843                    .uri(url.as_str())
64844                    .header(USER_AGENT, self.hub._user_agent.clone());
64845
64846                if let Some(token) = token.as_ref() {
64847                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
64848                }
64849
64850                let request = req_builder
64851                    .header(CONTENT_LENGTH, 0_u64)
64852                    .body(common::to_body::<String>(None));
64853
64854                client.request(request.unwrap()).await
64855            };
64856
64857            match req_result {
64858                Err(err) => {
64859                    if let common::Retry::After(d) = dlg.http_error(&err) {
64860                        sleep(d).await;
64861                        continue;
64862                    }
64863                    dlg.finished(false);
64864                    return Err(common::Error::HttpError(err));
64865                }
64866                Ok(res) => {
64867                    let (mut parts, body) = res.into_parts();
64868                    let mut body = common::Body::new(body);
64869                    if !parts.status.is_success() {
64870                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64871                        let error = serde_json::from_str(&common::to_string(&bytes));
64872                        let response = common::to_response(parts, bytes.into());
64873
64874                        if let common::Retry::After(d) =
64875                            dlg.http_failure(&response, error.as_ref().ok())
64876                        {
64877                            sleep(d).await;
64878                            continue;
64879                        }
64880
64881                        dlg.finished(false);
64882
64883                        return Err(match error {
64884                            Ok(value) => common::Error::BadRequest(value),
64885                            _ => common::Error::Failure(response),
64886                        });
64887                    }
64888                    let response = {
64889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
64890                        let encoded = common::to_string(&bytes);
64891                        match serde_json::from_str(&encoded) {
64892                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
64893                            Err(error) => {
64894                                dlg.response_json_decode_error(&encoded, &error);
64895                                return Err(common::Error::JsonDecodeError(
64896                                    encoded.to_string(),
64897                                    error,
64898                                ));
64899                            }
64900                        }
64901                    };
64902
64903                    dlg.finished(true);
64904                    return Ok(response);
64905                }
64906            }
64907        }
64908    }
64909
64910    /// User profile ID associated with this request.
64911    ///
64912    /// Sets the *profile id* path property to the given value.
64913    ///
64914    /// Even though the property as already been set when instantiating this call,
64915    /// we provide this method for API completeness.
64916    pub fn profile_id(mut self, new_value: i64) -> PlatformTypeListCall<'a, C> {
64917        self._profile_id = new_value;
64918        self
64919    }
64920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
64921    /// while executing the actual API request.
64922    ///
64923    /// ````text
64924    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
64925    /// ````
64926    ///
64927    /// Sets the *delegate* property to the given value.
64928    pub fn delegate(
64929        mut self,
64930        new_value: &'a mut dyn common::Delegate,
64931    ) -> PlatformTypeListCall<'a, C> {
64932        self._delegate = Some(new_value);
64933        self
64934    }
64935
64936    /// Set any additional parameter of the query string used in the request.
64937    /// It should be used to set parameters which are not yet available through their own
64938    /// setters.
64939    ///
64940    /// Please note that this method must not be used to set any of the known parameters
64941    /// which have their own setter method. If done anyway, the request will fail.
64942    ///
64943    /// # Additional Parameters
64944    ///
64945    /// * *alt* (query-string) - Data format for the response.
64946    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
64947    /// * *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.
64948    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
64949    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
64950    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
64951    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
64952    pub fn param<T>(mut self, name: T, value: T) -> PlatformTypeListCall<'a, C>
64953    where
64954        T: AsRef<str>,
64955    {
64956        self._additional_params
64957            .insert(name.as_ref().to_string(), value.as_ref().to_string());
64958        self
64959    }
64960
64961    /// Identifies the authorization scope for the method you are building.
64962    ///
64963    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
64964    /// [`Scope::Dfatrafficking`].
64965    ///
64966    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
64967    /// tokens for more than one scope.
64968    ///
64969    /// Usually there is more than one suitable scope to authorize an operation, some of which may
64970    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
64971    /// sufficient, a read-write scope will do as well.
64972    pub fn add_scope<St>(mut self, scope: St) -> PlatformTypeListCall<'a, C>
64973    where
64974        St: AsRef<str>,
64975    {
64976        self._scopes.insert(String::from(scope.as_ref()));
64977        self
64978    }
64979    /// Identifies the authorization scope(s) for the method you are building.
64980    ///
64981    /// See [`Self::add_scope()`] for details.
64982    pub fn add_scopes<I, St>(mut self, scopes: I) -> PlatformTypeListCall<'a, C>
64983    where
64984        I: IntoIterator<Item = St>,
64985        St: AsRef<str>,
64986    {
64987        self._scopes
64988            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
64989        self
64990    }
64991
64992    /// Removes all scopes, and no default scope will be used either.
64993    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
64994    /// for details).
64995    pub fn clear_scopes(mut self) -> PlatformTypeListCall<'a, C> {
64996        self._scopes.clear();
64997        self
64998    }
64999}
65000
65001/// Gets one postal code by ID.
65002///
65003/// A builder for the *get* method supported by a *postalCode* resource.
65004/// It is not used directly, but through a [`PostalCodeMethods`] instance.
65005///
65006/// # Example
65007///
65008/// Instantiate a resource method builder
65009///
65010/// ```test_harness,no_run
65011/// # extern crate hyper;
65012/// # extern crate hyper_rustls;
65013/// # extern crate google_dfareporting3d2 as dfareporting3d2;
65014/// # async fn dox() {
65015/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
65016///
65017/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
65018/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
65019/// #     secret,
65020/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65021/// # ).build().await.unwrap();
65022///
65023/// # let client = hyper_util::client::legacy::Client::builder(
65024/// #     hyper_util::rt::TokioExecutor::new()
65025/// # )
65026/// # .build(
65027/// #     hyper_rustls::HttpsConnectorBuilder::new()
65028/// #         .with_native_roots()
65029/// #         .unwrap()
65030/// #         .https_or_http()
65031/// #         .enable_http1()
65032/// #         .build()
65033/// # );
65034/// # let mut hub = Dfareporting::new(client, auth);
65035/// // You can configure optional parameters by calling the respective setters at will, and
65036/// // execute the final call using `doit()`.
65037/// // Values shown here are possibly random and not representative !
65038/// let result = hub.postal_codes().get(-32, "code")
65039///              .doit().await;
65040/// # }
65041/// ```
65042pub struct PostalCodeGetCall<'a, C>
65043where
65044    C: 'a,
65045{
65046    hub: &'a Dfareporting<C>,
65047    _profile_id: i64,
65048    _code: String,
65049    _delegate: Option<&'a mut dyn common::Delegate>,
65050    _additional_params: HashMap<String, String>,
65051    _scopes: BTreeSet<String>,
65052}
65053
65054impl<'a, C> common::CallBuilder for PostalCodeGetCall<'a, C> {}
65055
65056impl<'a, C> PostalCodeGetCall<'a, C>
65057where
65058    C: common::Connector,
65059{
65060    /// Perform the operation you have build so far.
65061    pub async fn doit(mut self) -> common::Result<(common::Response, PostalCode)> {
65062        use std::borrow::Cow;
65063        use std::io::{Read, Seek};
65064
65065        use common::{url::Params, ToParts};
65066        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
65067
65068        let mut dd = common::DefaultDelegate;
65069        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
65070        dlg.begin(common::MethodInfo {
65071            id: "dfareporting.postalCodes.get",
65072            http_method: hyper::Method::GET,
65073        });
65074
65075        for &field in ["alt", "profileId", "code"].iter() {
65076            if self._additional_params.contains_key(field) {
65077                dlg.finished(false);
65078                return Err(common::Error::FieldClash(field));
65079            }
65080        }
65081
65082        let mut params = Params::with_capacity(4 + self._additional_params.len());
65083        params.push("profileId", self._profile_id.to_string());
65084        params.push("code", self._code);
65085
65086        params.extend(self._additional_params.iter());
65087
65088        params.push("alt", "json");
65089        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/postalCodes/{code}";
65090        if self._scopes.is_empty() {
65091            self._scopes
65092                .insert(Scope::Dfatrafficking.as_ref().to_string());
65093        }
65094
65095        #[allow(clippy::single_element_loop)]
65096        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{code}", "code")].iter() {
65097            url = params.uri_replacement(url, param_name, find_this, false);
65098        }
65099        {
65100            let to_remove = ["code", "profileId"];
65101            params.remove_params(&to_remove);
65102        }
65103
65104        let url = params.parse_with_url(&url);
65105
65106        loop {
65107            let token = match self
65108                .hub
65109                .auth
65110                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
65111                .await
65112            {
65113                Ok(token) => token,
65114                Err(e) => match dlg.token(e) {
65115                    Ok(token) => token,
65116                    Err(e) => {
65117                        dlg.finished(false);
65118                        return Err(common::Error::MissingToken(e));
65119                    }
65120                },
65121            };
65122            let mut req_result = {
65123                let client = &self.hub.client;
65124                dlg.pre_request();
65125                let mut req_builder = hyper::Request::builder()
65126                    .method(hyper::Method::GET)
65127                    .uri(url.as_str())
65128                    .header(USER_AGENT, self.hub._user_agent.clone());
65129
65130                if let Some(token) = token.as_ref() {
65131                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
65132                }
65133
65134                let request = req_builder
65135                    .header(CONTENT_LENGTH, 0_u64)
65136                    .body(common::to_body::<String>(None));
65137
65138                client.request(request.unwrap()).await
65139            };
65140
65141            match req_result {
65142                Err(err) => {
65143                    if let common::Retry::After(d) = dlg.http_error(&err) {
65144                        sleep(d).await;
65145                        continue;
65146                    }
65147                    dlg.finished(false);
65148                    return Err(common::Error::HttpError(err));
65149                }
65150                Ok(res) => {
65151                    let (mut parts, body) = res.into_parts();
65152                    let mut body = common::Body::new(body);
65153                    if !parts.status.is_success() {
65154                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65155                        let error = serde_json::from_str(&common::to_string(&bytes));
65156                        let response = common::to_response(parts, bytes.into());
65157
65158                        if let common::Retry::After(d) =
65159                            dlg.http_failure(&response, error.as_ref().ok())
65160                        {
65161                            sleep(d).await;
65162                            continue;
65163                        }
65164
65165                        dlg.finished(false);
65166
65167                        return Err(match error {
65168                            Ok(value) => common::Error::BadRequest(value),
65169                            _ => common::Error::Failure(response),
65170                        });
65171                    }
65172                    let response = {
65173                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65174                        let encoded = common::to_string(&bytes);
65175                        match serde_json::from_str(&encoded) {
65176                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
65177                            Err(error) => {
65178                                dlg.response_json_decode_error(&encoded, &error);
65179                                return Err(common::Error::JsonDecodeError(
65180                                    encoded.to_string(),
65181                                    error,
65182                                ));
65183                            }
65184                        }
65185                    };
65186
65187                    dlg.finished(true);
65188                    return Ok(response);
65189                }
65190            }
65191        }
65192    }
65193
65194    /// User profile ID associated with this request.
65195    ///
65196    /// Sets the *profile id* path property to the given value.
65197    ///
65198    /// Even though the property as already been set when instantiating this call,
65199    /// we provide this method for API completeness.
65200    pub fn profile_id(mut self, new_value: i64) -> PostalCodeGetCall<'a, C> {
65201        self._profile_id = new_value;
65202        self
65203    }
65204    /// Postal code ID.
65205    ///
65206    /// Sets the *code* path property to the given value.
65207    ///
65208    /// Even though the property as already been set when instantiating this call,
65209    /// we provide this method for API completeness.
65210    pub fn code(mut self, new_value: &str) -> PostalCodeGetCall<'a, C> {
65211        self._code = new_value.to_string();
65212        self
65213    }
65214    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
65215    /// while executing the actual API request.
65216    ///
65217    /// ````text
65218    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
65219    /// ````
65220    ///
65221    /// Sets the *delegate* property to the given value.
65222    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> PostalCodeGetCall<'a, C> {
65223        self._delegate = Some(new_value);
65224        self
65225    }
65226
65227    /// Set any additional parameter of the query string used in the request.
65228    /// It should be used to set parameters which are not yet available through their own
65229    /// setters.
65230    ///
65231    /// Please note that this method must not be used to set any of the known parameters
65232    /// which have their own setter method. If done anyway, the request will fail.
65233    ///
65234    /// # Additional Parameters
65235    ///
65236    /// * *alt* (query-string) - Data format for the response.
65237    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
65238    /// * *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.
65239    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
65240    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
65241    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
65242    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
65243    pub fn param<T>(mut self, name: T, value: T) -> PostalCodeGetCall<'a, C>
65244    where
65245        T: AsRef<str>,
65246    {
65247        self._additional_params
65248            .insert(name.as_ref().to_string(), value.as_ref().to_string());
65249        self
65250    }
65251
65252    /// Identifies the authorization scope for the method you are building.
65253    ///
65254    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
65255    /// [`Scope::Dfatrafficking`].
65256    ///
65257    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
65258    /// tokens for more than one scope.
65259    ///
65260    /// Usually there is more than one suitable scope to authorize an operation, some of which may
65261    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
65262    /// sufficient, a read-write scope will do as well.
65263    pub fn add_scope<St>(mut self, scope: St) -> PostalCodeGetCall<'a, C>
65264    where
65265        St: AsRef<str>,
65266    {
65267        self._scopes.insert(String::from(scope.as_ref()));
65268        self
65269    }
65270    /// Identifies the authorization scope(s) for the method you are building.
65271    ///
65272    /// See [`Self::add_scope()`] for details.
65273    pub fn add_scopes<I, St>(mut self, scopes: I) -> PostalCodeGetCall<'a, C>
65274    where
65275        I: IntoIterator<Item = St>,
65276        St: AsRef<str>,
65277    {
65278        self._scopes
65279            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
65280        self
65281    }
65282
65283    /// Removes all scopes, and no default scope will be used either.
65284    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
65285    /// for details).
65286    pub fn clear_scopes(mut self) -> PostalCodeGetCall<'a, C> {
65287        self._scopes.clear();
65288        self
65289    }
65290}
65291
65292/// Retrieves a list of postal codes.
65293///
65294/// A builder for the *list* method supported by a *postalCode* resource.
65295/// It is not used directly, but through a [`PostalCodeMethods`] instance.
65296///
65297/// # Example
65298///
65299/// Instantiate a resource method builder
65300///
65301/// ```test_harness,no_run
65302/// # extern crate hyper;
65303/// # extern crate hyper_rustls;
65304/// # extern crate google_dfareporting3d2 as dfareporting3d2;
65305/// # async fn dox() {
65306/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
65307///
65308/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
65309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
65310/// #     secret,
65311/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65312/// # ).build().await.unwrap();
65313///
65314/// # let client = hyper_util::client::legacy::Client::builder(
65315/// #     hyper_util::rt::TokioExecutor::new()
65316/// # )
65317/// # .build(
65318/// #     hyper_rustls::HttpsConnectorBuilder::new()
65319/// #         .with_native_roots()
65320/// #         .unwrap()
65321/// #         .https_or_http()
65322/// #         .enable_http1()
65323/// #         .build()
65324/// # );
65325/// # let mut hub = Dfareporting::new(client, auth);
65326/// // You can configure optional parameters by calling the respective setters at will, and
65327/// // execute the final call using `doit()`.
65328/// // Values shown here are possibly random and not representative !
65329/// let result = hub.postal_codes().list(-26)
65330///              .doit().await;
65331/// # }
65332/// ```
65333pub struct PostalCodeListCall<'a, C>
65334where
65335    C: 'a,
65336{
65337    hub: &'a Dfareporting<C>,
65338    _profile_id: i64,
65339    _delegate: Option<&'a mut dyn common::Delegate>,
65340    _additional_params: HashMap<String, String>,
65341    _scopes: BTreeSet<String>,
65342}
65343
65344impl<'a, C> common::CallBuilder for PostalCodeListCall<'a, C> {}
65345
65346impl<'a, C> PostalCodeListCall<'a, C>
65347where
65348    C: common::Connector,
65349{
65350    /// Perform the operation you have build so far.
65351    pub async fn doit(mut self) -> common::Result<(common::Response, PostalCodesListResponse)> {
65352        use std::borrow::Cow;
65353        use std::io::{Read, Seek};
65354
65355        use common::{url::Params, ToParts};
65356        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
65357
65358        let mut dd = common::DefaultDelegate;
65359        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
65360        dlg.begin(common::MethodInfo {
65361            id: "dfareporting.postalCodes.list",
65362            http_method: hyper::Method::GET,
65363        });
65364
65365        for &field in ["alt", "profileId"].iter() {
65366            if self._additional_params.contains_key(field) {
65367                dlg.finished(false);
65368                return Err(common::Error::FieldClash(field));
65369            }
65370        }
65371
65372        let mut params = Params::with_capacity(3 + self._additional_params.len());
65373        params.push("profileId", self._profile_id.to_string());
65374
65375        params.extend(self._additional_params.iter());
65376
65377        params.push("alt", "json");
65378        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/postalCodes";
65379        if self._scopes.is_empty() {
65380            self._scopes
65381                .insert(Scope::Dfatrafficking.as_ref().to_string());
65382        }
65383
65384        #[allow(clippy::single_element_loop)]
65385        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
65386            url = params.uri_replacement(url, param_name, find_this, false);
65387        }
65388        {
65389            let to_remove = ["profileId"];
65390            params.remove_params(&to_remove);
65391        }
65392
65393        let url = params.parse_with_url(&url);
65394
65395        loop {
65396            let token = match self
65397                .hub
65398                .auth
65399                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
65400                .await
65401            {
65402                Ok(token) => token,
65403                Err(e) => match dlg.token(e) {
65404                    Ok(token) => token,
65405                    Err(e) => {
65406                        dlg.finished(false);
65407                        return Err(common::Error::MissingToken(e));
65408                    }
65409                },
65410            };
65411            let mut req_result = {
65412                let client = &self.hub.client;
65413                dlg.pre_request();
65414                let mut req_builder = hyper::Request::builder()
65415                    .method(hyper::Method::GET)
65416                    .uri(url.as_str())
65417                    .header(USER_AGENT, self.hub._user_agent.clone());
65418
65419                if let Some(token) = token.as_ref() {
65420                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
65421                }
65422
65423                let request = req_builder
65424                    .header(CONTENT_LENGTH, 0_u64)
65425                    .body(common::to_body::<String>(None));
65426
65427                client.request(request.unwrap()).await
65428            };
65429
65430            match req_result {
65431                Err(err) => {
65432                    if let common::Retry::After(d) = dlg.http_error(&err) {
65433                        sleep(d).await;
65434                        continue;
65435                    }
65436                    dlg.finished(false);
65437                    return Err(common::Error::HttpError(err));
65438                }
65439                Ok(res) => {
65440                    let (mut parts, body) = res.into_parts();
65441                    let mut body = common::Body::new(body);
65442                    if !parts.status.is_success() {
65443                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65444                        let error = serde_json::from_str(&common::to_string(&bytes));
65445                        let response = common::to_response(parts, bytes.into());
65446
65447                        if let common::Retry::After(d) =
65448                            dlg.http_failure(&response, error.as_ref().ok())
65449                        {
65450                            sleep(d).await;
65451                            continue;
65452                        }
65453
65454                        dlg.finished(false);
65455
65456                        return Err(match error {
65457                            Ok(value) => common::Error::BadRequest(value),
65458                            _ => common::Error::Failure(response),
65459                        });
65460                    }
65461                    let response = {
65462                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65463                        let encoded = common::to_string(&bytes);
65464                        match serde_json::from_str(&encoded) {
65465                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
65466                            Err(error) => {
65467                                dlg.response_json_decode_error(&encoded, &error);
65468                                return Err(common::Error::JsonDecodeError(
65469                                    encoded.to_string(),
65470                                    error,
65471                                ));
65472                            }
65473                        }
65474                    };
65475
65476                    dlg.finished(true);
65477                    return Ok(response);
65478                }
65479            }
65480        }
65481    }
65482
65483    /// User profile ID associated with this request.
65484    ///
65485    /// Sets the *profile id* path property to the given value.
65486    ///
65487    /// Even though the property as already been set when instantiating this call,
65488    /// we provide this method for API completeness.
65489    pub fn profile_id(mut self, new_value: i64) -> PostalCodeListCall<'a, C> {
65490        self._profile_id = new_value;
65491        self
65492    }
65493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
65494    /// while executing the actual API request.
65495    ///
65496    /// ````text
65497    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
65498    /// ````
65499    ///
65500    /// Sets the *delegate* property to the given value.
65501    pub fn delegate(
65502        mut self,
65503        new_value: &'a mut dyn common::Delegate,
65504    ) -> PostalCodeListCall<'a, C> {
65505        self._delegate = Some(new_value);
65506        self
65507    }
65508
65509    /// Set any additional parameter of the query string used in the request.
65510    /// It should be used to set parameters which are not yet available through their own
65511    /// setters.
65512    ///
65513    /// Please note that this method must not be used to set any of the known parameters
65514    /// which have their own setter method. If done anyway, the request will fail.
65515    ///
65516    /// # Additional Parameters
65517    ///
65518    /// * *alt* (query-string) - Data format for the response.
65519    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
65520    /// * *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.
65521    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
65522    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
65523    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
65524    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
65525    pub fn param<T>(mut self, name: T, value: T) -> PostalCodeListCall<'a, C>
65526    where
65527        T: AsRef<str>,
65528    {
65529        self._additional_params
65530            .insert(name.as_ref().to_string(), value.as_ref().to_string());
65531        self
65532    }
65533
65534    /// Identifies the authorization scope for the method you are building.
65535    ///
65536    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
65537    /// [`Scope::Dfatrafficking`].
65538    ///
65539    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
65540    /// tokens for more than one scope.
65541    ///
65542    /// Usually there is more than one suitable scope to authorize an operation, some of which may
65543    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
65544    /// sufficient, a read-write scope will do as well.
65545    pub fn add_scope<St>(mut self, scope: St) -> PostalCodeListCall<'a, C>
65546    where
65547        St: AsRef<str>,
65548    {
65549        self._scopes.insert(String::from(scope.as_ref()));
65550        self
65551    }
65552    /// Identifies the authorization scope(s) for the method you are building.
65553    ///
65554    /// See [`Self::add_scope()`] for details.
65555    pub fn add_scopes<I, St>(mut self, scopes: I) -> PostalCodeListCall<'a, C>
65556    where
65557        I: IntoIterator<Item = St>,
65558        St: AsRef<str>,
65559    {
65560        self._scopes
65561            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
65562        self
65563    }
65564
65565    /// Removes all scopes, and no default scope will be used either.
65566    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
65567    /// for details).
65568    pub fn clear_scopes(mut self) -> PostalCodeListCall<'a, C> {
65569        self._scopes.clear();
65570        self
65571    }
65572}
65573
65574/// Gets one project by ID.
65575///
65576/// A builder for the *get* method supported by a *project* resource.
65577/// It is not used directly, but through a [`ProjectMethods`] instance.
65578///
65579/// # Example
65580///
65581/// Instantiate a resource method builder
65582///
65583/// ```test_harness,no_run
65584/// # extern crate hyper;
65585/// # extern crate hyper_rustls;
65586/// # extern crate google_dfareporting3d2 as dfareporting3d2;
65587/// # async fn dox() {
65588/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
65589///
65590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
65591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
65592/// #     secret,
65593/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65594/// # ).build().await.unwrap();
65595///
65596/// # let client = hyper_util::client::legacy::Client::builder(
65597/// #     hyper_util::rt::TokioExecutor::new()
65598/// # )
65599/// # .build(
65600/// #     hyper_rustls::HttpsConnectorBuilder::new()
65601/// #         .with_native_roots()
65602/// #         .unwrap()
65603/// #         .https_or_http()
65604/// #         .enable_http1()
65605/// #         .build()
65606/// # );
65607/// # let mut hub = Dfareporting::new(client, auth);
65608/// // You can configure optional parameters by calling the respective setters at will, and
65609/// // execute the final call using `doit()`.
65610/// // Values shown here are possibly random and not representative !
65611/// let result = hub.projects().get(-67, -33)
65612///              .doit().await;
65613/// # }
65614/// ```
65615pub struct ProjectGetCall<'a, C>
65616where
65617    C: 'a,
65618{
65619    hub: &'a Dfareporting<C>,
65620    _profile_id: i64,
65621    _id: i64,
65622    _delegate: Option<&'a mut dyn common::Delegate>,
65623    _additional_params: HashMap<String, String>,
65624    _scopes: BTreeSet<String>,
65625}
65626
65627impl<'a, C> common::CallBuilder for ProjectGetCall<'a, C> {}
65628
65629impl<'a, C> ProjectGetCall<'a, C>
65630where
65631    C: common::Connector,
65632{
65633    /// Perform the operation you have build so far.
65634    pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
65635        use std::borrow::Cow;
65636        use std::io::{Read, Seek};
65637
65638        use common::{url::Params, ToParts};
65639        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
65640
65641        let mut dd = common::DefaultDelegate;
65642        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
65643        dlg.begin(common::MethodInfo {
65644            id: "dfareporting.projects.get",
65645            http_method: hyper::Method::GET,
65646        });
65647
65648        for &field in ["alt", "profileId", "id"].iter() {
65649            if self._additional_params.contains_key(field) {
65650                dlg.finished(false);
65651                return Err(common::Error::FieldClash(field));
65652            }
65653        }
65654
65655        let mut params = Params::with_capacity(4 + self._additional_params.len());
65656        params.push("profileId", self._profile_id.to_string());
65657        params.push("id", self._id.to_string());
65658
65659        params.extend(self._additional_params.iter());
65660
65661        params.push("alt", "json");
65662        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{id}";
65663        if self._scopes.is_empty() {
65664            self._scopes
65665                .insert(Scope::Dfatrafficking.as_ref().to_string());
65666        }
65667
65668        #[allow(clippy::single_element_loop)]
65669        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
65670            url = params.uri_replacement(url, param_name, find_this, false);
65671        }
65672        {
65673            let to_remove = ["id", "profileId"];
65674            params.remove_params(&to_remove);
65675        }
65676
65677        let url = params.parse_with_url(&url);
65678
65679        loop {
65680            let token = match self
65681                .hub
65682                .auth
65683                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
65684                .await
65685            {
65686                Ok(token) => token,
65687                Err(e) => match dlg.token(e) {
65688                    Ok(token) => token,
65689                    Err(e) => {
65690                        dlg.finished(false);
65691                        return Err(common::Error::MissingToken(e));
65692                    }
65693                },
65694            };
65695            let mut req_result = {
65696                let client = &self.hub.client;
65697                dlg.pre_request();
65698                let mut req_builder = hyper::Request::builder()
65699                    .method(hyper::Method::GET)
65700                    .uri(url.as_str())
65701                    .header(USER_AGENT, self.hub._user_agent.clone());
65702
65703                if let Some(token) = token.as_ref() {
65704                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
65705                }
65706
65707                let request = req_builder
65708                    .header(CONTENT_LENGTH, 0_u64)
65709                    .body(common::to_body::<String>(None));
65710
65711                client.request(request.unwrap()).await
65712            };
65713
65714            match req_result {
65715                Err(err) => {
65716                    if let common::Retry::After(d) = dlg.http_error(&err) {
65717                        sleep(d).await;
65718                        continue;
65719                    }
65720                    dlg.finished(false);
65721                    return Err(common::Error::HttpError(err));
65722                }
65723                Ok(res) => {
65724                    let (mut parts, body) = res.into_parts();
65725                    let mut body = common::Body::new(body);
65726                    if !parts.status.is_success() {
65727                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65728                        let error = serde_json::from_str(&common::to_string(&bytes));
65729                        let response = common::to_response(parts, bytes.into());
65730
65731                        if let common::Retry::After(d) =
65732                            dlg.http_failure(&response, error.as_ref().ok())
65733                        {
65734                            sleep(d).await;
65735                            continue;
65736                        }
65737
65738                        dlg.finished(false);
65739
65740                        return Err(match error {
65741                            Ok(value) => common::Error::BadRequest(value),
65742                            _ => common::Error::Failure(response),
65743                        });
65744                    }
65745                    let response = {
65746                        let bytes = common::to_bytes(body).await.unwrap_or_default();
65747                        let encoded = common::to_string(&bytes);
65748                        match serde_json::from_str(&encoded) {
65749                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
65750                            Err(error) => {
65751                                dlg.response_json_decode_error(&encoded, &error);
65752                                return Err(common::Error::JsonDecodeError(
65753                                    encoded.to_string(),
65754                                    error,
65755                                ));
65756                            }
65757                        }
65758                    };
65759
65760                    dlg.finished(true);
65761                    return Ok(response);
65762                }
65763            }
65764        }
65765    }
65766
65767    /// User profile ID associated with this request.
65768    ///
65769    /// Sets the *profile id* path property to the given value.
65770    ///
65771    /// Even though the property as already been set when instantiating this call,
65772    /// we provide this method for API completeness.
65773    pub fn profile_id(mut self, new_value: i64) -> ProjectGetCall<'a, C> {
65774        self._profile_id = new_value;
65775        self
65776    }
65777    /// Project ID.
65778    ///
65779    /// Sets the *id* path property to the given value.
65780    ///
65781    /// Even though the property as already been set when instantiating this call,
65782    /// we provide this method for API completeness.
65783    pub fn id(mut self, new_value: i64) -> ProjectGetCall<'a, C> {
65784        self._id = new_value;
65785        self
65786    }
65787    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
65788    /// while executing the actual API request.
65789    ///
65790    /// ````text
65791    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
65792    /// ````
65793    ///
65794    /// Sets the *delegate* property to the given value.
65795    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectGetCall<'a, C> {
65796        self._delegate = Some(new_value);
65797        self
65798    }
65799
65800    /// Set any additional parameter of the query string used in the request.
65801    /// It should be used to set parameters which are not yet available through their own
65802    /// setters.
65803    ///
65804    /// Please note that this method must not be used to set any of the known parameters
65805    /// which have their own setter method. If done anyway, the request will fail.
65806    ///
65807    /// # Additional Parameters
65808    ///
65809    /// * *alt* (query-string) - Data format for the response.
65810    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
65811    /// * *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.
65812    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
65813    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
65814    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
65815    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
65816    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C>
65817    where
65818        T: AsRef<str>,
65819    {
65820        self._additional_params
65821            .insert(name.as_ref().to_string(), value.as_ref().to_string());
65822        self
65823    }
65824
65825    /// Identifies the authorization scope for the method you are building.
65826    ///
65827    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
65828    /// [`Scope::Dfatrafficking`].
65829    ///
65830    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
65831    /// tokens for more than one scope.
65832    ///
65833    /// Usually there is more than one suitable scope to authorize an operation, some of which may
65834    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
65835    /// sufficient, a read-write scope will do as well.
65836    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetCall<'a, C>
65837    where
65838        St: AsRef<str>,
65839    {
65840        self._scopes.insert(String::from(scope.as_ref()));
65841        self
65842    }
65843    /// Identifies the authorization scope(s) for the method you are building.
65844    ///
65845    /// See [`Self::add_scope()`] for details.
65846    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetCall<'a, C>
65847    where
65848        I: IntoIterator<Item = St>,
65849        St: AsRef<str>,
65850    {
65851        self._scopes
65852            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
65853        self
65854    }
65855
65856    /// Removes all scopes, and no default scope will be used either.
65857    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
65858    /// for details).
65859    pub fn clear_scopes(mut self) -> ProjectGetCall<'a, C> {
65860        self._scopes.clear();
65861        self
65862    }
65863}
65864
65865/// Retrieves a list of projects, possibly filtered. This method supports paging.
65866///
65867/// A builder for the *list* method supported by a *project* resource.
65868/// It is not used directly, but through a [`ProjectMethods`] instance.
65869///
65870/// # Example
65871///
65872/// Instantiate a resource method builder
65873///
65874/// ```test_harness,no_run
65875/// # extern crate hyper;
65876/// # extern crate hyper_rustls;
65877/// # extern crate google_dfareporting3d2 as dfareporting3d2;
65878/// # async fn dox() {
65879/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
65880///
65881/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
65882/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
65883/// #     secret,
65884/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65885/// # ).build().await.unwrap();
65886///
65887/// # let client = hyper_util::client::legacy::Client::builder(
65888/// #     hyper_util::rt::TokioExecutor::new()
65889/// # )
65890/// # .build(
65891/// #     hyper_rustls::HttpsConnectorBuilder::new()
65892/// #         .with_native_roots()
65893/// #         .unwrap()
65894/// #         .https_or_http()
65895/// #         .enable_http1()
65896/// #         .build()
65897/// # );
65898/// # let mut hub = Dfareporting::new(client, auth);
65899/// // You can configure optional parameters by calling the respective setters at will, and
65900/// // execute the final call using `doit()`.
65901/// // Values shown here are possibly random and not representative !
65902/// let result = hub.projects().list(-66)
65903///              .sort_order("amet")
65904///              .sort_field("sea")
65905///              .search_string("sadipscing")
65906///              .page_token("dolore")
65907///              .max_results(-47)
65908///              .add_ids(-38)
65909///              .add_advertiser_ids(-38)
65910///              .doit().await;
65911/// # }
65912/// ```
65913pub struct ProjectListCall<'a, C>
65914where
65915    C: 'a,
65916{
65917    hub: &'a Dfareporting<C>,
65918    _profile_id: i64,
65919    _sort_order: Option<String>,
65920    _sort_field: Option<String>,
65921    _search_string: Option<String>,
65922    _page_token: Option<String>,
65923    _max_results: Option<i32>,
65924    _ids: Vec<i64>,
65925    _advertiser_ids: Vec<i64>,
65926    _delegate: Option<&'a mut dyn common::Delegate>,
65927    _additional_params: HashMap<String, String>,
65928    _scopes: BTreeSet<String>,
65929}
65930
65931impl<'a, C> common::CallBuilder for ProjectListCall<'a, C> {}
65932
65933impl<'a, C> ProjectListCall<'a, C>
65934where
65935    C: common::Connector,
65936{
65937    /// Perform the operation you have build so far.
65938    pub async fn doit(mut self) -> common::Result<(common::Response, ProjectsListResponse)> {
65939        use std::borrow::Cow;
65940        use std::io::{Read, Seek};
65941
65942        use common::{url::Params, ToParts};
65943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
65944
65945        let mut dd = common::DefaultDelegate;
65946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
65947        dlg.begin(common::MethodInfo {
65948            id: "dfareporting.projects.list",
65949            http_method: hyper::Method::GET,
65950        });
65951
65952        for &field in [
65953            "alt",
65954            "profileId",
65955            "sortOrder",
65956            "sortField",
65957            "searchString",
65958            "pageToken",
65959            "maxResults",
65960            "ids",
65961            "advertiserIds",
65962        ]
65963        .iter()
65964        {
65965            if self._additional_params.contains_key(field) {
65966                dlg.finished(false);
65967                return Err(common::Error::FieldClash(field));
65968            }
65969        }
65970
65971        let mut params = Params::with_capacity(10 + self._additional_params.len());
65972        params.push("profileId", self._profile_id.to_string());
65973        if let Some(value) = self._sort_order.as_ref() {
65974            params.push("sortOrder", value);
65975        }
65976        if let Some(value) = self._sort_field.as_ref() {
65977            params.push("sortField", value);
65978        }
65979        if let Some(value) = self._search_string.as_ref() {
65980            params.push("searchString", value);
65981        }
65982        if let Some(value) = self._page_token.as_ref() {
65983            params.push("pageToken", value);
65984        }
65985        if let Some(value) = self._max_results.as_ref() {
65986            params.push("maxResults", value.to_string());
65987        }
65988        if !self._ids.is_empty() {
65989            for f in self._ids.iter() {
65990                params.push("ids", f.to_string());
65991            }
65992        }
65993        if !self._advertiser_ids.is_empty() {
65994            for f in self._advertiser_ids.iter() {
65995                params.push("advertiserIds", f.to_string());
65996            }
65997        }
65998
65999        params.extend(self._additional_params.iter());
66000
66001        params.push("alt", "json");
66002        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects";
66003        if self._scopes.is_empty() {
66004            self._scopes
66005                .insert(Scope::Dfatrafficking.as_ref().to_string());
66006        }
66007
66008        #[allow(clippy::single_element_loop)]
66009        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
66010            url = params.uri_replacement(url, param_name, find_this, false);
66011        }
66012        {
66013            let to_remove = ["profileId"];
66014            params.remove_params(&to_remove);
66015        }
66016
66017        let url = params.parse_with_url(&url);
66018
66019        loop {
66020            let token = match self
66021                .hub
66022                .auth
66023                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
66024                .await
66025            {
66026                Ok(token) => token,
66027                Err(e) => match dlg.token(e) {
66028                    Ok(token) => token,
66029                    Err(e) => {
66030                        dlg.finished(false);
66031                        return Err(common::Error::MissingToken(e));
66032                    }
66033                },
66034            };
66035            let mut req_result = {
66036                let client = &self.hub.client;
66037                dlg.pre_request();
66038                let mut req_builder = hyper::Request::builder()
66039                    .method(hyper::Method::GET)
66040                    .uri(url.as_str())
66041                    .header(USER_AGENT, self.hub._user_agent.clone());
66042
66043                if let Some(token) = token.as_ref() {
66044                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
66045                }
66046
66047                let request = req_builder
66048                    .header(CONTENT_LENGTH, 0_u64)
66049                    .body(common::to_body::<String>(None));
66050
66051                client.request(request.unwrap()).await
66052            };
66053
66054            match req_result {
66055                Err(err) => {
66056                    if let common::Retry::After(d) = dlg.http_error(&err) {
66057                        sleep(d).await;
66058                        continue;
66059                    }
66060                    dlg.finished(false);
66061                    return Err(common::Error::HttpError(err));
66062                }
66063                Ok(res) => {
66064                    let (mut parts, body) = res.into_parts();
66065                    let mut body = common::Body::new(body);
66066                    if !parts.status.is_success() {
66067                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66068                        let error = serde_json::from_str(&common::to_string(&bytes));
66069                        let response = common::to_response(parts, bytes.into());
66070
66071                        if let common::Retry::After(d) =
66072                            dlg.http_failure(&response, error.as_ref().ok())
66073                        {
66074                            sleep(d).await;
66075                            continue;
66076                        }
66077
66078                        dlg.finished(false);
66079
66080                        return Err(match error {
66081                            Ok(value) => common::Error::BadRequest(value),
66082                            _ => common::Error::Failure(response),
66083                        });
66084                    }
66085                    let response = {
66086                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66087                        let encoded = common::to_string(&bytes);
66088                        match serde_json::from_str(&encoded) {
66089                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
66090                            Err(error) => {
66091                                dlg.response_json_decode_error(&encoded, &error);
66092                                return Err(common::Error::JsonDecodeError(
66093                                    encoded.to_string(),
66094                                    error,
66095                                ));
66096                            }
66097                        }
66098                    };
66099
66100                    dlg.finished(true);
66101                    return Ok(response);
66102                }
66103            }
66104        }
66105    }
66106
66107    /// User profile ID associated with this request.
66108    ///
66109    /// Sets the *profile id* path property to the given value.
66110    ///
66111    /// Even though the property as already been set when instantiating this call,
66112    /// we provide this method for API completeness.
66113    pub fn profile_id(mut self, new_value: i64) -> ProjectListCall<'a, C> {
66114        self._profile_id = new_value;
66115        self
66116    }
66117    /// Order of sorted results.
66118    ///
66119    /// Sets the *sort order* query property to the given value.
66120    pub fn sort_order(mut self, new_value: &str) -> ProjectListCall<'a, C> {
66121        self._sort_order = Some(new_value.to_string());
66122        self
66123    }
66124    /// Field by which to sort the list.
66125    ///
66126    /// Sets the *sort field* query property to the given value.
66127    pub fn sort_field(mut self, new_value: &str) -> ProjectListCall<'a, C> {
66128        self._sort_field = Some(new_value.to_string());
66129        self
66130    }
66131    /// Allows searching for projects by name or ID. Wildcards (*) are allowed. For example, "project*2015" will return projects with names like "project June 2015", "project April 2015", or simply "project 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "project" will match projects with name "my project", "project 2015", or simply "project".
66132    ///
66133    /// Sets the *search string* query property to the given value.
66134    pub fn search_string(mut self, new_value: &str) -> ProjectListCall<'a, C> {
66135        self._search_string = Some(new_value.to_string());
66136        self
66137    }
66138    /// Value of the nextPageToken from the previous result page.
66139    ///
66140    /// Sets the *page token* query property to the given value.
66141    pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C> {
66142        self._page_token = Some(new_value.to_string());
66143        self
66144    }
66145    /// Maximum number of results to return.
66146    ///
66147    /// Sets the *max results* query property to the given value.
66148    pub fn max_results(mut self, new_value: i32) -> ProjectListCall<'a, C> {
66149        self._max_results = Some(new_value);
66150        self
66151    }
66152    /// Select only projects with these IDs.
66153    ///
66154    /// Append the given value to the *ids* query property.
66155    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
66156    pub fn add_ids(mut self, new_value: i64) -> ProjectListCall<'a, C> {
66157        self._ids.push(new_value);
66158        self
66159    }
66160    /// Select only projects with these advertiser IDs.
66161    ///
66162    /// Append the given value to the *advertiser ids* query property.
66163    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
66164    pub fn add_advertiser_ids(mut self, new_value: i64) -> ProjectListCall<'a, C> {
66165        self._advertiser_ids.push(new_value);
66166        self
66167    }
66168    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
66169    /// while executing the actual API request.
66170    ///
66171    /// ````text
66172    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
66173    /// ````
66174    ///
66175    /// Sets the *delegate* property to the given value.
66176    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectListCall<'a, C> {
66177        self._delegate = Some(new_value);
66178        self
66179    }
66180
66181    /// Set any additional parameter of the query string used in the request.
66182    /// It should be used to set parameters which are not yet available through their own
66183    /// setters.
66184    ///
66185    /// Please note that this method must not be used to set any of the known parameters
66186    /// which have their own setter method. If done anyway, the request will fail.
66187    ///
66188    /// # Additional Parameters
66189    ///
66190    /// * *alt* (query-string) - Data format for the response.
66191    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
66192    /// * *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.
66193    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
66194    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
66195    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
66196    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
66197    pub fn param<T>(mut self, name: T, value: T) -> ProjectListCall<'a, C>
66198    where
66199        T: AsRef<str>,
66200    {
66201        self._additional_params
66202            .insert(name.as_ref().to_string(), value.as_ref().to_string());
66203        self
66204    }
66205
66206    /// Identifies the authorization scope for the method you are building.
66207    ///
66208    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
66209    /// [`Scope::Dfatrafficking`].
66210    ///
66211    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
66212    /// tokens for more than one scope.
66213    ///
66214    /// Usually there is more than one suitable scope to authorize an operation, some of which may
66215    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
66216    /// sufficient, a read-write scope will do as well.
66217    pub fn add_scope<St>(mut self, scope: St) -> ProjectListCall<'a, C>
66218    where
66219        St: AsRef<str>,
66220    {
66221        self._scopes.insert(String::from(scope.as_ref()));
66222        self
66223    }
66224    /// Identifies the authorization scope(s) for the method you are building.
66225    ///
66226    /// See [`Self::add_scope()`] for details.
66227    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectListCall<'a, C>
66228    where
66229        I: IntoIterator<Item = St>,
66230        St: AsRef<str>,
66231    {
66232        self._scopes
66233            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
66234        self
66235    }
66236
66237    /// Removes all scopes, and no default scope will be used either.
66238    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
66239    /// for details).
66240    pub fn clear_scopes(mut self) -> ProjectListCall<'a, C> {
66241        self._scopes.clear();
66242        self
66243    }
66244}
66245
66246/// Retrieves a list of regions.
66247///
66248/// A builder for the *list* method supported by a *region* resource.
66249/// It is not used directly, but through a [`RegionMethods`] instance.
66250///
66251/// # Example
66252///
66253/// Instantiate a resource method builder
66254///
66255/// ```test_harness,no_run
66256/// # extern crate hyper;
66257/// # extern crate hyper_rustls;
66258/// # extern crate google_dfareporting3d2 as dfareporting3d2;
66259/// # async fn dox() {
66260/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
66261///
66262/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
66263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
66264/// #     secret,
66265/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
66266/// # ).build().await.unwrap();
66267///
66268/// # let client = hyper_util::client::legacy::Client::builder(
66269/// #     hyper_util::rt::TokioExecutor::new()
66270/// # )
66271/// # .build(
66272/// #     hyper_rustls::HttpsConnectorBuilder::new()
66273/// #         .with_native_roots()
66274/// #         .unwrap()
66275/// #         .https_or_http()
66276/// #         .enable_http1()
66277/// #         .build()
66278/// # );
66279/// # let mut hub = Dfareporting::new(client, auth);
66280/// // You can configure optional parameters by calling the respective setters at will, and
66281/// // execute the final call using `doit()`.
66282/// // Values shown here are possibly random and not representative !
66283/// let result = hub.regions().list(-19)
66284///              .doit().await;
66285/// # }
66286/// ```
66287pub struct RegionListCall<'a, C>
66288where
66289    C: 'a,
66290{
66291    hub: &'a Dfareporting<C>,
66292    _profile_id: i64,
66293    _delegate: Option<&'a mut dyn common::Delegate>,
66294    _additional_params: HashMap<String, String>,
66295    _scopes: BTreeSet<String>,
66296}
66297
66298impl<'a, C> common::CallBuilder for RegionListCall<'a, C> {}
66299
66300impl<'a, C> RegionListCall<'a, C>
66301where
66302    C: common::Connector,
66303{
66304    /// Perform the operation you have build so far.
66305    pub async fn doit(mut self) -> common::Result<(common::Response, RegionsListResponse)> {
66306        use std::borrow::Cow;
66307        use std::io::{Read, Seek};
66308
66309        use common::{url::Params, ToParts};
66310        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
66311
66312        let mut dd = common::DefaultDelegate;
66313        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
66314        dlg.begin(common::MethodInfo {
66315            id: "dfareporting.regions.list",
66316            http_method: hyper::Method::GET,
66317        });
66318
66319        for &field in ["alt", "profileId"].iter() {
66320            if self._additional_params.contains_key(field) {
66321                dlg.finished(false);
66322                return Err(common::Error::FieldClash(field));
66323            }
66324        }
66325
66326        let mut params = Params::with_capacity(3 + self._additional_params.len());
66327        params.push("profileId", self._profile_id.to_string());
66328
66329        params.extend(self._additional_params.iter());
66330
66331        params.push("alt", "json");
66332        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/regions";
66333        if self._scopes.is_empty() {
66334            self._scopes
66335                .insert(Scope::Dfatrafficking.as_ref().to_string());
66336        }
66337
66338        #[allow(clippy::single_element_loop)]
66339        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
66340            url = params.uri_replacement(url, param_name, find_this, false);
66341        }
66342        {
66343            let to_remove = ["profileId"];
66344            params.remove_params(&to_remove);
66345        }
66346
66347        let url = params.parse_with_url(&url);
66348
66349        loop {
66350            let token = match self
66351                .hub
66352                .auth
66353                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
66354                .await
66355            {
66356                Ok(token) => token,
66357                Err(e) => match dlg.token(e) {
66358                    Ok(token) => token,
66359                    Err(e) => {
66360                        dlg.finished(false);
66361                        return Err(common::Error::MissingToken(e));
66362                    }
66363                },
66364            };
66365            let mut req_result = {
66366                let client = &self.hub.client;
66367                dlg.pre_request();
66368                let mut req_builder = hyper::Request::builder()
66369                    .method(hyper::Method::GET)
66370                    .uri(url.as_str())
66371                    .header(USER_AGENT, self.hub._user_agent.clone());
66372
66373                if let Some(token) = token.as_ref() {
66374                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
66375                }
66376
66377                let request = req_builder
66378                    .header(CONTENT_LENGTH, 0_u64)
66379                    .body(common::to_body::<String>(None));
66380
66381                client.request(request.unwrap()).await
66382            };
66383
66384            match req_result {
66385                Err(err) => {
66386                    if let common::Retry::After(d) = dlg.http_error(&err) {
66387                        sleep(d).await;
66388                        continue;
66389                    }
66390                    dlg.finished(false);
66391                    return Err(common::Error::HttpError(err));
66392                }
66393                Ok(res) => {
66394                    let (mut parts, body) = res.into_parts();
66395                    let mut body = common::Body::new(body);
66396                    if !parts.status.is_success() {
66397                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66398                        let error = serde_json::from_str(&common::to_string(&bytes));
66399                        let response = common::to_response(parts, bytes.into());
66400
66401                        if let common::Retry::After(d) =
66402                            dlg.http_failure(&response, error.as_ref().ok())
66403                        {
66404                            sleep(d).await;
66405                            continue;
66406                        }
66407
66408                        dlg.finished(false);
66409
66410                        return Err(match error {
66411                            Ok(value) => common::Error::BadRequest(value),
66412                            _ => common::Error::Failure(response),
66413                        });
66414                    }
66415                    let response = {
66416                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66417                        let encoded = common::to_string(&bytes);
66418                        match serde_json::from_str(&encoded) {
66419                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
66420                            Err(error) => {
66421                                dlg.response_json_decode_error(&encoded, &error);
66422                                return Err(common::Error::JsonDecodeError(
66423                                    encoded.to_string(),
66424                                    error,
66425                                ));
66426                            }
66427                        }
66428                    };
66429
66430                    dlg.finished(true);
66431                    return Ok(response);
66432                }
66433            }
66434        }
66435    }
66436
66437    /// User profile ID associated with this request.
66438    ///
66439    /// Sets the *profile id* path property to the given value.
66440    ///
66441    /// Even though the property as already been set when instantiating this call,
66442    /// we provide this method for API completeness.
66443    pub fn profile_id(mut self, new_value: i64) -> RegionListCall<'a, C> {
66444        self._profile_id = new_value;
66445        self
66446    }
66447    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
66448    /// while executing the actual API request.
66449    ///
66450    /// ````text
66451    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
66452    /// ````
66453    ///
66454    /// Sets the *delegate* property to the given value.
66455    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> RegionListCall<'a, C> {
66456        self._delegate = Some(new_value);
66457        self
66458    }
66459
66460    /// Set any additional parameter of the query string used in the request.
66461    /// It should be used to set parameters which are not yet available through their own
66462    /// setters.
66463    ///
66464    /// Please note that this method must not be used to set any of the known parameters
66465    /// which have their own setter method. If done anyway, the request will fail.
66466    ///
66467    /// # Additional Parameters
66468    ///
66469    /// * *alt* (query-string) - Data format for the response.
66470    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
66471    /// * *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.
66472    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
66473    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
66474    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
66475    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
66476    pub fn param<T>(mut self, name: T, value: T) -> RegionListCall<'a, C>
66477    where
66478        T: AsRef<str>,
66479    {
66480        self._additional_params
66481            .insert(name.as_ref().to_string(), value.as_ref().to_string());
66482        self
66483    }
66484
66485    /// Identifies the authorization scope for the method you are building.
66486    ///
66487    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
66488    /// [`Scope::Dfatrafficking`].
66489    ///
66490    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
66491    /// tokens for more than one scope.
66492    ///
66493    /// Usually there is more than one suitable scope to authorize an operation, some of which may
66494    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
66495    /// sufficient, a read-write scope will do as well.
66496    pub fn add_scope<St>(mut self, scope: St) -> RegionListCall<'a, C>
66497    where
66498        St: AsRef<str>,
66499    {
66500        self._scopes.insert(String::from(scope.as_ref()));
66501        self
66502    }
66503    /// Identifies the authorization scope(s) for the method you are building.
66504    ///
66505    /// See [`Self::add_scope()`] for details.
66506    pub fn add_scopes<I, St>(mut self, scopes: I) -> RegionListCall<'a, C>
66507    where
66508        I: IntoIterator<Item = St>,
66509        St: AsRef<str>,
66510    {
66511        self._scopes
66512            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
66513        self
66514    }
66515
66516    /// Removes all scopes, and no default scope will be used either.
66517    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
66518    /// for details).
66519    pub fn clear_scopes(mut self) -> RegionListCall<'a, C> {
66520        self._scopes.clear();
66521        self
66522    }
66523}
66524
66525/// Gets one remarketing list share by remarketing list ID.
66526///
66527/// A builder for the *get* method supported by a *remarketingListShare* resource.
66528/// It is not used directly, but through a [`RemarketingListShareMethods`] instance.
66529///
66530/// # Example
66531///
66532/// Instantiate a resource method builder
66533///
66534/// ```test_harness,no_run
66535/// # extern crate hyper;
66536/// # extern crate hyper_rustls;
66537/// # extern crate google_dfareporting3d2 as dfareporting3d2;
66538/// # async fn dox() {
66539/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
66540///
66541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
66542/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
66543/// #     secret,
66544/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
66545/// # ).build().await.unwrap();
66546///
66547/// # let client = hyper_util::client::legacy::Client::builder(
66548/// #     hyper_util::rt::TokioExecutor::new()
66549/// # )
66550/// # .build(
66551/// #     hyper_rustls::HttpsConnectorBuilder::new()
66552/// #         .with_native_roots()
66553/// #         .unwrap()
66554/// #         .https_or_http()
66555/// #         .enable_http1()
66556/// #         .build()
66557/// # );
66558/// # let mut hub = Dfareporting::new(client, auth);
66559/// // You can configure optional parameters by calling the respective setters at will, and
66560/// // execute the final call using `doit()`.
66561/// // Values shown here are possibly random and not representative !
66562/// let result = hub.remarketing_list_shares().get(-29, -58)
66563///              .doit().await;
66564/// # }
66565/// ```
66566pub struct RemarketingListShareGetCall<'a, C>
66567where
66568    C: 'a,
66569{
66570    hub: &'a Dfareporting<C>,
66571    _profile_id: i64,
66572    _remarketing_list_id: i64,
66573    _delegate: Option<&'a mut dyn common::Delegate>,
66574    _additional_params: HashMap<String, String>,
66575    _scopes: BTreeSet<String>,
66576}
66577
66578impl<'a, C> common::CallBuilder for RemarketingListShareGetCall<'a, C> {}
66579
66580impl<'a, C> RemarketingListShareGetCall<'a, C>
66581where
66582    C: common::Connector,
66583{
66584    /// Perform the operation you have build so far.
66585    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingListShare)> {
66586        use std::borrow::Cow;
66587        use std::io::{Read, Seek};
66588
66589        use common::{url::Params, ToParts};
66590        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
66591
66592        let mut dd = common::DefaultDelegate;
66593        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
66594        dlg.begin(common::MethodInfo {
66595            id: "dfareporting.remarketingListShares.get",
66596            http_method: hyper::Method::GET,
66597        });
66598
66599        for &field in ["alt", "profileId", "remarketingListId"].iter() {
66600            if self._additional_params.contains_key(field) {
66601                dlg.finished(false);
66602                return Err(common::Error::FieldClash(field));
66603            }
66604        }
66605
66606        let mut params = Params::with_capacity(4 + self._additional_params.len());
66607        params.push("profileId", self._profile_id.to_string());
66608        params.push("remarketingListId", self._remarketing_list_id.to_string());
66609
66610        params.extend(self._additional_params.iter());
66611
66612        params.push("alt", "json");
66613        let mut url = self.hub._base_url.clone()
66614            + "userprofiles/{profileId}/remarketingListShares/{remarketingListId}";
66615        if self._scopes.is_empty() {
66616            self._scopes
66617                .insert(Scope::Dfatrafficking.as_ref().to_string());
66618        }
66619
66620        #[allow(clippy::single_element_loop)]
66621        for &(find_this, param_name) in [
66622            ("{profileId}", "profileId"),
66623            ("{remarketingListId}", "remarketingListId"),
66624        ]
66625        .iter()
66626        {
66627            url = params.uri_replacement(url, param_name, find_this, false);
66628        }
66629        {
66630            let to_remove = ["remarketingListId", "profileId"];
66631            params.remove_params(&to_remove);
66632        }
66633
66634        let url = params.parse_with_url(&url);
66635
66636        loop {
66637            let token = match self
66638                .hub
66639                .auth
66640                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
66641                .await
66642            {
66643                Ok(token) => token,
66644                Err(e) => match dlg.token(e) {
66645                    Ok(token) => token,
66646                    Err(e) => {
66647                        dlg.finished(false);
66648                        return Err(common::Error::MissingToken(e));
66649                    }
66650                },
66651            };
66652            let mut req_result = {
66653                let client = &self.hub.client;
66654                dlg.pre_request();
66655                let mut req_builder = hyper::Request::builder()
66656                    .method(hyper::Method::GET)
66657                    .uri(url.as_str())
66658                    .header(USER_AGENT, self.hub._user_agent.clone());
66659
66660                if let Some(token) = token.as_ref() {
66661                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
66662                }
66663
66664                let request = req_builder
66665                    .header(CONTENT_LENGTH, 0_u64)
66666                    .body(common::to_body::<String>(None));
66667
66668                client.request(request.unwrap()).await
66669            };
66670
66671            match req_result {
66672                Err(err) => {
66673                    if let common::Retry::After(d) = dlg.http_error(&err) {
66674                        sleep(d).await;
66675                        continue;
66676                    }
66677                    dlg.finished(false);
66678                    return Err(common::Error::HttpError(err));
66679                }
66680                Ok(res) => {
66681                    let (mut parts, body) = res.into_parts();
66682                    let mut body = common::Body::new(body);
66683                    if !parts.status.is_success() {
66684                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66685                        let error = serde_json::from_str(&common::to_string(&bytes));
66686                        let response = common::to_response(parts, bytes.into());
66687
66688                        if let common::Retry::After(d) =
66689                            dlg.http_failure(&response, error.as_ref().ok())
66690                        {
66691                            sleep(d).await;
66692                            continue;
66693                        }
66694
66695                        dlg.finished(false);
66696
66697                        return Err(match error {
66698                            Ok(value) => common::Error::BadRequest(value),
66699                            _ => common::Error::Failure(response),
66700                        });
66701                    }
66702                    let response = {
66703                        let bytes = common::to_bytes(body).await.unwrap_or_default();
66704                        let encoded = common::to_string(&bytes);
66705                        match serde_json::from_str(&encoded) {
66706                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
66707                            Err(error) => {
66708                                dlg.response_json_decode_error(&encoded, &error);
66709                                return Err(common::Error::JsonDecodeError(
66710                                    encoded.to_string(),
66711                                    error,
66712                                ));
66713                            }
66714                        }
66715                    };
66716
66717                    dlg.finished(true);
66718                    return Ok(response);
66719                }
66720            }
66721        }
66722    }
66723
66724    /// User profile ID associated with this request.
66725    ///
66726    /// Sets the *profile id* path property to the given value.
66727    ///
66728    /// Even though the property as already been set when instantiating this call,
66729    /// we provide this method for API completeness.
66730    pub fn profile_id(mut self, new_value: i64) -> RemarketingListShareGetCall<'a, C> {
66731        self._profile_id = new_value;
66732        self
66733    }
66734    /// Remarketing list ID.
66735    ///
66736    /// Sets the *remarketing list id* path property to the given value.
66737    ///
66738    /// Even though the property as already been set when instantiating this call,
66739    /// we provide this method for API completeness.
66740    pub fn remarketing_list_id(mut self, new_value: i64) -> RemarketingListShareGetCall<'a, C> {
66741        self._remarketing_list_id = new_value;
66742        self
66743    }
66744    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
66745    /// while executing the actual API request.
66746    ///
66747    /// ````text
66748    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
66749    /// ````
66750    ///
66751    /// Sets the *delegate* property to the given value.
66752    pub fn delegate(
66753        mut self,
66754        new_value: &'a mut dyn common::Delegate,
66755    ) -> RemarketingListShareGetCall<'a, C> {
66756        self._delegate = Some(new_value);
66757        self
66758    }
66759
66760    /// Set any additional parameter of the query string used in the request.
66761    /// It should be used to set parameters which are not yet available through their own
66762    /// setters.
66763    ///
66764    /// Please note that this method must not be used to set any of the known parameters
66765    /// which have their own setter method. If done anyway, the request will fail.
66766    ///
66767    /// # Additional Parameters
66768    ///
66769    /// * *alt* (query-string) - Data format for the response.
66770    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
66771    /// * *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.
66772    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
66773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
66774    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
66775    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
66776    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListShareGetCall<'a, C>
66777    where
66778        T: AsRef<str>,
66779    {
66780        self._additional_params
66781            .insert(name.as_ref().to_string(), value.as_ref().to_string());
66782        self
66783    }
66784
66785    /// Identifies the authorization scope for the method you are building.
66786    ///
66787    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
66788    /// [`Scope::Dfatrafficking`].
66789    ///
66790    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
66791    /// tokens for more than one scope.
66792    ///
66793    /// Usually there is more than one suitable scope to authorize an operation, some of which may
66794    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
66795    /// sufficient, a read-write scope will do as well.
66796    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListShareGetCall<'a, C>
66797    where
66798        St: AsRef<str>,
66799    {
66800        self._scopes.insert(String::from(scope.as_ref()));
66801        self
66802    }
66803    /// Identifies the authorization scope(s) for the method you are building.
66804    ///
66805    /// See [`Self::add_scope()`] for details.
66806    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListShareGetCall<'a, C>
66807    where
66808        I: IntoIterator<Item = St>,
66809        St: AsRef<str>,
66810    {
66811        self._scopes
66812            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
66813        self
66814    }
66815
66816    /// Removes all scopes, and no default scope will be used either.
66817    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
66818    /// for details).
66819    pub fn clear_scopes(mut self) -> RemarketingListShareGetCall<'a, C> {
66820        self._scopes.clear();
66821        self
66822    }
66823}
66824
66825/// Updates an existing remarketing list share. This method supports patch semantics.
66826///
66827/// A builder for the *patch* method supported by a *remarketingListShare* resource.
66828/// It is not used directly, but through a [`RemarketingListShareMethods`] instance.
66829///
66830/// # Example
66831///
66832/// Instantiate a resource method builder
66833///
66834/// ```test_harness,no_run
66835/// # extern crate hyper;
66836/// # extern crate hyper_rustls;
66837/// # extern crate google_dfareporting3d2 as dfareporting3d2;
66838/// use dfareporting3d2::api::RemarketingListShare;
66839/// # async fn dox() {
66840/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
66841///
66842/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
66843/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
66844/// #     secret,
66845/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
66846/// # ).build().await.unwrap();
66847///
66848/// # let client = hyper_util::client::legacy::Client::builder(
66849/// #     hyper_util::rt::TokioExecutor::new()
66850/// # )
66851/// # .build(
66852/// #     hyper_rustls::HttpsConnectorBuilder::new()
66853/// #         .with_native_roots()
66854/// #         .unwrap()
66855/// #         .https_or_http()
66856/// #         .enable_http1()
66857/// #         .build()
66858/// # );
66859/// # let mut hub = Dfareporting::new(client, auth);
66860/// // As the method needs a request, you would usually fill it with the desired information
66861/// // into the respective structure. Some of the parts shown here might not be applicable !
66862/// // Values shown here are possibly random and not representative !
66863/// let mut req = RemarketingListShare::default();
66864///
66865/// // You can configure optional parameters by calling the respective setters at will, and
66866/// // execute the final call using `doit()`.
66867/// // Values shown here are possibly random and not representative !
66868/// let result = hub.remarketing_list_shares().patch(req, -80, -25)
66869///              .doit().await;
66870/// # }
66871/// ```
66872pub struct RemarketingListSharePatchCall<'a, C>
66873where
66874    C: 'a,
66875{
66876    hub: &'a Dfareporting<C>,
66877    _request: RemarketingListShare,
66878    _profile_id: i64,
66879    _remarketing_list_id: i64,
66880    _delegate: Option<&'a mut dyn common::Delegate>,
66881    _additional_params: HashMap<String, String>,
66882    _scopes: BTreeSet<String>,
66883}
66884
66885impl<'a, C> common::CallBuilder for RemarketingListSharePatchCall<'a, C> {}
66886
66887impl<'a, C> RemarketingListSharePatchCall<'a, C>
66888where
66889    C: common::Connector,
66890{
66891    /// Perform the operation you have build so far.
66892    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingListShare)> {
66893        use std::borrow::Cow;
66894        use std::io::{Read, Seek};
66895
66896        use common::{url::Params, ToParts};
66897        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
66898
66899        let mut dd = common::DefaultDelegate;
66900        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
66901        dlg.begin(common::MethodInfo {
66902            id: "dfareporting.remarketingListShares.patch",
66903            http_method: hyper::Method::PATCH,
66904        });
66905
66906        for &field in ["alt", "profileId", "remarketingListId"].iter() {
66907            if self._additional_params.contains_key(field) {
66908                dlg.finished(false);
66909                return Err(common::Error::FieldClash(field));
66910            }
66911        }
66912
66913        let mut params = Params::with_capacity(5 + self._additional_params.len());
66914        params.push("profileId", self._profile_id.to_string());
66915        params.push("remarketingListId", self._remarketing_list_id.to_string());
66916
66917        params.extend(self._additional_params.iter());
66918
66919        params.push("alt", "json");
66920        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingListShares";
66921        if self._scopes.is_empty() {
66922            self._scopes
66923                .insert(Scope::Dfatrafficking.as_ref().to_string());
66924        }
66925
66926        #[allow(clippy::single_element_loop)]
66927        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
66928            url = params.uri_replacement(url, param_name, find_this, false);
66929        }
66930        {
66931            let to_remove = ["profileId"];
66932            params.remove_params(&to_remove);
66933        }
66934
66935        let url = params.parse_with_url(&url);
66936
66937        let mut json_mime_type = mime::APPLICATION_JSON;
66938        let mut request_value_reader = {
66939            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
66940            common::remove_json_null_values(&mut value);
66941            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
66942            serde_json::to_writer(&mut dst, &value).unwrap();
66943            dst
66944        };
66945        let request_size = request_value_reader
66946            .seek(std::io::SeekFrom::End(0))
66947            .unwrap();
66948        request_value_reader
66949            .seek(std::io::SeekFrom::Start(0))
66950            .unwrap();
66951
66952        loop {
66953            let token = match self
66954                .hub
66955                .auth
66956                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
66957                .await
66958            {
66959                Ok(token) => token,
66960                Err(e) => match dlg.token(e) {
66961                    Ok(token) => token,
66962                    Err(e) => {
66963                        dlg.finished(false);
66964                        return Err(common::Error::MissingToken(e));
66965                    }
66966                },
66967            };
66968            request_value_reader
66969                .seek(std::io::SeekFrom::Start(0))
66970                .unwrap();
66971            let mut req_result = {
66972                let client = &self.hub.client;
66973                dlg.pre_request();
66974                let mut req_builder = hyper::Request::builder()
66975                    .method(hyper::Method::PATCH)
66976                    .uri(url.as_str())
66977                    .header(USER_AGENT, self.hub._user_agent.clone());
66978
66979                if let Some(token) = token.as_ref() {
66980                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
66981                }
66982
66983                let request = req_builder
66984                    .header(CONTENT_TYPE, json_mime_type.to_string())
66985                    .header(CONTENT_LENGTH, request_size as u64)
66986                    .body(common::to_body(
66987                        request_value_reader.get_ref().clone().into(),
66988                    ));
66989
66990                client.request(request.unwrap()).await
66991            };
66992
66993            match req_result {
66994                Err(err) => {
66995                    if let common::Retry::After(d) = dlg.http_error(&err) {
66996                        sleep(d).await;
66997                        continue;
66998                    }
66999                    dlg.finished(false);
67000                    return Err(common::Error::HttpError(err));
67001                }
67002                Ok(res) => {
67003                    let (mut parts, body) = res.into_parts();
67004                    let mut body = common::Body::new(body);
67005                    if !parts.status.is_success() {
67006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67007                        let error = serde_json::from_str(&common::to_string(&bytes));
67008                        let response = common::to_response(parts, bytes.into());
67009
67010                        if let common::Retry::After(d) =
67011                            dlg.http_failure(&response, error.as_ref().ok())
67012                        {
67013                            sleep(d).await;
67014                            continue;
67015                        }
67016
67017                        dlg.finished(false);
67018
67019                        return Err(match error {
67020                            Ok(value) => common::Error::BadRequest(value),
67021                            _ => common::Error::Failure(response),
67022                        });
67023                    }
67024                    let response = {
67025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67026                        let encoded = common::to_string(&bytes);
67027                        match serde_json::from_str(&encoded) {
67028                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
67029                            Err(error) => {
67030                                dlg.response_json_decode_error(&encoded, &error);
67031                                return Err(common::Error::JsonDecodeError(
67032                                    encoded.to_string(),
67033                                    error,
67034                                ));
67035                            }
67036                        }
67037                    };
67038
67039                    dlg.finished(true);
67040                    return Ok(response);
67041                }
67042            }
67043        }
67044    }
67045
67046    ///
67047    /// Sets the *request* property to the given value.
67048    ///
67049    /// Even though the property as already been set when instantiating this call,
67050    /// we provide this method for API completeness.
67051    pub fn request(
67052        mut self,
67053        new_value: RemarketingListShare,
67054    ) -> RemarketingListSharePatchCall<'a, C> {
67055        self._request = new_value;
67056        self
67057    }
67058    /// User profile ID associated with this request.
67059    ///
67060    /// Sets the *profile id* path property to the given value.
67061    ///
67062    /// Even though the property as already been set when instantiating this call,
67063    /// we provide this method for API completeness.
67064    pub fn profile_id(mut self, new_value: i64) -> RemarketingListSharePatchCall<'a, C> {
67065        self._profile_id = new_value;
67066        self
67067    }
67068    /// Remarketing list ID.
67069    ///
67070    /// Sets the *remarketing list id* query property to the given value.
67071    ///
67072    /// Even though the property as already been set when instantiating this call,
67073    /// we provide this method for API completeness.
67074    pub fn remarketing_list_id(mut self, new_value: i64) -> RemarketingListSharePatchCall<'a, C> {
67075        self._remarketing_list_id = new_value;
67076        self
67077    }
67078    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
67079    /// while executing the actual API request.
67080    ///
67081    /// ````text
67082    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
67083    /// ````
67084    ///
67085    /// Sets the *delegate* property to the given value.
67086    pub fn delegate(
67087        mut self,
67088        new_value: &'a mut dyn common::Delegate,
67089    ) -> RemarketingListSharePatchCall<'a, C> {
67090        self._delegate = Some(new_value);
67091        self
67092    }
67093
67094    /// Set any additional parameter of the query string used in the request.
67095    /// It should be used to set parameters which are not yet available through their own
67096    /// setters.
67097    ///
67098    /// Please note that this method must not be used to set any of the known parameters
67099    /// which have their own setter method. If done anyway, the request will fail.
67100    ///
67101    /// # Additional Parameters
67102    ///
67103    /// * *alt* (query-string) - Data format for the response.
67104    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
67105    /// * *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.
67106    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
67107    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
67108    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
67109    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
67110    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListSharePatchCall<'a, C>
67111    where
67112        T: AsRef<str>,
67113    {
67114        self._additional_params
67115            .insert(name.as_ref().to_string(), value.as_ref().to_string());
67116        self
67117    }
67118
67119    /// Identifies the authorization scope for the method you are building.
67120    ///
67121    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
67122    /// [`Scope::Dfatrafficking`].
67123    ///
67124    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
67125    /// tokens for more than one scope.
67126    ///
67127    /// Usually there is more than one suitable scope to authorize an operation, some of which may
67128    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
67129    /// sufficient, a read-write scope will do as well.
67130    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListSharePatchCall<'a, C>
67131    where
67132        St: AsRef<str>,
67133    {
67134        self._scopes.insert(String::from(scope.as_ref()));
67135        self
67136    }
67137    /// Identifies the authorization scope(s) for the method you are building.
67138    ///
67139    /// See [`Self::add_scope()`] for details.
67140    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListSharePatchCall<'a, C>
67141    where
67142        I: IntoIterator<Item = St>,
67143        St: AsRef<str>,
67144    {
67145        self._scopes
67146            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
67147        self
67148    }
67149
67150    /// Removes all scopes, and no default scope will be used either.
67151    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
67152    /// for details).
67153    pub fn clear_scopes(mut self) -> RemarketingListSharePatchCall<'a, C> {
67154        self._scopes.clear();
67155        self
67156    }
67157}
67158
67159/// Updates an existing remarketing list share.
67160///
67161/// A builder for the *update* method supported by a *remarketingListShare* resource.
67162/// It is not used directly, but through a [`RemarketingListShareMethods`] instance.
67163///
67164/// # Example
67165///
67166/// Instantiate a resource method builder
67167///
67168/// ```test_harness,no_run
67169/// # extern crate hyper;
67170/// # extern crate hyper_rustls;
67171/// # extern crate google_dfareporting3d2 as dfareporting3d2;
67172/// use dfareporting3d2::api::RemarketingListShare;
67173/// # async fn dox() {
67174/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
67175///
67176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
67177/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67178/// #     secret,
67179/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
67180/// # ).build().await.unwrap();
67181///
67182/// # let client = hyper_util::client::legacy::Client::builder(
67183/// #     hyper_util::rt::TokioExecutor::new()
67184/// # )
67185/// # .build(
67186/// #     hyper_rustls::HttpsConnectorBuilder::new()
67187/// #         .with_native_roots()
67188/// #         .unwrap()
67189/// #         .https_or_http()
67190/// #         .enable_http1()
67191/// #         .build()
67192/// # );
67193/// # let mut hub = Dfareporting::new(client, auth);
67194/// // As the method needs a request, you would usually fill it with the desired information
67195/// // into the respective structure. Some of the parts shown here might not be applicable !
67196/// // Values shown here are possibly random and not representative !
67197/// let mut req = RemarketingListShare::default();
67198///
67199/// // You can configure optional parameters by calling the respective setters at will, and
67200/// // execute the final call using `doit()`.
67201/// // Values shown here are possibly random and not representative !
67202/// let result = hub.remarketing_list_shares().update(req, -53)
67203///              .doit().await;
67204/// # }
67205/// ```
67206pub struct RemarketingListShareUpdateCall<'a, C>
67207where
67208    C: 'a,
67209{
67210    hub: &'a Dfareporting<C>,
67211    _request: RemarketingListShare,
67212    _profile_id: i64,
67213    _delegate: Option<&'a mut dyn common::Delegate>,
67214    _additional_params: HashMap<String, String>,
67215    _scopes: BTreeSet<String>,
67216}
67217
67218impl<'a, C> common::CallBuilder for RemarketingListShareUpdateCall<'a, C> {}
67219
67220impl<'a, C> RemarketingListShareUpdateCall<'a, C>
67221where
67222    C: common::Connector,
67223{
67224    /// Perform the operation you have build so far.
67225    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingListShare)> {
67226        use std::borrow::Cow;
67227        use std::io::{Read, Seek};
67228
67229        use common::{url::Params, ToParts};
67230        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
67231
67232        let mut dd = common::DefaultDelegate;
67233        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
67234        dlg.begin(common::MethodInfo {
67235            id: "dfareporting.remarketingListShares.update",
67236            http_method: hyper::Method::PUT,
67237        });
67238
67239        for &field in ["alt", "profileId"].iter() {
67240            if self._additional_params.contains_key(field) {
67241                dlg.finished(false);
67242                return Err(common::Error::FieldClash(field));
67243            }
67244        }
67245
67246        let mut params = Params::with_capacity(4 + self._additional_params.len());
67247        params.push("profileId", self._profile_id.to_string());
67248
67249        params.extend(self._additional_params.iter());
67250
67251        params.push("alt", "json");
67252        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingListShares";
67253        if self._scopes.is_empty() {
67254            self._scopes
67255                .insert(Scope::Dfatrafficking.as_ref().to_string());
67256        }
67257
67258        #[allow(clippy::single_element_loop)]
67259        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
67260            url = params.uri_replacement(url, param_name, find_this, false);
67261        }
67262        {
67263            let to_remove = ["profileId"];
67264            params.remove_params(&to_remove);
67265        }
67266
67267        let url = params.parse_with_url(&url);
67268
67269        let mut json_mime_type = mime::APPLICATION_JSON;
67270        let mut request_value_reader = {
67271            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
67272            common::remove_json_null_values(&mut value);
67273            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
67274            serde_json::to_writer(&mut dst, &value).unwrap();
67275            dst
67276        };
67277        let request_size = request_value_reader
67278            .seek(std::io::SeekFrom::End(0))
67279            .unwrap();
67280        request_value_reader
67281            .seek(std::io::SeekFrom::Start(0))
67282            .unwrap();
67283
67284        loop {
67285            let token = match self
67286                .hub
67287                .auth
67288                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
67289                .await
67290            {
67291                Ok(token) => token,
67292                Err(e) => match dlg.token(e) {
67293                    Ok(token) => token,
67294                    Err(e) => {
67295                        dlg.finished(false);
67296                        return Err(common::Error::MissingToken(e));
67297                    }
67298                },
67299            };
67300            request_value_reader
67301                .seek(std::io::SeekFrom::Start(0))
67302                .unwrap();
67303            let mut req_result = {
67304                let client = &self.hub.client;
67305                dlg.pre_request();
67306                let mut req_builder = hyper::Request::builder()
67307                    .method(hyper::Method::PUT)
67308                    .uri(url.as_str())
67309                    .header(USER_AGENT, self.hub._user_agent.clone());
67310
67311                if let Some(token) = token.as_ref() {
67312                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
67313                }
67314
67315                let request = req_builder
67316                    .header(CONTENT_TYPE, json_mime_type.to_string())
67317                    .header(CONTENT_LENGTH, request_size as u64)
67318                    .body(common::to_body(
67319                        request_value_reader.get_ref().clone().into(),
67320                    ));
67321
67322                client.request(request.unwrap()).await
67323            };
67324
67325            match req_result {
67326                Err(err) => {
67327                    if let common::Retry::After(d) = dlg.http_error(&err) {
67328                        sleep(d).await;
67329                        continue;
67330                    }
67331                    dlg.finished(false);
67332                    return Err(common::Error::HttpError(err));
67333                }
67334                Ok(res) => {
67335                    let (mut parts, body) = res.into_parts();
67336                    let mut body = common::Body::new(body);
67337                    if !parts.status.is_success() {
67338                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67339                        let error = serde_json::from_str(&common::to_string(&bytes));
67340                        let response = common::to_response(parts, bytes.into());
67341
67342                        if let common::Retry::After(d) =
67343                            dlg.http_failure(&response, error.as_ref().ok())
67344                        {
67345                            sleep(d).await;
67346                            continue;
67347                        }
67348
67349                        dlg.finished(false);
67350
67351                        return Err(match error {
67352                            Ok(value) => common::Error::BadRequest(value),
67353                            _ => common::Error::Failure(response),
67354                        });
67355                    }
67356                    let response = {
67357                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67358                        let encoded = common::to_string(&bytes);
67359                        match serde_json::from_str(&encoded) {
67360                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
67361                            Err(error) => {
67362                                dlg.response_json_decode_error(&encoded, &error);
67363                                return Err(common::Error::JsonDecodeError(
67364                                    encoded.to_string(),
67365                                    error,
67366                                ));
67367                            }
67368                        }
67369                    };
67370
67371                    dlg.finished(true);
67372                    return Ok(response);
67373                }
67374            }
67375        }
67376    }
67377
67378    ///
67379    /// Sets the *request* property to the given value.
67380    ///
67381    /// Even though the property as already been set when instantiating this call,
67382    /// we provide this method for API completeness.
67383    pub fn request(
67384        mut self,
67385        new_value: RemarketingListShare,
67386    ) -> RemarketingListShareUpdateCall<'a, C> {
67387        self._request = new_value;
67388        self
67389    }
67390    /// User profile ID associated with this request.
67391    ///
67392    /// Sets the *profile id* path property to the given value.
67393    ///
67394    /// Even though the property as already been set when instantiating this call,
67395    /// we provide this method for API completeness.
67396    pub fn profile_id(mut self, new_value: i64) -> RemarketingListShareUpdateCall<'a, C> {
67397        self._profile_id = new_value;
67398        self
67399    }
67400    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
67401    /// while executing the actual API request.
67402    ///
67403    /// ````text
67404    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
67405    /// ````
67406    ///
67407    /// Sets the *delegate* property to the given value.
67408    pub fn delegate(
67409        mut self,
67410        new_value: &'a mut dyn common::Delegate,
67411    ) -> RemarketingListShareUpdateCall<'a, C> {
67412        self._delegate = Some(new_value);
67413        self
67414    }
67415
67416    /// Set any additional parameter of the query string used in the request.
67417    /// It should be used to set parameters which are not yet available through their own
67418    /// setters.
67419    ///
67420    /// Please note that this method must not be used to set any of the known parameters
67421    /// which have their own setter method. If done anyway, the request will fail.
67422    ///
67423    /// # Additional Parameters
67424    ///
67425    /// * *alt* (query-string) - Data format for the response.
67426    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
67427    /// * *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.
67428    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
67429    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
67430    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
67431    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
67432    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListShareUpdateCall<'a, C>
67433    where
67434        T: AsRef<str>,
67435    {
67436        self._additional_params
67437            .insert(name.as_ref().to_string(), value.as_ref().to_string());
67438        self
67439    }
67440
67441    /// Identifies the authorization scope for the method you are building.
67442    ///
67443    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
67444    /// [`Scope::Dfatrafficking`].
67445    ///
67446    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
67447    /// tokens for more than one scope.
67448    ///
67449    /// Usually there is more than one suitable scope to authorize an operation, some of which may
67450    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
67451    /// sufficient, a read-write scope will do as well.
67452    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListShareUpdateCall<'a, C>
67453    where
67454        St: AsRef<str>,
67455    {
67456        self._scopes.insert(String::from(scope.as_ref()));
67457        self
67458    }
67459    /// Identifies the authorization scope(s) for the method you are building.
67460    ///
67461    /// See [`Self::add_scope()`] for details.
67462    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListShareUpdateCall<'a, C>
67463    where
67464        I: IntoIterator<Item = St>,
67465        St: AsRef<str>,
67466    {
67467        self._scopes
67468            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
67469        self
67470    }
67471
67472    /// Removes all scopes, and no default scope will be used either.
67473    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
67474    /// for details).
67475    pub fn clear_scopes(mut self) -> RemarketingListShareUpdateCall<'a, C> {
67476        self._scopes.clear();
67477        self
67478    }
67479}
67480
67481/// Gets one remarketing list by ID.
67482///
67483/// A builder for the *get* method supported by a *remarketingList* resource.
67484/// It is not used directly, but through a [`RemarketingListMethods`] instance.
67485///
67486/// # Example
67487///
67488/// Instantiate a resource method builder
67489///
67490/// ```test_harness,no_run
67491/// # extern crate hyper;
67492/// # extern crate hyper_rustls;
67493/// # extern crate google_dfareporting3d2 as dfareporting3d2;
67494/// # async fn dox() {
67495/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
67496///
67497/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
67498/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67499/// #     secret,
67500/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
67501/// # ).build().await.unwrap();
67502///
67503/// # let client = hyper_util::client::legacy::Client::builder(
67504/// #     hyper_util::rt::TokioExecutor::new()
67505/// # )
67506/// # .build(
67507/// #     hyper_rustls::HttpsConnectorBuilder::new()
67508/// #         .with_native_roots()
67509/// #         .unwrap()
67510/// #         .https_or_http()
67511/// #         .enable_http1()
67512/// #         .build()
67513/// # );
67514/// # let mut hub = Dfareporting::new(client, auth);
67515/// // You can configure optional parameters by calling the respective setters at will, and
67516/// // execute the final call using `doit()`.
67517/// // Values shown here are possibly random and not representative !
67518/// let result = hub.remarketing_lists().get(-35, -17)
67519///              .doit().await;
67520/// # }
67521/// ```
67522pub struct RemarketingListGetCall<'a, C>
67523where
67524    C: 'a,
67525{
67526    hub: &'a Dfareporting<C>,
67527    _profile_id: i64,
67528    _id: i64,
67529    _delegate: Option<&'a mut dyn common::Delegate>,
67530    _additional_params: HashMap<String, String>,
67531    _scopes: BTreeSet<String>,
67532}
67533
67534impl<'a, C> common::CallBuilder for RemarketingListGetCall<'a, C> {}
67535
67536impl<'a, C> RemarketingListGetCall<'a, C>
67537where
67538    C: common::Connector,
67539{
67540    /// Perform the operation you have build so far.
67541    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingList)> {
67542        use std::borrow::Cow;
67543        use std::io::{Read, Seek};
67544
67545        use common::{url::Params, ToParts};
67546        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
67547
67548        let mut dd = common::DefaultDelegate;
67549        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
67550        dlg.begin(common::MethodInfo {
67551            id: "dfareporting.remarketingLists.get",
67552            http_method: hyper::Method::GET,
67553        });
67554
67555        for &field in ["alt", "profileId", "id"].iter() {
67556            if self._additional_params.contains_key(field) {
67557                dlg.finished(false);
67558                return Err(common::Error::FieldClash(field));
67559            }
67560        }
67561
67562        let mut params = Params::with_capacity(4 + self._additional_params.len());
67563        params.push("profileId", self._profile_id.to_string());
67564        params.push("id", self._id.to_string());
67565
67566        params.extend(self._additional_params.iter());
67567
67568        params.push("alt", "json");
67569        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists/{id}";
67570        if self._scopes.is_empty() {
67571            self._scopes
67572                .insert(Scope::Dfatrafficking.as_ref().to_string());
67573        }
67574
67575        #[allow(clippy::single_element_loop)]
67576        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
67577            url = params.uri_replacement(url, param_name, find_this, false);
67578        }
67579        {
67580            let to_remove = ["id", "profileId"];
67581            params.remove_params(&to_remove);
67582        }
67583
67584        let url = params.parse_with_url(&url);
67585
67586        loop {
67587            let token = match self
67588                .hub
67589                .auth
67590                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
67591                .await
67592            {
67593                Ok(token) => token,
67594                Err(e) => match dlg.token(e) {
67595                    Ok(token) => token,
67596                    Err(e) => {
67597                        dlg.finished(false);
67598                        return Err(common::Error::MissingToken(e));
67599                    }
67600                },
67601            };
67602            let mut req_result = {
67603                let client = &self.hub.client;
67604                dlg.pre_request();
67605                let mut req_builder = hyper::Request::builder()
67606                    .method(hyper::Method::GET)
67607                    .uri(url.as_str())
67608                    .header(USER_AGENT, self.hub._user_agent.clone());
67609
67610                if let Some(token) = token.as_ref() {
67611                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
67612                }
67613
67614                let request = req_builder
67615                    .header(CONTENT_LENGTH, 0_u64)
67616                    .body(common::to_body::<String>(None));
67617
67618                client.request(request.unwrap()).await
67619            };
67620
67621            match req_result {
67622                Err(err) => {
67623                    if let common::Retry::After(d) = dlg.http_error(&err) {
67624                        sleep(d).await;
67625                        continue;
67626                    }
67627                    dlg.finished(false);
67628                    return Err(common::Error::HttpError(err));
67629                }
67630                Ok(res) => {
67631                    let (mut parts, body) = res.into_parts();
67632                    let mut body = common::Body::new(body);
67633                    if !parts.status.is_success() {
67634                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67635                        let error = serde_json::from_str(&common::to_string(&bytes));
67636                        let response = common::to_response(parts, bytes.into());
67637
67638                        if let common::Retry::After(d) =
67639                            dlg.http_failure(&response, error.as_ref().ok())
67640                        {
67641                            sleep(d).await;
67642                            continue;
67643                        }
67644
67645                        dlg.finished(false);
67646
67647                        return Err(match error {
67648                            Ok(value) => common::Error::BadRequest(value),
67649                            _ => common::Error::Failure(response),
67650                        });
67651                    }
67652                    let response = {
67653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67654                        let encoded = common::to_string(&bytes);
67655                        match serde_json::from_str(&encoded) {
67656                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
67657                            Err(error) => {
67658                                dlg.response_json_decode_error(&encoded, &error);
67659                                return Err(common::Error::JsonDecodeError(
67660                                    encoded.to_string(),
67661                                    error,
67662                                ));
67663                            }
67664                        }
67665                    };
67666
67667                    dlg.finished(true);
67668                    return Ok(response);
67669                }
67670            }
67671        }
67672    }
67673
67674    /// User profile ID associated with this request.
67675    ///
67676    /// Sets the *profile id* path property to the given value.
67677    ///
67678    /// Even though the property as already been set when instantiating this call,
67679    /// we provide this method for API completeness.
67680    pub fn profile_id(mut self, new_value: i64) -> RemarketingListGetCall<'a, C> {
67681        self._profile_id = new_value;
67682        self
67683    }
67684    /// Remarketing list ID.
67685    ///
67686    /// Sets the *id* path property to the given value.
67687    ///
67688    /// Even though the property as already been set when instantiating this call,
67689    /// we provide this method for API completeness.
67690    pub fn id(mut self, new_value: i64) -> RemarketingListGetCall<'a, C> {
67691        self._id = new_value;
67692        self
67693    }
67694    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
67695    /// while executing the actual API request.
67696    ///
67697    /// ````text
67698    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
67699    /// ````
67700    ///
67701    /// Sets the *delegate* property to the given value.
67702    pub fn delegate(
67703        mut self,
67704        new_value: &'a mut dyn common::Delegate,
67705    ) -> RemarketingListGetCall<'a, C> {
67706        self._delegate = Some(new_value);
67707        self
67708    }
67709
67710    /// Set any additional parameter of the query string used in the request.
67711    /// It should be used to set parameters which are not yet available through their own
67712    /// setters.
67713    ///
67714    /// Please note that this method must not be used to set any of the known parameters
67715    /// which have their own setter method. If done anyway, the request will fail.
67716    ///
67717    /// # Additional Parameters
67718    ///
67719    /// * *alt* (query-string) - Data format for the response.
67720    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
67721    /// * *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.
67722    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
67723    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
67724    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
67725    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
67726    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListGetCall<'a, C>
67727    where
67728        T: AsRef<str>,
67729    {
67730        self._additional_params
67731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
67732        self
67733    }
67734
67735    /// Identifies the authorization scope for the method you are building.
67736    ///
67737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
67738    /// [`Scope::Dfatrafficking`].
67739    ///
67740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
67741    /// tokens for more than one scope.
67742    ///
67743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
67744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
67745    /// sufficient, a read-write scope will do as well.
67746    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListGetCall<'a, C>
67747    where
67748        St: AsRef<str>,
67749    {
67750        self._scopes.insert(String::from(scope.as_ref()));
67751        self
67752    }
67753    /// Identifies the authorization scope(s) for the method you are building.
67754    ///
67755    /// See [`Self::add_scope()`] for details.
67756    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListGetCall<'a, C>
67757    where
67758        I: IntoIterator<Item = St>,
67759        St: AsRef<str>,
67760    {
67761        self._scopes
67762            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
67763        self
67764    }
67765
67766    /// Removes all scopes, and no default scope will be used either.
67767    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
67768    /// for details).
67769    pub fn clear_scopes(mut self) -> RemarketingListGetCall<'a, C> {
67770        self._scopes.clear();
67771        self
67772    }
67773}
67774
67775/// Inserts a new remarketing list.
67776///
67777/// A builder for the *insert* method supported by a *remarketingList* resource.
67778/// It is not used directly, but through a [`RemarketingListMethods`] instance.
67779///
67780/// # Example
67781///
67782/// Instantiate a resource method builder
67783///
67784/// ```test_harness,no_run
67785/// # extern crate hyper;
67786/// # extern crate hyper_rustls;
67787/// # extern crate google_dfareporting3d2 as dfareporting3d2;
67788/// use dfareporting3d2::api::RemarketingList;
67789/// # async fn dox() {
67790/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
67791///
67792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
67793/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67794/// #     secret,
67795/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
67796/// # ).build().await.unwrap();
67797///
67798/// # let client = hyper_util::client::legacy::Client::builder(
67799/// #     hyper_util::rt::TokioExecutor::new()
67800/// # )
67801/// # .build(
67802/// #     hyper_rustls::HttpsConnectorBuilder::new()
67803/// #         .with_native_roots()
67804/// #         .unwrap()
67805/// #         .https_or_http()
67806/// #         .enable_http1()
67807/// #         .build()
67808/// # );
67809/// # let mut hub = Dfareporting::new(client, auth);
67810/// // As the method needs a request, you would usually fill it with the desired information
67811/// // into the respective structure. Some of the parts shown here might not be applicable !
67812/// // Values shown here are possibly random and not representative !
67813/// let mut req = RemarketingList::default();
67814///
67815/// // You can configure optional parameters by calling the respective setters at will, and
67816/// // execute the final call using `doit()`.
67817/// // Values shown here are possibly random and not representative !
67818/// let result = hub.remarketing_lists().insert(req, -99)
67819///              .doit().await;
67820/// # }
67821/// ```
67822pub struct RemarketingListInsertCall<'a, C>
67823where
67824    C: 'a,
67825{
67826    hub: &'a Dfareporting<C>,
67827    _request: RemarketingList,
67828    _profile_id: i64,
67829    _delegate: Option<&'a mut dyn common::Delegate>,
67830    _additional_params: HashMap<String, String>,
67831    _scopes: BTreeSet<String>,
67832}
67833
67834impl<'a, C> common::CallBuilder for RemarketingListInsertCall<'a, C> {}
67835
67836impl<'a, C> RemarketingListInsertCall<'a, C>
67837where
67838    C: common::Connector,
67839{
67840    /// Perform the operation you have build so far.
67841    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingList)> {
67842        use std::borrow::Cow;
67843        use std::io::{Read, Seek};
67844
67845        use common::{url::Params, ToParts};
67846        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
67847
67848        let mut dd = common::DefaultDelegate;
67849        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
67850        dlg.begin(common::MethodInfo {
67851            id: "dfareporting.remarketingLists.insert",
67852            http_method: hyper::Method::POST,
67853        });
67854
67855        for &field in ["alt", "profileId"].iter() {
67856            if self._additional_params.contains_key(field) {
67857                dlg.finished(false);
67858                return Err(common::Error::FieldClash(field));
67859            }
67860        }
67861
67862        let mut params = Params::with_capacity(4 + self._additional_params.len());
67863        params.push("profileId", self._profile_id.to_string());
67864
67865        params.extend(self._additional_params.iter());
67866
67867        params.push("alt", "json");
67868        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists";
67869        if self._scopes.is_empty() {
67870            self._scopes
67871                .insert(Scope::Dfatrafficking.as_ref().to_string());
67872        }
67873
67874        #[allow(clippy::single_element_loop)]
67875        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
67876            url = params.uri_replacement(url, param_name, find_this, false);
67877        }
67878        {
67879            let to_remove = ["profileId"];
67880            params.remove_params(&to_remove);
67881        }
67882
67883        let url = params.parse_with_url(&url);
67884
67885        let mut json_mime_type = mime::APPLICATION_JSON;
67886        let mut request_value_reader = {
67887            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
67888            common::remove_json_null_values(&mut value);
67889            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
67890            serde_json::to_writer(&mut dst, &value).unwrap();
67891            dst
67892        };
67893        let request_size = request_value_reader
67894            .seek(std::io::SeekFrom::End(0))
67895            .unwrap();
67896        request_value_reader
67897            .seek(std::io::SeekFrom::Start(0))
67898            .unwrap();
67899
67900        loop {
67901            let token = match self
67902                .hub
67903                .auth
67904                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
67905                .await
67906            {
67907                Ok(token) => token,
67908                Err(e) => match dlg.token(e) {
67909                    Ok(token) => token,
67910                    Err(e) => {
67911                        dlg.finished(false);
67912                        return Err(common::Error::MissingToken(e));
67913                    }
67914                },
67915            };
67916            request_value_reader
67917                .seek(std::io::SeekFrom::Start(0))
67918                .unwrap();
67919            let mut req_result = {
67920                let client = &self.hub.client;
67921                dlg.pre_request();
67922                let mut req_builder = hyper::Request::builder()
67923                    .method(hyper::Method::POST)
67924                    .uri(url.as_str())
67925                    .header(USER_AGENT, self.hub._user_agent.clone());
67926
67927                if let Some(token) = token.as_ref() {
67928                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
67929                }
67930
67931                let request = req_builder
67932                    .header(CONTENT_TYPE, json_mime_type.to_string())
67933                    .header(CONTENT_LENGTH, request_size as u64)
67934                    .body(common::to_body(
67935                        request_value_reader.get_ref().clone().into(),
67936                    ));
67937
67938                client.request(request.unwrap()).await
67939            };
67940
67941            match req_result {
67942                Err(err) => {
67943                    if let common::Retry::After(d) = dlg.http_error(&err) {
67944                        sleep(d).await;
67945                        continue;
67946                    }
67947                    dlg.finished(false);
67948                    return Err(common::Error::HttpError(err));
67949                }
67950                Ok(res) => {
67951                    let (mut parts, body) = res.into_parts();
67952                    let mut body = common::Body::new(body);
67953                    if !parts.status.is_success() {
67954                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67955                        let error = serde_json::from_str(&common::to_string(&bytes));
67956                        let response = common::to_response(parts, bytes.into());
67957
67958                        if let common::Retry::After(d) =
67959                            dlg.http_failure(&response, error.as_ref().ok())
67960                        {
67961                            sleep(d).await;
67962                            continue;
67963                        }
67964
67965                        dlg.finished(false);
67966
67967                        return Err(match error {
67968                            Ok(value) => common::Error::BadRequest(value),
67969                            _ => common::Error::Failure(response),
67970                        });
67971                    }
67972                    let response = {
67973                        let bytes = common::to_bytes(body).await.unwrap_or_default();
67974                        let encoded = common::to_string(&bytes);
67975                        match serde_json::from_str(&encoded) {
67976                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
67977                            Err(error) => {
67978                                dlg.response_json_decode_error(&encoded, &error);
67979                                return Err(common::Error::JsonDecodeError(
67980                                    encoded.to_string(),
67981                                    error,
67982                                ));
67983                            }
67984                        }
67985                    };
67986
67987                    dlg.finished(true);
67988                    return Ok(response);
67989                }
67990            }
67991        }
67992    }
67993
67994    ///
67995    /// Sets the *request* property to the given value.
67996    ///
67997    /// Even though the property as already been set when instantiating this call,
67998    /// we provide this method for API completeness.
67999    pub fn request(mut self, new_value: RemarketingList) -> RemarketingListInsertCall<'a, C> {
68000        self._request = new_value;
68001        self
68002    }
68003    /// User profile ID associated with this request.
68004    ///
68005    /// Sets the *profile id* path property to the given value.
68006    ///
68007    /// Even though the property as already been set when instantiating this call,
68008    /// we provide this method for API completeness.
68009    pub fn profile_id(mut self, new_value: i64) -> RemarketingListInsertCall<'a, C> {
68010        self._profile_id = new_value;
68011        self
68012    }
68013    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
68014    /// while executing the actual API request.
68015    ///
68016    /// ````text
68017    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
68018    /// ````
68019    ///
68020    /// Sets the *delegate* property to the given value.
68021    pub fn delegate(
68022        mut self,
68023        new_value: &'a mut dyn common::Delegate,
68024    ) -> RemarketingListInsertCall<'a, C> {
68025        self._delegate = Some(new_value);
68026        self
68027    }
68028
68029    /// Set any additional parameter of the query string used in the request.
68030    /// It should be used to set parameters which are not yet available through their own
68031    /// setters.
68032    ///
68033    /// Please note that this method must not be used to set any of the known parameters
68034    /// which have their own setter method. If done anyway, the request will fail.
68035    ///
68036    /// # Additional Parameters
68037    ///
68038    /// * *alt* (query-string) - Data format for the response.
68039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
68040    /// * *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.
68041    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
68042    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
68043    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
68044    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
68045    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListInsertCall<'a, C>
68046    where
68047        T: AsRef<str>,
68048    {
68049        self._additional_params
68050            .insert(name.as_ref().to_string(), value.as_ref().to_string());
68051        self
68052    }
68053
68054    /// Identifies the authorization scope for the method you are building.
68055    ///
68056    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
68057    /// [`Scope::Dfatrafficking`].
68058    ///
68059    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
68060    /// tokens for more than one scope.
68061    ///
68062    /// Usually there is more than one suitable scope to authorize an operation, some of which may
68063    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
68064    /// sufficient, a read-write scope will do as well.
68065    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListInsertCall<'a, C>
68066    where
68067        St: AsRef<str>,
68068    {
68069        self._scopes.insert(String::from(scope.as_ref()));
68070        self
68071    }
68072    /// Identifies the authorization scope(s) for the method you are building.
68073    ///
68074    /// See [`Self::add_scope()`] for details.
68075    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListInsertCall<'a, C>
68076    where
68077        I: IntoIterator<Item = St>,
68078        St: AsRef<str>,
68079    {
68080        self._scopes
68081            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
68082        self
68083    }
68084
68085    /// Removes all scopes, and no default scope will be used either.
68086    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
68087    /// for details).
68088    pub fn clear_scopes(mut self) -> RemarketingListInsertCall<'a, C> {
68089        self._scopes.clear();
68090        self
68091    }
68092}
68093
68094/// Retrieves a list of remarketing lists, possibly filtered. This method supports paging.
68095///
68096/// A builder for the *list* method supported by a *remarketingList* resource.
68097/// It is not used directly, but through a [`RemarketingListMethods`] instance.
68098///
68099/// # Example
68100///
68101/// Instantiate a resource method builder
68102///
68103/// ```test_harness,no_run
68104/// # extern crate hyper;
68105/// # extern crate hyper_rustls;
68106/// # extern crate google_dfareporting3d2 as dfareporting3d2;
68107/// # async fn dox() {
68108/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
68109///
68110/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
68111/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
68112/// #     secret,
68113/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
68114/// # ).build().await.unwrap();
68115///
68116/// # let client = hyper_util::client::legacy::Client::builder(
68117/// #     hyper_util::rt::TokioExecutor::new()
68118/// # )
68119/// # .build(
68120/// #     hyper_rustls::HttpsConnectorBuilder::new()
68121/// #         .with_native_roots()
68122/// #         .unwrap()
68123/// #         .https_or_http()
68124/// #         .enable_http1()
68125/// #         .build()
68126/// # );
68127/// # let mut hub = Dfareporting::new(client, auth);
68128/// // You can configure optional parameters by calling the respective setters at will, and
68129/// // execute the final call using `doit()`.
68130/// // Values shown here are possibly random and not representative !
68131/// let result = hub.remarketing_lists().list(-45, -92)
68132///              .sort_order("At")
68133///              .sort_field("At")
68134///              .page_token("kasd")
68135///              .name("magna")
68136///              .max_results(-52)
68137///              .floodlight_activity_id(-7)
68138///              .active(true)
68139///              .doit().await;
68140/// # }
68141/// ```
68142pub struct RemarketingListListCall<'a, C>
68143where
68144    C: 'a,
68145{
68146    hub: &'a Dfareporting<C>,
68147    _profile_id: i64,
68148    _advertiser_id: i64,
68149    _sort_order: Option<String>,
68150    _sort_field: Option<String>,
68151    _page_token: Option<String>,
68152    _name: Option<String>,
68153    _max_results: Option<i32>,
68154    _floodlight_activity_id: Option<i64>,
68155    _active: Option<bool>,
68156    _delegate: Option<&'a mut dyn common::Delegate>,
68157    _additional_params: HashMap<String, String>,
68158    _scopes: BTreeSet<String>,
68159}
68160
68161impl<'a, C> common::CallBuilder for RemarketingListListCall<'a, C> {}
68162
68163impl<'a, C> RemarketingListListCall<'a, C>
68164where
68165    C: common::Connector,
68166{
68167    /// Perform the operation you have build so far.
68168    pub async fn doit(
68169        mut self,
68170    ) -> common::Result<(common::Response, RemarketingListsListResponse)> {
68171        use std::borrow::Cow;
68172        use std::io::{Read, Seek};
68173
68174        use common::{url::Params, ToParts};
68175        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
68176
68177        let mut dd = common::DefaultDelegate;
68178        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
68179        dlg.begin(common::MethodInfo {
68180            id: "dfareporting.remarketingLists.list",
68181            http_method: hyper::Method::GET,
68182        });
68183
68184        for &field in [
68185            "alt",
68186            "profileId",
68187            "advertiserId",
68188            "sortOrder",
68189            "sortField",
68190            "pageToken",
68191            "name",
68192            "maxResults",
68193            "floodlightActivityId",
68194            "active",
68195        ]
68196        .iter()
68197        {
68198            if self._additional_params.contains_key(field) {
68199                dlg.finished(false);
68200                return Err(common::Error::FieldClash(field));
68201            }
68202        }
68203
68204        let mut params = Params::with_capacity(11 + self._additional_params.len());
68205        params.push("profileId", self._profile_id.to_string());
68206        params.push("advertiserId", self._advertiser_id.to_string());
68207        if let Some(value) = self._sort_order.as_ref() {
68208            params.push("sortOrder", value);
68209        }
68210        if let Some(value) = self._sort_field.as_ref() {
68211            params.push("sortField", value);
68212        }
68213        if let Some(value) = self._page_token.as_ref() {
68214            params.push("pageToken", value);
68215        }
68216        if let Some(value) = self._name.as_ref() {
68217            params.push("name", value);
68218        }
68219        if let Some(value) = self._max_results.as_ref() {
68220            params.push("maxResults", value.to_string());
68221        }
68222        if let Some(value) = self._floodlight_activity_id.as_ref() {
68223            params.push("floodlightActivityId", value.to_string());
68224        }
68225        if let Some(value) = self._active.as_ref() {
68226            params.push("active", value.to_string());
68227        }
68228
68229        params.extend(self._additional_params.iter());
68230
68231        params.push("alt", "json");
68232        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists";
68233        if self._scopes.is_empty() {
68234            self._scopes
68235                .insert(Scope::Dfatrafficking.as_ref().to_string());
68236        }
68237
68238        #[allow(clippy::single_element_loop)]
68239        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
68240            url = params.uri_replacement(url, param_name, find_this, false);
68241        }
68242        {
68243            let to_remove = ["profileId"];
68244            params.remove_params(&to_remove);
68245        }
68246
68247        let url = params.parse_with_url(&url);
68248
68249        loop {
68250            let token = match self
68251                .hub
68252                .auth
68253                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
68254                .await
68255            {
68256                Ok(token) => token,
68257                Err(e) => match dlg.token(e) {
68258                    Ok(token) => token,
68259                    Err(e) => {
68260                        dlg.finished(false);
68261                        return Err(common::Error::MissingToken(e));
68262                    }
68263                },
68264            };
68265            let mut req_result = {
68266                let client = &self.hub.client;
68267                dlg.pre_request();
68268                let mut req_builder = hyper::Request::builder()
68269                    .method(hyper::Method::GET)
68270                    .uri(url.as_str())
68271                    .header(USER_AGENT, self.hub._user_agent.clone());
68272
68273                if let Some(token) = token.as_ref() {
68274                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
68275                }
68276
68277                let request = req_builder
68278                    .header(CONTENT_LENGTH, 0_u64)
68279                    .body(common::to_body::<String>(None));
68280
68281                client.request(request.unwrap()).await
68282            };
68283
68284            match req_result {
68285                Err(err) => {
68286                    if let common::Retry::After(d) = dlg.http_error(&err) {
68287                        sleep(d).await;
68288                        continue;
68289                    }
68290                    dlg.finished(false);
68291                    return Err(common::Error::HttpError(err));
68292                }
68293                Ok(res) => {
68294                    let (mut parts, body) = res.into_parts();
68295                    let mut body = common::Body::new(body);
68296                    if !parts.status.is_success() {
68297                        let bytes = common::to_bytes(body).await.unwrap_or_default();
68298                        let error = serde_json::from_str(&common::to_string(&bytes));
68299                        let response = common::to_response(parts, bytes.into());
68300
68301                        if let common::Retry::After(d) =
68302                            dlg.http_failure(&response, error.as_ref().ok())
68303                        {
68304                            sleep(d).await;
68305                            continue;
68306                        }
68307
68308                        dlg.finished(false);
68309
68310                        return Err(match error {
68311                            Ok(value) => common::Error::BadRequest(value),
68312                            _ => common::Error::Failure(response),
68313                        });
68314                    }
68315                    let response = {
68316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
68317                        let encoded = common::to_string(&bytes);
68318                        match serde_json::from_str(&encoded) {
68319                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
68320                            Err(error) => {
68321                                dlg.response_json_decode_error(&encoded, &error);
68322                                return Err(common::Error::JsonDecodeError(
68323                                    encoded.to_string(),
68324                                    error,
68325                                ));
68326                            }
68327                        }
68328                    };
68329
68330                    dlg.finished(true);
68331                    return Ok(response);
68332                }
68333            }
68334        }
68335    }
68336
68337    /// User profile ID associated with this request.
68338    ///
68339    /// Sets the *profile id* path property to the given value.
68340    ///
68341    /// Even though the property as already been set when instantiating this call,
68342    /// we provide this method for API completeness.
68343    pub fn profile_id(mut self, new_value: i64) -> RemarketingListListCall<'a, C> {
68344        self._profile_id = new_value;
68345        self
68346    }
68347    /// Select only remarketing lists owned by this advertiser.
68348    ///
68349    /// Sets the *advertiser id* query property to the given value.
68350    ///
68351    /// Even though the property as already been set when instantiating this call,
68352    /// we provide this method for API completeness.
68353    pub fn advertiser_id(mut self, new_value: i64) -> RemarketingListListCall<'a, C> {
68354        self._advertiser_id = new_value;
68355        self
68356    }
68357    /// Order of sorted results.
68358    ///
68359    /// Sets the *sort order* query property to the given value.
68360    pub fn sort_order(mut self, new_value: &str) -> RemarketingListListCall<'a, C> {
68361        self._sort_order = Some(new_value.to_string());
68362        self
68363    }
68364    /// Field by which to sort the list.
68365    ///
68366    /// Sets the *sort field* query property to the given value.
68367    pub fn sort_field(mut self, new_value: &str) -> RemarketingListListCall<'a, C> {
68368        self._sort_field = Some(new_value.to_string());
68369        self
68370    }
68371    /// Value of the nextPageToken from the previous result page.
68372    ///
68373    /// Sets the *page token* query property to the given value.
68374    pub fn page_token(mut self, new_value: &str) -> RemarketingListListCall<'a, C> {
68375        self._page_token = Some(new_value.to_string());
68376        self
68377    }
68378    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list".
68379    ///
68380    /// Sets the *name* query property to the given value.
68381    pub fn name(mut self, new_value: &str) -> RemarketingListListCall<'a, C> {
68382        self._name = Some(new_value.to_string());
68383        self
68384    }
68385    /// Maximum number of results to return.
68386    ///
68387    /// Sets the *max results* query property to the given value.
68388    pub fn max_results(mut self, new_value: i32) -> RemarketingListListCall<'a, C> {
68389        self._max_results = Some(new_value);
68390        self
68391    }
68392    /// Select only remarketing lists that have this floodlight activity ID.
68393    ///
68394    /// Sets the *floodlight activity id* query property to the given value.
68395    pub fn floodlight_activity_id(mut self, new_value: i64) -> RemarketingListListCall<'a, C> {
68396        self._floodlight_activity_id = Some(new_value);
68397        self
68398    }
68399    /// Select only active or only inactive remarketing lists.
68400    ///
68401    /// Sets the *active* query property to the given value.
68402    pub fn active(mut self, new_value: bool) -> RemarketingListListCall<'a, C> {
68403        self._active = Some(new_value);
68404        self
68405    }
68406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
68407    /// while executing the actual API request.
68408    ///
68409    /// ````text
68410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
68411    /// ````
68412    ///
68413    /// Sets the *delegate* property to the given value.
68414    pub fn delegate(
68415        mut self,
68416        new_value: &'a mut dyn common::Delegate,
68417    ) -> RemarketingListListCall<'a, C> {
68418        self._delegate = Some(new_value);
68419        self
68420    }
68421
68422    /// Set any additional parameter of the query string used in the request.
68423    /// It should be used to set parameters which are not yet available through their own
68424    /// setters.
68425    ///
68426    /// Please note that this method must not be used to set any of the known parameters
68427    /// which have their own setter method. If done anyway, the request will fail.
68428    ///
68429    /// # Additional Parameters
68430    ///
68431    /// * *alt* (query-string) - Data format for the response.
68432    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
68433    /// * *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.
68434    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
68435    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
68436    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
68437    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
68438    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListListCall<'a, C>
68439    where
68440        T: AsRef<str>,
68441    {
68442        self._additional_params
68443            .insert(name.as_ref().to_string(), value.as_ref().to_string());
68444        self
68445    }
68446
68447    /// Identifies the authorization scope for the method you are building.
68448    ///
68449    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
68450    /// [`Scope::Dfatrafficking`].
68451    ///
68452    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
68453    /// tokens for more than one scope.
68454    ///
68455    /// Usually there is more than one suitable scope to authorize an operation, some of which may
68456    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
68457    /// sufficient, a read-write scope will do as well.
68458    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListListCall<'a, C>
68459    where
68460        St: AsRef<str>,
68461    {
68462        self._scopes.insert(String::from(scope.as_ref()));
68463        self
68464    }
68465    /// Identifies the authorization scope(s) for the method you are building.
68466    ///
68467    /// See [`Self::add_scope()`] for details.
68468    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListListCall<'a, C>
68469    where
68470        I: IntoIterator<Item = St>,
68471        St: AsRef<str>,
68472    {
68473        self._scopes
68474            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
68475        self
68476    }
68477
68478    /// Removes all scopes, and no default scope will be used either.
68479    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
68480    /// for details).
68481    pub fn clear_scopes(mut self) -> RemarketingListListCall<'a, C> {
68482        self._scopes.clear();
68483        self
68484    }
68485}
68486
68487/// Updates an existing remarketing list. This method supports patch semantics.
68488///
68489/// A builder for the *patch* method supported by a *remarketingList* resource.
68490/// It is not used directly, but through a [`RemarketingListMethods`] instance.
68491///
68492/// # Example
68493///
68494/// Instantiate a resource method builder
68495///
68496/// ```test_harness,no_run
68497/// # extern crate hyper;
68498/// # extern crate hyper_rustls;
68499/// # extern crate google_dfareporting3d2 as dfareporting3d2;
68500/// use dfareporting3d2::api::RemarketingList;
68501/// # async fn dox() {
68502/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
68503///
68504/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
68505/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
68506/// #     secret,
68507/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
68508/// # ).build().await.unwrap();
68509///
68510/// # let client = hyper_util::client::legacy::Client::builder(
68511/// #     hyper_util::rt::TokioExecutor::new()
68512/// # )
68513/// # .build(
68514/// #     hyper_rustls::HttpsConnectorBuilder::new()
68515/// #         .with_native_roots()
68516/// #         .unwrap()
68517/// #         .https_or_http()
68518/// #         .enable_http1()
68519/// #         .build()
68520/// # );
68521/// # let mut hub = Dfareporting::new(client, auth);
68522/// // As the method needs a request, you would usually fill it with the desired information
68523/// // into the respective structure. Some of the parts shown here might not be applicable !
68524/// // Values shown here are possibly random and not representative !
68525/// let mut req = RemarketingList::default();
68526///
68527/// // You can configure optional parameters by calling the respective setters at will, and
68528/// // execute the final call using `doit()`.
68529/// // Values shown here are possibly random and not representative !
68530/// let result = hub.remarketing_lists().patch(req, -75, -34)
68531///              .doit().await;
68532/// # }
68533/// ```
68534pub struct RemarketingListPatchCall<'a, C>
68535where
68536    C: 'a,
68537{
68538    hub: &'a Dfareporting<C>,
68539    _request: RemarketingList,
68540    _profile_id: i64,
68541    _id: i64,
68542    _delegate: Option<&'a mut dyn common::Delegate>,
68543    _additional_params: HashMap<String, String>,
68544    _scopes: BTreeSet<String>,
68545}
68546
68547impl<'a, C> common::CallBuilder for RemarketingListPatchCall<'a, C> {}
68548
68549impl<'a, C> RemarketingListPatchCall<'a, C>
68550where
68551    C: common::Connector,
68552{
68553    /// Perform the operation you have build so far.
68554    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingList)> {
68555        use std::borrow::Cow;
68556        use std::io::{Read, Seek};
68557
68558        use common::{url::Params, ToParts};
68559        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
68560
68561        let mut dd = common::DefaultDelegate;
68562        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
68563        dlg.begin(common::MethodInfo {
68564            id: "dfareporting.remarketingLists.patch",
68565            http_method: hyper::Method::PATCH,
68566        });
68567
68568        for &field in ["alt", "profileId", "id"].iter() {
68569            if self._additional_params.contains_key(field) {
68570                dlg.finished(false);
68571                return Err(common::Error::FieldClash(field));
68572            }
68573        }
68574
68575        let mut params = Params::with_capacity(5 + self._additional_params.len());
68576        params.push("profileId", self._profile_id.to_string());
68577        params.push("id", self._id.to_string());
68578
68579        params.extend(self._additional_params.iter());
68580
68581        params.push("alt", "json");
68582        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists";
68583        if self._scopes.is_empty() {
68584            self._scopes
68585                .insert(Scope::Dfatrafficking.as_ref().to_string());
68586        }
68587
68588        #[allow(clippy::single_element_loop)]
68589        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
68590            url = params.uri_replacement(url, param_name, find_this, false);
68591        }
68592        {
68593            let to_remove = ["profileId"];
68594            params.remove_params(&to_remove);
68595        }
68596
68597        let url = params.parse_with_url(&url);
68598
68599        let mut json_mime_type = mime::APPLICATION_JSON;
68600        let mut request_value_reader = {
68601            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
68602            common::remove_json_null_values(&mut value);
68603            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
68604            serde_json::to_writer(&mut dst, &value).unwrap();
68605            dst
68606        };
68607        let request_size = request_value_reader
68608            .seek(std::io::SeekFrom::End(0))
68609            .unwrap();
68610        request_value_reader
68611            .seek(std::io::SeekFrom::Start(0))
68612            .unwrap();
68613
68614        loop {
68615            let token = match self
68616                .hub
68617                .auth
68618                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
68619                .await
68620            {
68621                Ok(token) => token,
68622                Err(e) => match dlg.token(e) {
68623                    Ok(token) => token,
68624                    Err(e) => {
68625                        dlg.finished(false);
68626                        return Err(common::Error::MissingToken(e));
68627                    }
68628                },
68629            };
68630            request_value_reader
68631                .seek(std::io::SeekFrom::Start(0))
68632                .unwrap();
68633            let mut req_result = {
68634                let client = &self.hub.client;
68635                dlg.pre_request();
68636                let mut req_builder = hyper::Request::builder()
68637                    .method(hyper::Method::PATCH)
68638                    .uri(url.as_str())
68639                    .header(USER_AGENT, self.hub._user_agent.clone());
68640
68641                if let Some(token) = token.as_ref() {
68642                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
68643                }
68644
68645                let request = req_builder
68646                    .header(CONTENT_TYPE, json_mime_type.to_string())
68647                    .header(CONTENT_LENGTH, request_size as u64)
68648                    .body(common::to_body(
68649                        request_value_reader.get_ref().clone().into(),
68650                    ));
68651
68652                client.request(request.unwrap()).await
68653            };
68654
68655            match req_result {
68656                Err(err) => {
68657                    if let common::Retry::After(d) = dlg.http_error(&err) {
68658                        sleep(d).await;
68659                        continue;
68660                    }
68661                    dlg.finished(false);
68662                    return Err(common::Error::HttpError(err));
68663                }
68664                Ok(res) => {
68665                    let (mut parts, body) = res.into_parts();
68666                    let mut body = common::Body::new(body);
68667                    if !parts.status.is_success() {
68668                        let bytes = common::to_bytes(body).await.unwrap_or_default();
68669                        let error = serde_json::from_str(&common::to_string(&bytes));
68670                        let response = common::to_response(parts, bytes.into());
68671
68672                        if let common::Retry::After(d) =
68673                            dlg.http_failure(&response, error.as_ref().ok())
68674                        {
68675                            sleep(d).await;
68676                            continue;
68677                        }
68678
68679                        dlg.finished(false);
68680
68681                        return Err(match error {
68682                            Ok(value) => common::Error::BadRequest(value),
68683                            _ => common::Error::Failure(response),
68684                        });
68685                    }
68686                    let response = {
68687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
68688                        let encoded = common::to_string(&bytes);
68689                        match serde_json::from_str(&encoded) {
68690                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
68691                            Err(error) => {
68692                                dlg.response_json_decode_error(&encoded, &error);
68693                                return Err(common::Error::JsonDecodeError(
68694                                    encoded.to_string(),
68695                                    error,
68696                                ));
68697                            }
68698                        }
68699                    };
68700
68701                    dlg.finished(true);
68702                    return Ok(response);
68703                }
68704            }
68705        }
68706    }
68707
68708    ///
68709    /// Sets the *request* property to the given value.
68710    ///
68711    /// Even though the property as already been set when instantiating this call,
68712    /// we provide this method for API completeness.
68713    pub fn request(mut self, new_value: RemarketingList) -> RemarketingListPatchCall<'a, C> {
68714        self._request = new_value;
68715        self
68716    }
68717    /// User profile ID associated with this request.
68718    ///
68719    /// Sets the *profile id* path property to the given value.
68720    ///
68721    /// Even though the property as already been set when instantiating this call,
68722    /// we provide this method for API completeness.
68723    pub fn profile_id(mut self, new_value: i64) -> RemarketingListPatchCall<'a, C> {
68724        self._profile_id = new_value;
68725        self
68726    }
68727    /// Remarketing list ID.
68728    ///
68729    /// Sets the *id* query property to the given value.
68730    ///
68731    /// Even though the property as already been set when instantiating this call,
68732    /// we provide this method for API completeness.
68733    pub fn id(mut self, new_value: i64) -> RemarketingListPatchCall<'a, C> {
68734        self._id = new_value;
68735        self
68736    }
68737    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
68738    /// while executing the actual API request.
68739    ///
68740    /// ````text
68741    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
68742    /// ````
68743    ///
68744    /// Sets the *delegate* property to the given value.
68745    pub fn delegate(
68746        mut self,
68747        new_value: &'a mut dyn common::Delegate,
68748    ) -> RemarketingListPatchCall<'a, C> {
68749        self._delegate = Some(new_value);
68750        self
68751    }
68752
68753    /// Set any additional parameter of the query string used in the request.
68754    /// It should be used to set parameters which are not yet available through their own
68755    /// setters.
68756    ///
68757    /// Please note that this method must not be used to set any of the known parameters
68758    /// which have their own setter method. If done anyway, the request will fail.
68759    ///
68760    /// # Additional Parameters
68761    ///
68762    /// * *alt* (query-string) - Data format for the response.
68763    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
68764    /// * *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.
68765    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
68766    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
68767    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
68768    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
68769    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListPatchCall<'a, C>
68770    where
68771        T: AsRef<str>,
68772    {
68773        self._additional_params
68774            .insert(name.as_ref().to_string(), value.as_ref().to_string());
68775        self
68776    }
68777
68778    /// Identifies the authorization scope for the method you are building.
68779    ///
68780    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
68781    /// [`Scope::Dfatrafficking`].
68782    ///
68783    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
68784    /// tokens for more than one scope.
68785    ///
68786    /// Usually there is more than one suitable scope to authorize an operation, some of which may
68787    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
68788    /// sufficient, a read-write scope will do as well.
68789    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListPatchCall<'a, C>
68790    where
68791        St: AsRef<str>,
68792    {
68793        self._scopes.insert(String::from(scope.as_ref()));
68794        self
68795    }
68796    /// Identifies the authorization scope(s) for the method you are building.
68797    ///
68798    /// See [`Self::add_scope()`] for details.
68799    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListPatchCall<'a, C>
68800    where
68801        I: IntoIterator<Item = St>,
68802        St: AsRef<str>,
68803    {
68804        self._scopes
68805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
68806        self
68807    }
68808
68809    /// Removes all scopes, and no default scope will be used either.
68810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
68811    /// for details).
68812    pub fn clear_scopes(mut self) -> RemarketingListPatchCall<'a, C> {
68813        self._scopes.clear();
68814        self
68815    }
68816}
68817
68818/// Updates an existing remarketing list.
68819///
68820/// A builder for the *update* method supported by a *remarketingList* resource.
68821/// It is not used directly, but through a [`RemarketingListMethods`] instance.
68822///
68823/// # Example
68824///
68825/// Instantiate a resource method builder
68826///
68827/// ```test_harness,no_run
68828/// # extern crate hyper;
68829/// # extern crate hyper_rustls;
68830/// # extern crate google_dfareporting3d2 as dfareporting3d2;
68831/// use dfareporting3d2::api::RemarketingList;
68832/// # async fn dox() {
68833/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
68834///
68835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
68836/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
68837/// #     secret,
68838/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
68839/// # ).build().await.unwrap();
68840///
68841/// # let client = hyper_util::client::legacy::Client::builder(
68842/// #     hyper_util::rt::TokioExecutor::new()
68843/// # )
68844/// # .build(
68845/// #     hyper_rustls::HttpsConnectorBuilder::new()
68846/// #         .with_native_roots()
68847/// #         .unwrap()
68848/// #         .https_or_http()
68849/// #         .enable_http1()
68850/// #         .build()
68851/// # );
68852/// # let mut hub = Dfareporting::new(client, auth);
68853/// // As the method needs a request, you would usually fill it with the desired information
68854/// // into the respective structure. Some of the parts shown here might not be applicable !
68855/// // Values shown here are possibly random and not representative !
68856/// let mut req = RemarketingList::default();
68857///
68858/// // You can configure optional parameters by calling the respective setters at will, and
68859/// // execute the final call using `doit()`.
68860/// // Values shown here are possibly random and not representative !
68861/// let result = hub.remarketing_lists().update(req, -39)
68862///              .doit().await;
68863/// # }
68864/// ```
68865pub struct RemarketingListUpdateCall<'a, C>
68866where
68867    C: 'a,
68868{
68869    hub: &'a Dfareporting<C>,
68870    _request: RemarketingList,
68871    _profile_id: i64,
68872    _delegate: Option<&'a mut dyn common::Delegate>,
68873    _additional_params: HashMap<String, String>,
68874    _scopes: BTreeSet<String>,
68875}
68876
68877impl<'a, C> common::CallBuilder for RemarketingListUpdateCall<'a, C> {}
68878
68879impl<'a, C> RemarketingListUpdateCall<'a, C>
68880where
68881    C: common::Connector,
68882{
68883    /// Perform the operation you have build so far.
68884    pub async fn doit(mut self) -> common::Result<(common::Response, RemarketingList)> {
68885        use std::borrow::Cow;
68886        use std::io::{Read, Seek};
68887
68888        use common::{url::Params, ToParts};
68889        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
68890
68891        let mut dd = common::DefaultDelegate;
68892        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
68893        dlg.begin(common::MethodInfo {
68894            id: "dfareporting.remarketingLists.update",
68895            http_method: hyper::Method::PUT,
68896        });
68897
68898        for &field in ["alt", "profileId"].iter() {
68899            if self._additional_params.contains_key(field) {
68900                dlg.finished(false);
68901                return Err(common::Error::FieldClash(field));
68902            }
68903        }
68904
68905        let mut params = Params::with_capacity(4 + self._additional_params.len());
68906        params.push("profileId", self._profile_id.to_string());
68907
68908        params.extend(self._additional_params.iter());
68909
68910        params.push("alt", "json");
68911        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists";
68912        if self._scopes.is_empty() {
68913            self._scopes
68914                .insert(Scope::Dfatrafficking.as_ref().to_string());
68915        }
68916
68917        #[allow(clippy::single_element_loop)]
68918        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
68919            url = params.uri_replacement(url, param_name, find_this, false);
68920        }
68921        {
68922            let to_remove = ["profileId"];
68923            params.remove_params(&to_remove);
68924        }
68925
68926        let url = params.parse_with_url(&url);
68927
68928        let mut json_mime_type = mime::APPLICATION_JSON;
68929        let mut request_value_reader = {
68930            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
68931            common::remove_json_null_values(&mut value);
68932            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
68933            serde_json::to_writer(&mut dst, &value).unwrap();
68934            dst
68935        };
68936        let request_size = request_value_reader
68937            .seek(std::io::SeekFrom::End(0))
68938            .unwrap();
68939        request_value_reader
68940            .seek(std::io::SeekFrom::Start(0))
68941            .unwrap();
68942
68943        loop {
68944            let token = match self
68945                .hub
68946                .auth
68947                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
68948                .await
68949            {
68950                Ok(token) => token,
68951                Err(e) => match dlg.token(e) {
68952                    Ok(token) => token,
68953                    Err(e) => {
68954                        dlg.finished(false);
68955                        return Err(common::Error::MissingToken(e));
68956                    }
68957                },
68958            };
68959            request_value_reader
68960                .seek(std::io::SeekFrom::Start(0))
68961                .unwrap();
68962            let mut req_result = {
68963                let client = &self.hub.client;
68964                dlg.pre_request();
68965                let mut req_builder = hyper::Request::builder()
68966                    .method(hyper::Method::PUT)
68967                    .uri(url.as_str())
68968                    .header(USER_AGENT, self.hub._user_agent.clone());
68969
68970                if let Some(token) = token.as_ref() {
68971                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
68972                }
68973
68974                let request = req_builder
68975                    .header(CONTENT_TYPE, json_mime_type.to_string())
68976                    .header(CONTENT_LENGTH, request_size as u64)
68977                    .body(common::to_body(
68978                        request_value_reader.get_ref().clone().into(),
68979                    ));
68980
68981                client.request(request.unwrap()).await
68982            };
68983
68984            match req_result {
68985                Err(err) => {
68986                    if let common::Retry::After(d) = dlg.http_error(&err) {
68987                        sleep(d).await;
68988                        continue;
68989                    }
68990                    dlg.finished(false);
68991                    return Err(common::Error::HttpError(err));
68992                }
68993                Ok(res) => {
68994                    let (mut parts, body) = res.into_parts();
68995                    let mut body = common::Body::new(body);
68996                    if !parts.status.is_success() {
68997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
68998                        let error = serde_json::from_str(&common::to_string(&bytes));
68999                        let response = common::to_response(parts, bytes.into());
69000
69001                        if let common::Retry::After(d) =
69002                            dlg.http_failure(&response, error.as_ref().ok())
69003                        {
69004                            sleep(d).await;
69005                            continue;
69006                        }
69007
69008                        dlg.finished(false);
69009
69010                        return Err(match error {
69011                            Ok(value) => common::Error::BadRequest(value),
69012                            _ => common::Error::Failure(response),
69013                        });
69014                    }
69015                    let response = {
69016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69017                        let encoded = common::to_string(&bytes);
69018                        match serde_json::from_str(&encoded) {
69019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
69020                            Err(error) => {
69021                                dlg.response_json_decode_error(&encoded, &error);
69022                                return Err(common::Error::JsonDecodeError(
69023                                    encoded.to_string(),
69024                                    error,
69025                                ));
69026                            }
69027                        }
69028                    };
69029
69030                    dlg.finished(true);
69031                    return Ok(response);
69032                }
69033            }
69034        }
69035    }
69036
69037    ///
69038    /// Sets the *request* property to the given value.
69039    ///
69040    /// Even though the property as already been set when instantiating this call,
69041    /// we provide this method for API completeness.
69042    pub fn request(mut self, new_value: RemarketingList) -> RemarketingListUpdateCall<'a, C> {
69043        self._request = new_value;
69044        self
69045    }
69046    /// User profile ID associated with this request.
69047    ///
69048    /// Sets the *profile id* path property to the given value.
69049    ///
69050    /// Even though the property as already been set when instantiating this call,
69051    /// we provide this method for API completeness.
69052    pub fn profile_id(mut self, new_value: i64) -> RemarketingListUpdateCall<'a, C> {
69053        self._profile_id = new_value;
69054        self
69055    }
69056    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
69057    /// while executing the actual API request.
69058    ///
69059    /// ````text
69060    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
69061    /// ````
69062    ///
69063    /// Sets the *delegate* property to the given value.
69064    pub fn delegate(
69065        mut self,
69066        new_value: &'a mut dyn common::Delegate,
69067    ) -> RemarketingListUpdateCall<'a, C> {
69068        self._delegate = Some(new_value);
69069        self
69070    }
69071
69072    /// Set any additional parameter of the query string used in the request.
69073    /// It should be used to set parameters which are not yet available through their own
69074    /// setters.
69075    ///
69076    /// Please note that this method must not be used to set any of the known parameters
69077    /// which have their own setter method. If done anyway, the request will fail.
69078    ///
69079    /// # Additional Parameters
69080    ///
69081    /// * *alt* (query-string) - Data format for the response.
69082    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
69083    /// * *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.
69084    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
69085    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
69086    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
69087    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
69088    pub fn param<T>(mut self, name: T, value: T) -> RemarketingListUpdateCall<'a, C>
69089    where
69090        T: AsRef<str>,
69091    {
69092        self._additional_params
69093            .insert(name.as_ref().to_string(), value.as_ref().to_string());
69094        self
69095    }
69096
69097    /// Identifies the authorization scope for the method you are building.
69098    ///
69099    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
69100    /// [`Scope::Dfatrafficking`].
69101    ///
69102    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
69103    /// tokens for more than one scope.
69104    ///
69105    /// Usually there is more than one suitable scope to authorize an operation, some of which may
69106    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
69107    /// sufficient, a read-write scope will do as well.
69108    pub fn add_scope<St>(mut self, scope: St) -> RemarketingListUpdateCall<'a, C>
69109    where
69110        St: AsRef<str>,
69111    {
69112        self._scopes.insert(String::from(scope.as_ref()));
69113        self
69114    }
69115    /// Identifies the authorization scope(s) for the method you are building.
69116    ///
69117    /// See [`Self::add_scope()`] for details.
69118    pub fn add_scopes<I, St>(mut self, scopes: I) -> RemarketingListUpdateCall<'a, C>
69119    where
69120        I: IntoIterator<Item = St>,
69121        St: AsRef<str>,
69122    {
69123        self._scopes
69124            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
69125        self
69126    }
69127
69128    /// Removes all scopes, and no default scope will be used either.
69129    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
69130    /// for details).
69131    pub fn clear_scopes(mut self) -> RemarketingListUpdateCall<'a, C> {
69132        self._scopes.clear();
69133        self
69134    }
69135}
69136
69137/// Returns the fields that are compatible to be selected in the respective sections of a report criteria, given the fields already selected in the input report and user permissions.
69138///
69139/// A builder for the *compatibleFields.query* method supported by a *report* resource.
69140/// It is not used directly, but through a [`ReportMethods`] instance.
69141///
69142/// # Example
69143///
69144/// Instantiate a resource method builder
69145///
69146/// ```test_harness,no_run
69147/// # extern crate hyper;
69148/// # extern crate hyper_rustls;
69149/// # extern crate google_dfareporting3d2 as dfareporting3d2;
69150/// use dfareporting3d2::api::Report;
69151/// # async fn dox() {
69152/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
69153///
69154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
69155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
69156/// #     secret,
69157/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69158/// # ).build().await.unwrap();
69159///
69160/// # let client = hyper_util::client::legacy::Client::builder(
69161/// #     hyper_util::rt::TokioExecutor::new()
69162/// # )
69163/// # .build(
69164/// #     hyper_rustls::HttpsConnectorBuilder::new()
69165/// #         .with_native_roots()
69166/// #         .unwrap()
69167/// #         .https_or_http()
69168/// #         .enable_http1()
69169/// #         .build()
69170/// # );
69171/// # let mut hub = Dfareporting::new(client, auth);
69172/// // As the method needs a request, you would usually fill it with the desired information
69173/// // into the respective structure. Some of the parts shown here might not be applicable !
69174/// // Values shown here are possibly random and not representative !
69175/// let mut req = Report::default();
69176///
69177/// // You can configure optional parameters by calling the respective setters at will, and
69178/// // execute the final call using `doit()`.
69179/// // Values shown here are possibly random and not representative !
69180/// let result = hub.reports().compatible_fields_query(req, -15)
69181///              .doit().await;
69182/// # }
69183/// ```
69184pub struct ReportCompatibleFieldQueryCall<'a, C>
69185where
69186    C: 'a,
69187{
69188    hub: &'a Dfareporting<C>,
69189    _request: Report,
69190    _profile_id: i64,
69191    _delegate: Option<&'a mut dyn common::Delegate>,
69192    _additional_params: HashMap<String, String>,
69193    _scopes: BTreeSet<String>,
69194}
69195
69196impl<'a, C> common::CallBuilder for ReportCompatibleFieldQueryCall<'a, C> {}
69197
69198impl<'a, C> ReportCompatibleFieldQueryCall<'a, C>
69199where
69200    C: common::Connector,
69201{
69202    /// Perform the operation you have build so far.
69203    pub async fn doit(mut self) -> common::Result<(common::Response, CompatibleFields)> {
69204        use std::borrow::Cow;
69205        use std::io::{Read, Seek};
69206
69207        use common::{url::Params, ToParts};
69208        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
69209
69210        let mut dd = common::DefaultDelegate;
69211        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
69212        dlg.begin(common::MethodInfo {
69213            id: "dfareporting.reports.compatibleFields.query",
69214            http_method: hyper::Method::POST,
69215        });
69216
69217        for &field in ["alt", "profileId"].iter() {
69218            if self._additional_params.contains_key(field) {
69219                dlg.finished(false);
69220                return Err(common::Error::FieldClash(field));
69221            }
69222        }
69223
69224        let mut params = Params::with_capacity(4 + self._additional_params.len());
69225        params.push("profileId", self._profile_id.to_string());
69226
69227        params.extend(self._additional_params.iter());
69228
69229        params.push("alt", "json");
69230        let mut url =
69231            self.hub._base_url.clone() + "userprofiles/{profileId}/reports/compatiblefields/query";
69232        if self._scopes.is_empty() {
69233            self._scopes.insert(Scope::Full.as_ref().to_string());
69234        }
69235
69236        #[allow(clippy::single_element_loop)]
69237        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
69238            url = params.uri_replacement(url, param_name, find_this, false);
69239        }
69240        {
69241            let to_remove = ["profileId"];
69242            params.remove_params(&to_remove);
69243        }
69244
69245        let url = params.parse_with_url(&url);
69246
69247        let mut json_mime_type = mime::APPLICATION_JSON;
69248        let mut request_value_reader = {
69249            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
69250            common::remove_json_null_values(&mut value);
69251            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
69252            serde_json::to_writer(&mut dst, &value).unwrap();
69253            dst
69254        };
69255        let request_size = request_value_reader
69256            .seek(std::io::SeekFrom::End(0))
69257            .unwrap();
69258        request_value_reader
69259            .seek(std::io::SeekFrom::Start(0))
69260            .unwrap();
69261
69262        loop {
69263            let token = match self
69264                .hub
69265                .auth
69266                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
69267                .await
69268            {
69269                Ok(token) => token,
69270                Err(e) => match dlg.token(e) {
69271                    Ok(token) => token,
69272                    Err(e) => {
69273                        dlg.finished(false);
69274                        return Err(common::Error::MissingToken(e));
69275                    }
69276                },
69277            };
69278            request_value_reader
69279                .seek(std::io::SeekFrom::Start(0))
69280                .unwrap();
69281            let mut req_result = {
69282                let client = &self.hub.client;
69283                dlg.pre_request();
69284                let mut req_builder = hyper::Request::builder()
69285                    .method(hyper::Method::POST)
69286                    .uri(url.as_str())
69287                    .header(USER_AGENT, self.hub._user_agent.clone());
69288
69289                if let Some(token) = token.as_ref() {
69290                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
69291                }
69292
69293                let request = req_builder
69294                    .header(CONTENT_TYPE, json_mime_type.to_string())
69295                    .header(CONTENT_LENGTH, request_size as u64)
69296                    .body(common::to_body(
69297                        request_value_reader.get_ref().clone().into(),
69298                    ));
69299
69300                client.request(request.unwrap()).await
69301            };
69302
69303            match req_result {
69304                Err(err) => {
69305                    if let common::Retry::After(d) = dlg.http_error(&err) {
69306                        sleep(d).await;
69307                        continue;
69308                    }
69309                    dlg.finished(false);
69310                    return Err(common::Error::HttpError(err));
69311                }
69312                Ok(res) => {
69313                    let (mut parts, body) = res.into_parts();
69314                    let mut body = common::Body::new(body);
69315                    if !parts.status.is_success() {
69316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69317                        let error = serde_json::from_str(&common::to_string(&bytes));
69318                        let response = common::to_response(parts, bytes.into());
69319
69320                        if let common::Retry::After(d) =
69321                            dlg.http_failure(&response, error.as_ref().ok())
69322                        {
69323                            sleep(d).await;
69324                            continue;
69325                        }
69326
69327                        dlg.finished(false);
69328
69329                        return Err(match error {
69330                            Ok(value) => common::Error::BadRequest(value),
69331                            _ => common::Error::Failure(response),
69332                        });
69333                    }
69334                    let response = {
69335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69336                        let encoded = common::to_string(&bytes);
69337                        match serde_json::from_str(&encoded) {
69338                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
69339                            Err(error) => {
69340                                dlg.response_json_decode_error(&encoded, &error);
69341                                return Err(common::Error::JsonDecodeError(
69342                                    encoded.to_string(),
69343                                    error,
69344                                ));
69345                            }
69346                        }
69347                    };
69348
69349                    dlg.finished(true);
69350                    return Ok(response);
69351                }
69352            }
69353        }
69354    }
69355
69356    ///
69357    /// Sets the *request* property to the given value.
69358    ///
69359    /// Even though the property as already been set when instantiating this call,
69360    /// we provide this method for API completeness.
69361    pub fn request(mut self, new_value: Report) -> ReportCompatibleFieldQueryCall<'a, C> {
69362        self._request = new_value;
69363        self
69364    }
69365    /// The DFA user profile ID.
69366    ///
69367    /// Sets the *profile id* path property to the given value.
69368    ///
69369    /// Even though the property as already been set when instantiating this call,
69370    /// we provide this method for API completeness.
69371    pub fn profile_id(mut self, new_value: i64) -> ReportCompatibleFieldQueryCall<'a, C> {
69372        self._profile_id = new_value;
69373        self
69374    }
69375    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
69376    /// while executing the actual API request.
69377    ///
69378    /// ````text
69379    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
69380    /// ````
69381    ///
69382    /// Sets the *delegate* property to the given value.
69383    pub fn delegate(
69384        mut self,
69385        new_value: &'a mut dyn common::Delegate,
69386    ) -> ReportCompatibleFieldQueryCall<'a, C> {
69387        self._delegate = Some(new_value);
69388        self
69389    }
69390
69391    /// Set any additional parameter of the query string used in the request.
69392    /// It should be used to set parameters which are not yet available through their own
69393    /// setters.
69394    ///
69395    /// Please note that this method must not be used to set any of the known parameters
69396    /// which have their own setter method. If done anyway, the request will fail.
69397    ///
69398    /// # Additional Parameters
69399    ///
69400    /// * *alt* (query-string) - Data format for the response.
69401    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
69402    /// * *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.
69403    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
69404    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
69405    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
69406    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
69407    pub fn param<T>(mut self, name: T, value: T) -> ReportCompatibleFieldQueryCall<'a, C>
69408    where
69409        T: AsRef<str>,
69410    {
69411        self._additional_params
69412            .insert(name.as_ref().to_string(), value.as_ref().to_string());
69413        self
69414    }
69415
69416    /// Identifies the authorization scope for the method you are building.
69417    ///
69418    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
69419    /// [`Scope::Full`].
69420    ///
69421    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
69422    /// tokens for more than one scope.
69423    ///
69424    /// Usually there is more than one suitable scope to authorize an operation, some of which may
69425    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
69426    /// sufficient, a read-write scope will do as well.
69427    pub fn add_scope<St>(mut self, scope: St) -> ReportCompatibleFieldQueryCall<'a, C>
69428    where
69429        St: AsRef<str>,
69430    {
69431        self._scopes.insert(String::from(scope.as_ref()));
69432        self
69433    }
69434    /// Identifies the authorization scope(s) for the method you are building.
69435    ///
69436    /// See [`Self::add_scope()`] for details.
69437    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportCompatibleFieldQueryCall<'a, C>
69438    where
69439        I: IntoIterator<Item = St>,
69440        St: AsRef<str>,
69441    {
69442        self._scopes
69443            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
69444        self
69445    }
69446
69447    /// Removes all scopes, and no default scope will be used either.
69448    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
69449    /// for details).
69450    pub fn clear_scopes(mut self) -> ReportCompatibleFieldQueryCall<'a, C> {
69451        self._scopes.clear();
69452        self
69453    }
69454}
69455
69456/// Retrieves a report file. This method supports media download.
69457///
69458/// This method supports **media download**. To enable it, adjust the builder like this:
69459/// `.param("alt", "media")`.
69460/// Please note that due to missing multi-part support on the server side, you will only receive the media,
69461/// but not the `File` structure that you would usually get. The latter will be a default value.
69462///
69463/// A builder for the *files.get* method supported by a *report* resource.
69464/// It is not used directly, but through a [`ReportMethods`] instance.
69465///
69466/// # Example
69467///
69468/// Instantiate a resource method builder
69469///
69470/// ```test_harness,no_run
69471/// # extern crate hyper;
69472/// # extern crate hyper_rustls;
69473/// # extern crate google_dfareporting3d2 as dfareporting3d2;
69474/// # async fn dox() {
69475/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
69476///
69477/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
69478/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
69479/// #     secret,
69480/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69481/// # ).build().await.unwrap();
69482///
69483/// # let client = hyper_util::client::legacy::Client::builder(
69484/// #     hyper_util::rt::TokioExecutor::new()
69485/// # )
69486/// # .build(
69487/// #     hyper_rustls::HttpsConnectorBuilder::new()
69488/// #         .with_native_roots()
69489/// #         .unwrap()
69490/// #         .https_or_http()
69491/// #         .enable_http1()
69492/// #         .build()
69493/// # );
69494/// # let mut hub = Dfareporting::new(client, auth);
69495/// // You can configure optional parameters by calling the respective setters at will, and
69496/// // execute the final call using `doit()`.
69497/// // Values shown here are possibly random and not representative !
69498/// let result = hub.reports().files_get(-23, -22, -49)
69499///              .doit().await;
69500/// # }
69501/// ```
69502pub struct ReportFileGetCall<'a, C>
69503where
69504    C: 'a,
69505{
69506    hub: &'a Dfareporting<C>,
69507    _profile_id: i64,
69508    _report_id: i64,
69509    _file_id: i64,
69510    _delegate: Option<&'a mut dyn common::Delegate>,
69511    _additional_params: HashMap<String, String>,
69512    _scopes: BTreeSet<String>,
69513}
69514
69515impl<'a, C> common::CallBuilder for ReportFileGetCall<'a, C> {}
69516
69517impl<'a, C> ReportFileGetCall<'a, C>
69518where
69519    C: common::Connector,
69520{
69521    /// Perform the operation you have build so far.
69522    pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
69523        use std::borrow::Cow;
69524        use std::io::{Read, Seek};
69525
69526        use common::{url::Params, ToParts};
69527        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
69528
69529        let mut dd = common::DefaultDelegate;
69530        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
69531        dlg.begin(common::MethodInfo {
69532            id: "dfareporting.reports.files.get",
69533            http_method: hyper::Method::GET,
69534        });
69535
69536        for &field in ["profileId", "reportId", "fileId"].iter() {
69537            if self._additional_params.contains_key(field) {
69538                dlg.finished(false);
69539                return Err(common::Error::FieldClash(field));
69540            }
69541        }
69542
69543        let mut params = Params::with_capacity(4 + self._additional_params.len());
69544        params.push("profileId", self._profile_id.to_string());
69545        params.push("reportId", self._report_id.to_string());
69546        params.push("fileId", self._file_id.to_string());
69547
69548        params.extend(self._additional_params.iter());
69549
69550        let (alt_field_missing, enable_resource_parsing) = {
69551            if let Some(value) = params.get("alt") {
69552                (false, value == "json")
69553            } else {
69554                (true, true)
69555            }
69556        };
69557        if alt_field_missing {
69558            params.push("alt", "json");
69559        }
69560        let mut url = self.hub._base_url.clone()
69561            + "userprofiles/{profileId}/reports/{reportId}/files/{fileId}";
69562        if self._scopes.is_empty() {
69563            self._scopes.insert(Scope::Full.as_ref().to_string());
69564        }
69565
69566        #[allow(clippy::single_element_loop)]
69567        for &(find_this, param_name) in [
69568            ("{profileId}", "profileId"),
69569            ("{reportId}", "reportId"),
69570            ("{fileId}", "fileId"),
69571        ]
69572        .iter()
69573        {
69574            url = params.uri_replacement(url, param_name, find_this, false);
69575        }
69576        {
69577            let to_remove = ["fileId", "reportId", "profileId"];
69578            params.remove_params(&to_remove);
69579        }
69580
69581        let url = params.parse_with_url(&url);
69582
69583        loop {
69584            let token = match self
69585                .hub
69586                .auth
69587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
69588                .await
69589            {
69590                Ok(token) => token,
69591                Err(e) => match dlg.token(e) {
69592                    Ok(token) => token,
69593                    Err(e) => {
69594                        dlg.finished(false);
69595                        return Err(common::Error::MissingToken(e));
69596                    }
69597                },
69598            };
69599            let mut req_result = {
69600                let client = &self.hub.client;
69601                dlg.pre_request();
69602                let mut req_builder = hyper::Request::builder()
69603                    .method(hyper::Method::GET)
69604                    .uri(url.as_str())
69605                    .header(USER_AGENT, self.hub._user_agent.clone());
69606
69607                if let Some(token) = token.as_ref() {
69608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
69609                }
69610
69611                let request = req_builder
69612                    .header(CONTENT_LENGTH, 0_u64)
69613                    .body(common::to_body::<String>(None));
69614
69615                client.request(request.unwrap()).await
69616            };
69617
69618            match req_result {
69619                Err(err) => {
69620                    if let common::Retry::After(d) = dlg.http_error(&err) {
69621                        sleep(d).await;
69622                        continue;
69623                    }
69624                    dlg.finished(false);
69625                    return Err(common::Error::HttpError(err));
69626                }
69627                Ok(res) => {
69628                    let (mut parts, body) = res.into_parts();
69629                    let mut body = common::Body::new(body);
69630                    if !parts.status.is_success() {
69631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69632                        let error = serde_json::from_str(&common::to_string(&bytes));
69633                        let response = common::to_response(parts, bytes.into());
69634
69635                        if let common::Retry::After(d) =
69636                            dlg.http_failure(&response, error.as_ref().ok())
69637                        {
69638                            sleep(d).await;
69639                            continue;
69640                        }
69641
69642                        dlg.finished(false);
69643
69644                        return Err(match error {
69645                            Ok(value) => common::Error::BadRequest(value),
69646                            _ => common::Error::Failure(response),
69647                        });
69648                    }
69649                    let response = if enable_resource_parsing {
69650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69651                        let encoded = common::to_string(&bytes);
69652                        match serde_json::from_str(&encoded) {
69653                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
69654                            Err(error) => {
69655                                dlg.response_json_decode_error(&encoded, &error);
69656                                return Err(common::Error::JsonDecodeError(
69657                                    encoded.to_string(),
69658                                    error,
69659                                ));
69660                            }
69661                        }
69662                    } else {
69663                        (
69664                            common::Response::from_parts(parts, body),
69665                            Default::default(),
69666                        )
69667                    };
69668
69669                    dlg.finished(true);
69670                    return Ok(response);
69671                }
69672            }
69673        }
69674    }
69675
69676    /// The DFA profile ID.
69677    ///
69678    /// Sets the *profile id* path property to the given value.
69679    ///
69680    /// Even though the property as already been set when instantiating this call,
69681    /// we provide this method for API completeness.
69682    pub fn profile_id(mut self, new_value: i64) -> ReportFileGetCall<'a, C> {
69683        self._profile_id = new_value;
69684        self
69685    }
69686    /// The ID of the report.
69687    ///
69688    /// Sets the *report id* path property to the given value.
69689    ///
69690    /// Even though the property as already been set when instantiating this call,
69691    /// we provide this method for API completeness.
69692    pub fn report_id(mut self, new_value: i64) -> ReportFileGetCall<'a, C> {
69693        self._report_id = new_value;
69694        self
69695    }
69696    /// The ID of the report file.
69697    ///
69698    /// Sets the *file id* path property to the given value.
69699    ///
69700    /// Even though the property as already been set when instantiating this call,
69701    /// we provide this method for API completeness.
69702    pub fn file_id(mut self, new_value: i64) -> ReportFileGetCall<'a, C> {
69703        self._file_id = new_value;
69704        self
69705    }
69706    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
69707    /// while executing the actual API request.
69708    ///
69709    /// ````text
69710    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
69711    /// ````
69712    ///
69713    /// Sets the *delegate* property to the given value.
69714    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportFileGetCall<'a, C> {
69715        self._delegate = Some(new_value);
69716        self
69717    }
69718
69719    /// Set any additional parameter of the query string used in the request.
69720    /// It should be used to set parameters which are not yet available through their own
69721    /// setters.
69722    ///
69723    /// Please note that this method must not be used to set any of the known parameters
69724    /// which have their own setter method. If done anyway, the request will fail.
69725    ///
69726    /// # Additional Parameters
69727    ///
69728    /// * *alt* (query-string) - Data format for the response.
69729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
69730    /// * *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.
69731    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
69732    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
69733    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
69734    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
69735    pub fn param<T>(mut self, name: T, value: T) -> ReportFileGetCall<'a, C>
69736    where
69737        T: AsRef<str>,
69738    {
69739        self._additional_params
69740            .insert(name.as_ref().to_string(), value.as_ref().to_string());
69741        self
69742    }
69743
69744    /// Identifies the authorization scope for the method you are building.
69745    ///
69746    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
69747    /// [`Scope::Full`].
69748    ///
69749    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
69750    /// tokens for more than one scope.
69751    ///
69752    /// Usually there is more than one suitable scope to authorize an operation, some of which may
69753    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
69754    /// sufficient, a read-write scope will do as well.
69755    pub fn add_scope<St>(mut self, scope: St) -> ReportFileGetCall<'a, C>
69756    where
69757        St: AsRef<str>,
69758    {
69759        self._scopes.insert(String::from(scope.as_ref()));
69760        self
69761    }
69762    /// Identifies the authorization scope(s) for the method you are building.
69763    ///
69764    /// See [`Self::add_scope()`] for details.
69765    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportFileGetCall<'a, C>
69766    where
69767        I: IntoIterator<Item = St>,
69768        St: AsRef<str>,
69769    {
69770        self._scopes
69771            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
69772        self
69773    }
69774
69775    /// Removes all scopes, and no default scope will be used either.
69776    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
69777    /// for details).
69778    pub fn clear_scopes(mut self) -> ReportFileGetCall<'a, C> {
69779        self._scopes.clear();
69780        self
69781    }
69782}
69783
69784/// Lists files for a report.
69785///
69786/// A builder for the *files.list* method supported by a *report* resource.
69787/// It is not used directly, but through a [`ReportMethods`] instance.
69788///
69789/// # Example
69790///
69791/// Instantiate a resource method builder
69792///
69793/// ```test_harness,no_run
69794/// # extern crate hyper;
69795/// # extern crate hyper_rustls;
69796/// # extern crate google_dfareporting3d2 as dfareporting3d2;
69797/// # async fn dox() {
69798/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
69799///
69800/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
69801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
69802/// #     secret,
69803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69804/// # ).build().await.unwrap();
69805///
69806/// # let client = hyper_util::client::legacy::Client::builder(
69807/// #     hyper_util::rt::TokioExecutor::new()
69808/// # )
69809/// # .build(
69810/// #     hyper_rustls::HttpsConnectorBuilder::new()
69811/// #         .with_native_roots()
69812/// #         .unwrap()
69813/// #         .https_or_http()
69814/// #         .enable_http1()
69815/// #         .build()
69816/// # );
69817/// # let mut hub = Dfareporting::new(client, auth);
69818/// // You can configure optional parameters by calling the respective setters at will, and
69819/// // execute the final call using `doit()`.
69820/// // Values shown here are possibly random and not representative !
69821/// let result = hub.reports().files_list(-29, -44)
69822///              .sort_order("sea")
69823///              .sort_field("vero")
69824///              .page_token("et")
69825///              .max_results(-51)
69826///              .doit().await;
69827/// # }
69828/// ```
69829pub struct ReportFileListCall<'a, C>
69830where
69831    C: 'a,
69832{
69833    hub: &'a Dfareporting<C>,
69834    _profile_id: i64,
69835    _report_id: i64,
69836    _sort_order: Option<String>,
69837    _sort_field: Option<String>,
69838    _page_token: Option<String>,
69839    _max_results: Option<i32>,
69840    _delegate: Option<&'a mut dyn common::Delegate>,
69841    _additional_params: HashMap<String, String>,
69842    _scopes: BTreeSet<String>,
69843}
69844
69845impl<'a, C> common::CallBuilder for ReportFileListCall<'a, C> {}
69846
69847impl<'a, C> ReportFileListCall<'a, C>
69848where
69849    C: common::Connector,
69850{
69851    /// Perform the operation you have build so far.
69852    pub async fn doit(mut self) -> common::Result<(common::Response, FileList)> {
69853        use std::borrow::Cow;
69854        use std::io::{Read, Seek};
69855
69856        use common::{url::Params, ToParts};
69857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
69858
69859        let mut dd = common::DefaultDelegate;
69860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
69861        dlg.begin(common::MethodInfo {
69862            id: "dfareporting.reports.files.list",
69863            http_method: hyper::Method::GET,
69864        });
69865
69866        for &field in [
69867            "alt",
69868            "profileId",
69869            "reportId",
69870            "sortOrder",
69871            "sortField",
69872            "pageToken",
69873            "maxResults",
69874        ]
69875        .iter()
69876        {
69877            if self._additional_params.contains_key(field) {
69878                dlg.finished(false);
69879                return Err(common::Error::FieldClash(field));
69880            }
69881        }
69882
69883        let mut params = Params::with_capacity(8 + self._additional_params.len());
69884        params.push("profileId", self._profile_id.to_string());
69885        params.push("reportId", self._report_id.to_string());
69886        if let Some(value) = self._sort_order.as_ref() {
69887            params.push("sortOrder", value);
69888        }
69889        if let Some(value) = self._sort_field.as_ref() {
69890            params.push("sortField", value);
69891        }
69892        if let Some(value) = self._page_token.as_ref() {
69893            params.push("pageToken", value);
69894        }
69895        if let Some(value) = self._max_results.as_ref() {
69896            params.push("maxResults", value.to_string());
69897        }
69898
69899        params.extend(self._additional_params.iter());
69900
69901        params.push("alt", "json");
69902        let mut url =
69903            self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}/files";
69904        if self._scopes.is_empty() {
69905            self._scopes.insert(Scope::Full.as_ref().to_string());
69906        }
69907
69908        #[allow(clippy::single_element_loop)]
69909        for &(find_this, param_name) in
69910            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
69911        {
69912            url = params.uri_replacement(url, param_name, find_this, false);
69913        }
69914        {
69915            let to_remove = ["reportId", "profileId"];
69916            params.remove_params(&to_remove);
69917        }
69918
69919        let url = params.parse_with_url(&url);
69920
69921        loop {
69922            let token = match self
69923                .hub
69924                .auth
69925                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
69926                .await
69927            {
69928                Ok(token) => token,
69929                Err(e) => match dlg.token(e) {
69930                    Ok(token) => token,
69931                    Err(e) => {
69932                        dlg.finished(false);
69933                        return Err(common::Error::MissingToken(e));
69934                    }
69935                },
69936            };
69937            let mut req_result = {
69938                let client = &self.hub.client;
69939                dlg.pre_request();
69940                let mut req_builder = hyper::Request::builder()
69941                    .method(hyper::Method::GET)
69942                    .uri(url.as_str())
69943                    .header(USER_AGENT, self.hub._user_agent.clone());
69944
69945                if let Some(token) = token.as_ref() {
69946                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
69947                }
69948
69949                let request = req_builder
69950                    .header(CONTENT_LENGTH, 0_u64)
69951                    .body(common::to_body::<String>(None));
69952
69953                client.request(request.unwrap()).await
69954            };
69955
69956            match req_result {
69957                Err(err) => {
69958                    if let common::Retry::After(d) = dlg.http_error(&err) {
69959                        sleep(d).await;
69960                        continue;
69961                    }
69962                    dlg.finished(false);
69963                    return Err(common::Error::HttpError(err));
69964                }
69965                Ok(res) => {
69966                    let (mut parts, body) = res.into_parts();
69967                    let mut body = common::Body::new(body);
69968                    if !parts.status.is_success() {
69969                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69970                        let error = serde_json::from_str(&common::to_string(&bytes));
69971                        let response = common::to_response(parts, bytes.into());
69972
69973                        if let common::Retry::After(d) =
69974                            dlg.http_failure(&response, error.as_ref().ok())
69975                        {
69976                            sleep(d).await;
69977                            continue;
69978                        }
69979
69980                        dlg.finished(false);
69981
69982                        return Err(match error {
69983                            Ok(value) => common::Error::BadRequest(value),
69984                            _ => common::Error::Failure(response),
69985                        });
69986                    }
69987                    let response = {
69988                        let bytes = common::to_bytes(body).await.unwrap_or_default();
69989                        let encoded = common::to_string(&bytes);
69990                        match serde_json::from_str(&encoded) {
69991                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
69992                            Err(error) => {
69993                                dlg.response_json_decode_error(&encoded, &error);
69994                                return Err(common::Error::JsonDecodeError(
69995                                    encoded.to_string(),
69996                                    error,
69997                                ));
69998                            }
69999                        }
70000                    };
70001
70002                    dlg.finished(true);
70003                    return Ok(response);
70004                }
70005            }
70006        }
70007    }
70008
70009    /// The DFA profile ID.
70010    ///
70011    /// Sets the *profile id* path property to the given value.
70012    ///
70013    /// Even though the property as already been set when instantiating this call,
70014    /// we provide this method for API completeness.
70015    pub fn profile_id(mut self, new_value: i64) -> ReportFileListCall<'a, C> {
70016        self._profile_id = new_value;
70017        self
70018    }
70019    /// The ID of the parent report.
70020    ///
70021    /// Sets the *report id* path property to the given value.
70022    ///
70023    /// Even though the property as already been set when instantiating this call,
70024    /// we provide this method for API completeness.
70025    pub fn report_id(mut self, new_value: i64) -> ReportFileListCall<'a, C> {
70026        self._report_id = new_value;
70027        self
70028    }
70029    /// Order of sorted results.
70030    ///
70031    /// Sets the *sort order* query property to the given value.
70032    pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, C> {
70033        self._sort_order = Some(new_value.to_string());
70034        self
70035    }
70036    /// The field by which to sort the list.
70037    ///
70038    /// Sets the *sort field* query property to the given value.
70039    pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, C> {
70040        self._sort_field = Some(new_value.to_string());
70041        self
70042    }
70043    /// The value of the nextToken from the previous result page.
70044    ///
70045    /// Sets the *page token* query property to the given value.
70046    pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, C> {
70047        self._page_token = Some(new_value.to_string());
70048        self
70049    }
70050    /// Maximum number of results to return.
70051    ///
70052    /// Sets the *max results* query property to the given value.
70053    pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'a, C> {
70054        self._max_results = Some(new_value);
70055        self
70056    }
70057    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
70058    /// while executing the actual API request.
70059    ///
70060    /// ````text
70061    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
70062    /// ````
70063    ///
70064    /// Sets the *delegate* property to the given value.
70065    pub fn delegate(
70066        mut self,
70067        new_value: &'a mut dyn common::Delegate,
70068    ) -> ReportFileListCall<'a, C> {
70069        self._delegate = Some(new_value);
70070        self
70071    }
70072
70073    /// Set any additional parameter of the query string used in the request.
70074    /// It should be used to set parameters which are not yet available through their own
70075    /// setters.
70076    ///
70077    /// Please note that this method must not be used to set any of the known parameters
70078    /// which have their own setter method. If done anyway, the request will fail.
70079    ///
70080    /// # Additional Parameters
70081    ///
70082    /// * *alt* (query-string) - Data format for the response.
70083    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
70084    /// * *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.
70085    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
70086    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
70087    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
70088    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
70089    pub fn param<T>(mut self, name: T, value: T) -> ReportFileListCall<'a, C>
70090    where
70091        T: AsRef<str>,
70092    {
70093        self._additional_params
70094            .insert(name.as_ref().to_string(), value.as_ref().to_string());
70095        self
70096    }
70097
70098    /// Identifies the authorization scope for the method you are building.
70099    ///
70100    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
70101    /// [`Scope::Full`].
70102    ///
70103    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
70104    /// tokens for more than one scope.
70105    ///
70106    /// Usually there is more than one suitable scope to authorize an operation, some of which may
70107    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
70108    /// sufficient, a read-write scope will do as well.
70109    pub fn add_scope<St>(mut self, scope: St) -> ReportFileListCall<'a, C>
70110    where
70111        St: AsRef<str>,
70112    {
70113        self._scopes.insert(String::from(scope.as_ref()));
70114        self
70115    }
70116    /// Identifies the authorization scope(s) for the method you are building.
70117    ///
70118    /// See [`Self::add_scope()`] for details.
70119    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportFileListCall<'a, C>
70120    where
70121        I: IntoIterator<Item = St>,
70122        St: AsRef<str>,
70123    {
70124        self._scopes
70125            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
70126        self
70127    }
70128
70129    /// Removes all scopes, and no default scope will be used either.
70130    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
70131    /// for details).
70132    pub fn clear_scopes(mut self) -> ReportFileListCall<'a, C> {
70133        self._scopes.clear();
70134        self
70135    }
70136}
70137
70138/// Deletes a report by its ID.
70139///
70140/// A builder for the *delete* method supported by a *report* resource.
70141/// It is not used directly, but through a [`ReportMethods`] instance.
70142///
70143/// # Example
70144///
70145/// Instantiate a resource method builder
70146///
70147/// ```test_harness,no_run
70148/// # extern crate hyper;
70149/// # extern crate hyper_rustls;
70150/// # extern crate google_dfareporting3d2 as dfareporting3d2;
70151/// # async fn dox() {
70152/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
70153///
70154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
70155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
70156/// #     secret,
70157/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
70158/// # ).build().await.unwrap();
70159///
70160/// # let client = hyper_util::client::legacy::Client::builder(
70161/// #     hyper_util::rt::TokioExecutor::new()
70162/// # )
70163/// # .build(
70164/// #     hyper_rustls::HttpsConnectorBuilder::new()
70165/// #         .with_native_roots()
70166/// #         .unwrap()
70167/// #         .https_or_http()
70168/// #         .enable_http1()
70169/// #         .build()
70170/// # );
70171/// # let mut hub = Dfareporting::new(client, auth);
70172/// // You can configure optional parameters by calling the respective setters at will, and
70173/// // execute the final call using `doit()`.
70174/// // Values shown here are possibly random and not representative !
70175/// let result = hub.reports().delete(-53, -6)
70176///              .doit().await;
70177/// # }
70178/// ```
70179pub struct ReportDeleteCall<'a, C>
70180where
70181    C: 'a,
70182{
70183    hub: &'a Dfareporting<C>,
70184    _profile_id: i64,
70185    _report_id: i64,
70186    _delegate: Option<&'a mut dyn common::Delegate>,
70187    _additional_params: HashMap<String, String>,
70188    _scopes: BTreeSet<String>,
70189}
70190
70191impl<'a, C> common::CallBuilder for ReportDeleteCall<'a, C> {}
70192
70193impl<'a, C> ReportDeleteCall<'a, C>
70194where
70195    C: common::Connector,
70196{
70197    /// Perform the operation you have build so far.
70198    pub async fn doit(mut self) -> common::Result<common::Response> {
70199        use std::borrow::Cow;
70200        use std::io::{Read, Seek};
70201
70202        use common::{url::Params, ToParts};
70203        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
70204
70205        let mut dd = common::DefaultDelegate;
70206        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
70207        dlg.begin(common::MethodInfo {
70208            id: "dfareporting.reports.delete",
70209            http_method: hyper::Method::DELETE,
70210        });
70211
70212        for &field in ["profileId", "reportId"].iter() {
70213            if self._additional_params.contains_key(field) {
70214                dlg.finished(false);
70215                return Err(common::Error::FieldClash(field));
70216            }
70217        }
70218
70219        let mut params = Params::with_capacity(3 + self._additional_params.len());
70220        params.push("profileId", self._profile_id.to_string());
70221        params.push("reportId", self._report_id.to_string());
70222
70223        params.extend(self._additional_params.iter());
70224
70225        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}";
70226        if self._scopes.is_empty() {
70227            self._scopes.insert(Scope::Full.as_ref().to_string());
70228        }
70229
70230        #[allow(clippy::single_element_loop)]
70231        for &(find_this, param_name) in
70232            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
70233        {
70234            url = params.uri_replacement(url, param_name, find_this, false);
70235        }
70236        {
70237            let to_remove = ["reportId", "profileId"];
70238            params.remove_params(&to_remove);
70239        }
70240
70241        let url = params.parse_with_url(&url);
70242
70243        loop {
70244            let token = match self
70245                .hub
70246                .auth
70247                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
70248                .await
70249            {
70250                Ok(token) => token,
70251                Err(e) => match dlg.token(e) {
70252                    Ok(token) => token,
70253                    Err(e) => {
70254                        dlg.finished(false);
70255                        return Err(common::Error::MissingToken(e));
70256                    }
70257                },
70258            };
70259            let mut req_result = {
70260                let client = &self.hub.client;
70261                dlg.pre_request();
70262                let mut req_builder = hyper::Request::builder()
70263                    .method(hyper::Method::DELETE)
70264                    .uri(url.as_str())
70265                    .header(USER_AGENT, self.hub._user_agent.clone());
70266
70267                if let Some(token) = token.as_ref() {
70268                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
70269                }
70270
70271                let request = req_builder
70272                    .header(CONTENT_LENGTH, 0_u64)
70273                    .body(common::to_body::<String>(None));
70274
70275                client.request(request.unwrap()).await
70276            };
70277
70278            match req_result {
70279                Err(err) => {
70280                    if let common::Retry::After(d) = dlg.http_error(&err) {
70281                        sleep(d).await;
70282                        continue;
70283                    }
70284                    dlg.finished(false);
70285                    return Err(common::Error::HttpError(err));
70286                }
70287                Ok(res) => {
70288                    let (mut parts, body) = res.into_parts();
70289                    let mut body = common::Body::new(body);
70290                    if !parts.status.is_success() {
70291                        let bytes = common::to_bytes(body).await.unwrap_or_default();
70292                        let error = serde_json::from_str(&common::to_string(&bytes));
70293                        let response = common::to_response(parts, bytes.into());
70294
70295                        if let common::Retry::After(d) =
70296                            dlg.http_failure(&response, error.as_ref().ok())
70297                        {
70298                            sleep(d).await;
70299                            continue;
70300                        }
70301
70302                        dlg.finished(false);
70303
70304                        return Err(match error {
70305                            Ok(value) => common::Error::BadRequest(value),
70306                            _ => common::Error::Failure(response),
70307                        });
70308                    }
70309                    let response = common::Response::from_parts(parts, body);
70310
70311                    dlg.finished(true);
70312                    return Ok(response);
70313                }
70314            }
70315        }
70316    }
70317
70318    /// The DFA user profile ID.
70319    ///
70320    /// Sets the *profile id* path property to the given value.
70321    ///
70322    /// Even though the property as already been set when instantiating this call,
70323    /// we provide this method for API completeness.
70324    pub fn profile_id(mut self, new_value: i64) -> ReportDeleteCall<'a, C> {
70325        self._profile_id = new_value;
70326        self
70327    }
70328    /// The ID of the report.
70329    ///
70330    /// Sets the *report id* path property to the given value.
70331    ///
70332    /// Even though the property as already been set when instantiating this call,
70333    /// we provide this method for API completeness.
70334    pub fn report_id(mut self, new_value: i64) -> ReportDeleteCall<'a, C> {
70335        self._report_id = new_value;
70336        self
70337    }
70338    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
70339    /// while executing the actual API request.
70340    ///
70341    /// ````text
70342    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
70343    /// ````
70344    ///
70345    /// Sets the *delegate* property to the given value.
70346    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportDeleteCall<'a, C> {
70347        self._delegate = Some(new_value);
70348        self
70349    }
70350
70351    /// Set any additional parameter of the query string used in the request.
70352    /// It should be used to set parameters which are not yet available through their own
70353    /// setters.
70354    ///
70355    /// Please note that this method must not be used to set any of the known parameters
70356    /// which have their own setter method. If done anyway, the request will fail.
70357    ///
70358    /// # Additional Parameters
70359    ///
70360    /// * *alt* (query-string) - Data format for the response.
70361    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
70362    /// * *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.
70363    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
70364    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
70365    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
70366    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
70367    pub fn param<T>(mut self, name: T, value: T) -> ReportDeleteCall<'a, C>
70368    where
70369        T: AsRef<str>,
70370    {
70371        self._additional_params
70372            .insert(name.as_ref().to_string(), value.as_ref().to_string());
70373        self
70374    }
70375
70376    /// Identifies the authorization scope for the method you are building.
70377    ///
70378    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
70379    /// [`Scope::Full`].
70380    ///
70381    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
70382    /// tokens for more than one scope.
70383    ///
70384    /// Usually there is more than one suitable scope to authorize an operation, some of which may
70385    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
70386    /// sufficient, a read-write scope will do as well.
70387    pub fn add_scope<St>(mut self, scope: St) -> ReportDeleteCall<'a, C>
70388    where
70389        St: AsRef<str>,
70390    {
70391        self._scopes.insert(String::from(scope.as_ref()));
70392        self
70393    }
70394    /// Identifies the authorization scope(s) for the method you are building.
70395    ///
70396    /// See [`Self::add_scope()`] for details.
70397    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportDeleteCall<'a, C>
70398    where
70399        I: IntoIterator<Item = St>,
70400        St: AsRef<str>,
70401    {
70402        self._scopes
70403            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
70404        self
70405    }
70406
70407    /// Removes all scopes, and no default scope will be used either.
70408    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
70409    /// for details).
70410    pub fn clear_scopes(mut self) -> ReportDeleteCall<'a, C> {
70411        self._scopes.clear();
70412        self
70413    }
70414}
70415
70416/// Retrieves a report by its ID.
70417///
70418/// A builder for the *get* method supported by a *report* resource.
70419/// It is not used directly, but through a [`ReportMethods`] instance.
70420///
70421/// # Example
70422///
70423/// Instantiate a resource method builder
70424///
70425/// ```test_harness,no_run
70426/// # extern crate hyper;
70427/// # extern crate hyper_rustls;
70428/// # extern crate google_dfareporting3d2 as dfareporting3d2;
70429/// # async fn dox() {
70430/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
70431///
70432/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
70433/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
70434/// #     secret,
70435/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
70436/// # ).build().await.unwrap();
70437///
70438/// # let client = hyper_util::client::legacy::Client::builder(
70439/// #     hyper_util::rt::TokioExecutor::new()
70440/// # )
70441/// # .build(
70442/// #     hyper_rustls::HttpsConnectorBuilder::new()
70443/// #         .with_native_roots()
70444/// #         .unwrap()
70445/// #         .https_or_http()
70446/// #         .enable_http1()
70447/// #         .build()
70448/// # );
70449/// # let mut hub = Dfareporting::new(client, auth);
70450/// // You can configure optional parameters by calling the respective setters at will, and
70451/// // execute the final call using `doit()`.
70452/// // Values shown here are possibly random and not representative !
70453/// let result = hub.reports().get(-52, -79)
70454///              .doit().await;
70455/// # }
70456/// ```
70457pub struct ReportGetCall<'a, C>
70458where
70459    C: 'a,
70460{
70461    hub: &'a Dfareporting<C>,
70462    _profile_id: i64,
70463    _report_id: i64,
70464    _delegate: Option<&'a mut dyn common::Delegate>,
70465    _additional_params: HashMap<String, String>,
70466    _scopes: BTreeSet<String>,
70467}
70468
70469impl<'a, C> common::CallBuilder for ReportGetCall<'a, C> {}
70470
70471impl<'a, C> ReportGetCall<'a, C>
70472where
70473    C: common::Connector,
70474{
70475    /// Perform the operation you have build so far.
70476    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
70477        use std::borrow::Cow;
70478        use std::io::{Read, Seek};
70479
70480        use common::{url::Params, ToParts};
70481        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
70482
70483        let mut dd = common::DefaultDelegate;
70484        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
70485        dlg.begin(common::MethodInfo {
70486            id: "dfareporting.reports.get",
70487            http_method: hyper::Method::GET,
70488        });
70489
70490        for &field in ["alt", "profileId", "reportId"].iter() {
70491            if self._additional_params.contains_key(field) {
70492                dlg.finished(false);
70493                return Err(common::Error::FieldClash(field));
70494            }
70495        }
70496
70497        let mut params = Params::with_capacity(4 + self._additional_params.len());
70498        params.push("profileId", self._profile_id.to_string());
70499        params.push("reportId", self._report_id.to_string());
70500
70501        params.extend(self._additional_params.iter());
70502
70503        params.push("alt", "json");
70504        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}";
70505        if self._scopes.is_empty() {
70506            self._scopes.insert(Scope::Full.as_ref().to_string());
70507        }
70508
70509        #[allow(clippy::single_element_loop)]
70510        for &(find_this, param_name) in
70511            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
70512        {
70513            url = params.uri_replacement(url, param_name, find_this, false);
70514        }
70515        {
70516            let to_remove = ["reportId", "profileId"];
70517            params.remove_params(&to_remove);
70518        }
70519
70520        let url = params.parse_with_url(&url);
70521
70522        loop {
70523            let token = match self
70524                .hub
70525                .auth
70526                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
70527                .await
70528            {
70529                Ok(token) => token,
70530                Err(e) => match dlg.token(e) {
70531                    Ok(token) => token,
70532                    Err(e) => {
70533                        dlg.finished(false);
70534                        return Err(common::Error::MissingToken(e));
70535                    }
70536                },
70537            };
70538            let mut req_result = {
70539                let client = &self.hub.client;
70540                dlg.pre_request();
70541                let mut req_builder = hyper::Request::builder()
70542                    .method(hyper::Method::GET)
70543                    .uri(url.as_str())
70544                    .header(USER_AGENT, self.hub._user_agent.clone());
70545
70546                if let Some(token) = token.as_ref() {
70547                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
70548                }
70549
70550                let request = req_builder
70551                    .header(CONTENT_LENGTH, 0_u64)
70552                    .body(common::to_body::<String>(None));
70553
70554                client.request(request.unwrap()).await
70555            };
70556
70557            match req_result {
70558                Err(err) => {
70559                    if let common::Retry::After(d) = dlg.http_error(&err) {
70560                        sleep(d).await;
70561                        continue;
70562                    }
70563                    dlg.finished(false);
70564                    return Err(common::Error::HttpError(err));
70565                }
70566                Ok(res) => {
70567                    let (mut parts, body) = res.into_parts();
70568                    let mut body = common::Body::new(body);
70569                    if !parts.status.is_success() {
70570                        let bytes = common::to_bytes(body).await.unwrap_or_default();
70571                        let error = serde_json::from_str(&common::to_string(&bytes));
70572                        let response = common::to_response(parts, bytes.into());
70573
70574                        if let common::Retry::After(d) =
70575                            dlg.http_failure(&response, error.as_ref().ok())
70576                        {
70577                            sleep(d).await;
70578                            continue;
70579                        }
70580
70581                        dlg.finished(false);
70582
70583                        return Err(match error {
70584                            Ok(value) => common::Error::BadRequest(value),
70585                            _ => common::Error::Failure(response),
70586                        });
70587                    }
70588                    let response = {
70589                        let bytes = common::to_bytes(body).await.unwrap_or_default();
70590                        let encoded = common::to_string(&bytes);
70591                        match serde_json::from_str(&encoded) {
70592                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
70593                            Err(error) => {
70594                                dlg.response_json_decode_error(&encoded, &error);
70595                                return Err(common::Error::JsonDecodeError(
70596                                    encoded.to_string(),
70597                                    error,
70598                                ));
70599                            }
70600                        }
70601                    };
70602
70603                    dlg.finished(true);
70604                    return Ok(response);
70605                }
70606            }
70607        }
70608    }
70609
70610    /// The DFA user profile ID.
70611    ///
70612    /// Sets the *profile id* path property to the given value.
70613    ///
70614    /// Even though the property as already been set when instantiating this call,
70615    /// we provide this method for API completeness.
70616    pub fn profile_id(mut self, new_value: i64) -> ReportGetCall<'a, C> {
70617        self._profile_id = new_value;
70618        self
70619    }
70620    /// The ID of the report.
70621    ///
70622    /// Sets the *report id* path property to the given value.
70623    ///
70624    /// Even though the property as already been set when instantiating this call,
70625    /// we provide this method for API completeness.
70626    pub fn report_id(mut self, new_value: i64) -> ReportGetCall<'a, C> {
70627        self._report_id = new_value;
70628        self
70629    }
70630    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
70631    /// while executing the actual API request.
70632    ///
70633    /// ````text
70634    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
70635    /// ````
70636    ///
70637    /// Sets the *delegate* property to the given value.
70638    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportGetCall<'a, C> {
70639        self._delegate = Some(new_value);
70640        self
70641    }
70642
70643    /// Set any additional parameter of the query string used in the request.
70644    /// It should be used to set parameters which are not yet available through their own
70645    /// setters.
70646    ///
70647    /// Please note that this method must not be used to set any of the known parameters
70648    /// which have their own setter method. If done anyway, the request will fail.
70649    ///
70650    /// # Additional Parameters
70651    ///
70652    /// * *alt* (query-string) - Data format for the response.
70653    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
70654    /// * *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.
70655    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
70656    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
70657    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
70658    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
70659    pub fn param<T>(mut self, name: T, value: T) -> ReportGetCall<'a, C>
70660    where
70661        T: AsRef<str>,
70662    {
70663        self._additional_params
70664            .insert(name.as_ref().to_string(), value.as_ref().to_string());
70665        self
70666    }
70667
70668    /// Identifies the authorization scope for the method you are building.
70669    ///
70670    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
70671    /// [`Scope::Full`].
70672    ///
70673    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
70674    /// tokens for more than one scope.
70675    ///
70676    /// Usually there is more than one suitable scope to authorize an operation, some of which may
70677    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
70678    /// sufficient, a read-write scope will do as well.
70679    pub fn add_scope<St>(mut self, scope: St) -> ReportGetCall<'a, C>
70680    where
70681        St: AsRef<str>,
70682    {
70683        self._scopes.insert(String::from(scope.as_ref()));
70684        self
70685    }
70686    /// Identifies the authorization scope(s) for the method you are building.
70687    ///
70688    /// See [`Self::add_scope()`] for details.
70689    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportGetCall<'a, C>
70690    where
70691        I: IntoIterator<Item = St>,
70692        St: AsRef<str>,
70693    {
70694        self._scopes
70695            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
70696        self
70697    }
70698
70699    /// Removes all scopes, and no default scope will be used either.
70700    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
70701    /// for details).
70702    pub fn clear_scopes(mut self) -> ReportGetCall<'a, C> {
70703        self._scopes.clear();
70704        self
70705    }
70706}
70707
70708/// Creates a report.
70709///
70710/// A builder for the *insert* method supported by a *report* resource.
70711/// It is not used directly, but through a [`ReportMethods`] instance.
70712///
70713/// # Example
70714///
70715/// Instantiate a resource method builder
70716///
70717/// ```test_harness,no_run
70718/// # extern crate hyper;
70719/// # extern crate hyper_rustls;
70720/// # extern crate google_dfareporting3d2 as dfareporting3d2;
70721/// use dfareporting3d2::api::Report;
70722/// # async fn dox() {
70723/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
70724///
70725/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
70726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
70727/// #     secret,
70728/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
70729/// # ).build().await.unwrap();
70730///
70731/// # let client = hyper_util::client::legacy::Client::builder(
70732/// #     hyper_util::rt::TokioExecutor::new()
70733/// # )
70734/// # .build(
70735/// #     hyper_rustls::HttpsConnectorBuilder::new()
70736/// #         .with_native_roots()
70737/// #         .unwrap()
70738/// #         .https_or_http()
70739/// #         .enable_http1()
70740/// #         .build()
70741/// # );
70742/// # let mut hub = Dfareporting::new(client, auth);
70743/// // As the method needs a request, you would usually fill it with the desired information
70744/// // into the respective structure. Some of the parts shown here might not be applicable !
70745/// // Values shown here are possibly random and not representative !
70746/// let mut req = Report::default();
70747///
70748/// // You can configure optional parameters by calling the respective setters at will, and
70749/// // execute the final call using `doit()`.
70750/// // Values shown here are possibly random and not representative !
70751/// let result = hub.reports().insert(req, -92)
70752///              .doit().await;
70753/// # }
70754/// ```
70755pub struct ReportInsertCall<'a, C>
70756where
70757    C: 'a,
70758{
70759    hub: &'a Dfareporting<C>,
70760    _request: Report,
70761    _profile_id: i64,
70762    _delegate: Option<&'a mut dyn common::Delegate>,
70763    _additional_params: HashMap<String, String>,
70764    _scopes: BTreeSet<String>,
70765}
70766
70767impl<'a, C> common::CallBuilder for ReportInsertCall<'a, C> {}
70768
70769impl<'a, C> ReportInsertCall<'a, C>
70770where
70771    C: common::Connector,
70772{
70773    /// Perform the operation you have build so far.
70774    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
70775        use std::borrow::Cow;
70776        use std::io::{Read, Seek};
70777
70778        use common::{url::Params, ToParts};
70779        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
70780
70781        let mut dd = common::DefaultDelegate;
70782        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
70783        dlg.begin(common::MethodInfo {
70784            id: "dfareporting.reports.insert",
70785            http_method: hyper::Method::POST,
70786        });
70787
70788        for &field in ["alt", "profileId"].iter() {
70789            if self._additional_params.contains_key(field) {
70790                dlg.finished(false);
70791                return Err(common::Error::FieldClash(field));
70792            }
70793        }
70794
70795        let mut params = Params::with_capacity(4 + self._additional_params.len());
70796        params.push("profileId", self._profile_id.to_string());
70797
70798        params.extend(self._additional_params.iter());
70799
70800        params.push("alt", "json");
70801        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports";
70802        if self._scopes.is_empty() {
70803            self._scopes.insert(Scope::Full.as_ref().to_string());
70804        }
70805
70806        #[allow(clippy::single_element_loop)]
70807        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
70808            url = params.uri_replacement(url, param_name, find_this, false);
70809        }
70810        {
70811            let to_remove = ["profileId"];
70812            params.remove_params(&to_remove);
70813        }
70814
70815        let url = params.parse_with_url(&url);
70816
70817        let mut json_mime_type = mime::APPLICATION_JSON;
70818        let mut request_value_reader = {
70819            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
70820            common::remove_json_null_values(&mut value);
70821            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
70822            serde_json::to_writer(&mut dst, &value).unwrap();
70823            dst
70824        };
70825        let request_size = request_value_reader
70826            .seek(std::io::SeekFrom::End(0))
70827            .unwrap();
70828        request_value_reader
70829            .seek(std::io::SeekFrom::Start(0))
70830            .unwrap();
70831
70832        loop {
70833            let token = match self
70834                .hub
70835                .auth
70836                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
70837                .await
70838            {
70839                Ok(token) => token,
70840                Err(e) => match dlg.token(e) {
70841                    Ok(token) => token,
70842                    Err(e) => {
70843                        dlg.finished(false);
70844                        return Err(common::Error::MissingToken(e));
70845                    }
70846                },
70847            };
70848            request_value_reader
70849                .seek(std::io::SeekFrom::Start(0))
70850                .unwrap();
70851            let mut req_result = {
70852                let client = &self.hub.client;
70853                dlg.pre_request();
70854                let mut req_builder = hyper::Request::builder()
70855                    .method(hyper::Method::POST)
70856                    .uri(url.as_str())
70857                    .header(USER_AGENT, self.hub._user_agent.clone());
70858
70859                if let Some(token) = token.as_ref() {
70860                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
70861                }
70862
70863                let request = req_builder
70864                    .header(CONTENT_TYPE, json_mime_type.to_string())
70865                    .header(CONTENT_LENGTH, request_size as u64)
70866                    .body(common::to_body(
70867                        request_value_reader.get_ref().clone().into(),
70868                    ));
70869
70870                client.request(request.unwrap()).await
70871            };
70872
70873            match req_result {
70874                Err(err) => {
70875                    if let common::Retry::After(d) = dlg.http_error(&err) {
70876                        sleep(d).await;
70877                        continue;
70878                    }
70879                    dlg.finished(false);
70880                    return Err(common::Error::HttpError(err));
70881                }
70882                Ok(res) => {
70883                    let (mut parts, body) = res.into_parts();
70884                    let mut body = common::Body::new(body);
70885                    if !parts.status.is_success() {
70886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
70887                        let error = serde_json::from_str(&common::to_string(&bytes));
70888                        let response = common::to_response(parts, bytes.into());
70889
70890                        if let common::Retry::After(d) =
70891                            dlg.http_failure(&response, error.as_ref().ok())
70892                        {
70893                            sleep(d).await;
70894                            continue;
70895                        }
70896
70897                        dlg.finished(false);
70898
70899                        return Err(match error {
70900                            Ok(value) => common::Error::BadRequest(value),
70901                            _ => common::Error::Failure(response),
70902                        });
70903                    }
70904                    let response = {
70905                        let bytes = common::to_bytes(body).await.unwrap_or_default();
70906                        let encoded = common::to_string(&bytes);
70907                        match serde_json::from_str(&encoded) {
70908                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
70909                            Err(error) => {
70910                                dlg.response_json_decode_error(&encoded, &error);
70911                                return Err(common::Error::JsonDecodeError(
70912                                    encoded.to_string(),
70913                                    error,
70914                                ));
70915                            }
70916                        }
70917                    };
70918
70919                    dlg.finished(true);
70920                    return Ok(response);
70921                }
70922            }
70923        }
70924    }
70925
70926    ///
70927    /// Sets the *request* property to the given value.
70928    ///
70929    /// Even though the property as already been set when instantiating this call,
70930    /// we provide this method for API completeness.
70931    pub fn request(mut self, new_value: Report) -> ReportInsertCall<'a, C> {
70932        self._request = new_value;
70933        self
70934    }
70935    /// The DFA user profile ID.
70936    ///
70937    /// Sets the *profile id* path property to the given value.
70938    ///
70939    /// Even though the property as already been set when instantiating this call,
70940    /// we provide this method for API completeness.
70941    pub fn profile_id(mut self, new_value: i64) -> ReportInsertCall<'a, C> {
70942        self._profile_id = new_value;
70943        self
70944    }
70945    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
70946    /// while executing the actual API request.
70947    ///
70948    /// ````text
70949    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
70950    /// ````
70951    ///
70952    /// Sets the *delegate* property to the given value.
70953    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportInsertCall<'a, C> {
70954        self._delegate = Some(new_value);
70955        self
70956    }
70957
70958    /// Set any additional parameter of the query string used in the request.
70959    /// It should be used to set parameters which are not yet available through their own
70960    /// setters.
70961    ///
70962    /// Please note that this method must not be used to set any of the known parameters
70963    /// which have their own setter method. If done anyway, the request will fail.
70964    ///
70965    /// # Additional Parameters
70966    ///
70967    /// * *alt* (query-string) - Data format for the response.
70968    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
70969    /// * *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.
70970    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
70971    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
70972    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
70973    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
70974    pub fn param<T>(mut self, name: T, value: T) -> ReportInsertCall<'a, C>
70975    where
70976        T: AsRef<str>,
70977    {
70978        self._additional_params
70979            .insert(name.as_ref().to_string(), value.as_ref().to_string());
70980        self
70981    }
70982
70983    /// Identifies the authorization scope for the method you are building.
70984    ///
70985    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
70986    /// [`Scope::Full`].
70987    ///
70988    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
70989    /// tokens for more than one scope.
70990    ///
70991    /// Usually there is more than one suitable scope to authorize an operation, some of which may
70992    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
70993    /// sufficient, a read-write scope will do as well.
70994    pub fn add_scope<St>(mut self, scope: St) -> ReportInsertCall<'a, C>
70995    where
70996        St: AsRef<str>,
70997    {
70998        self._scopes.insert(String::from(scope.as_ref()));
70999        self
71000    }
71001    /// Identifies the authorization scope(s) for the method you are building.
71002    ///
71003    /// See [`Self::add_scope()`] for details.
71004    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportInsertCall<'a, C>
71005    where
71006        I: IntoIterator<Item = St>,
71007        St: AsRef<str>,
71008    {
71009        self._scopes
71010            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
71011        self
71012    }
71013
71014    /// Removes all scopes, and no default scope will be used either.
71015    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
71016    /// for details).
71017    pub fn clear_scopes(mut self) -> ReportInsertCall<'a, C> {
71018        self._scopes.clear();
71019        self
71020    }
71021}
71022
71023/// Retrieves list of reports.
71024///
71025/// A builder for the *list* method supported by a *report* resource.
71026/// It is not used directly, but through a [`ReportMethods`] instance.
71027///
71028/// # Example
71029///
71030/// Instantiate a resource method builder
71031///
71032/// ```test_harness,no_run
71033/// # extern crate hyper;
71034/// # extern crate hyper_rustls;
71035/// # extern crate google_dfareporting3d2 as dfareporting3d2;
71036/// # async fn dox() {
71037/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
71038///
71039/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
71040/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
71041/// #     secret,
71042/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
71043/// # ).build().await.unwrap();
71044///
71045/// # let client = hyper_util::client::legacy::Client::builder(
71046/// #     hyper_util::rt::TokioExecutor::new()
71047/// # )
71048/// # .build(
71049/// #     hyper_rustls::HttpsConnectorBuilder::new()
71050/// #         .with_native_roots()
71051/// #         .unwrap()
71052/// #         .https_or_http()
71053/// #         .enable_http1()
71054/// #         .build()
71055/// # );
71056/// # let mut hub = Dfareporting::new(client, auth);
71057/// // You can configure optional parameters by calling the respective setters at will, and
71058/// // execute the final call using `doit()`.
71059/// // Values shown here are possibly random and not representative !
71060/// let result = hub.reports().list(-68)
71061///              .sort_order("takimata")
71062///              .sort_field("et")
71063///              .scope("dolores")
71064///              .page_token("dolores")
71065///              .max_results(-29)
71066///              .doit().await;
71067/// # }
71068/// ```
71069pub struct ReportListCall<'a, C>
71070where
71071    C: 'a,
71072{
71073    hub: &'a Dfareporting<C>,
71074    _profile_id: i64,
71075    _sort_order: Option<String>,
71076    _sort_field: Option<String>,
71077    _scope: Option<String>,
71078    _page_token: Option<String>,
71079    _max_results: Option<i32>,
71080    _delegate: Option<&'a mut dyn common::Delegate>,
71081    _additional_params: HashMap<String, String>,
71082    _scopes: BTreeSet<String>,
71083}
71084
71085impl<'a, C> common::CallBuilder for ReportListCall<'a, C> {}
71086
71087impl<'a, C> ReportListCall<'a, C>
71088where
71089    C: common::Connector,
71090{
71091    /// Perform the operation you have build so far.
71092    pub async fn doit(mut self) -> common::Result<(common::Response, ReportList)> {
71093        use std::borrow::Cow;
71094        use std::io::{Read, Seek};
71095
71096        use common::{url::Params, ToParts};
71097        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
71098
71099        let mut dd = common::DefaultDelegate;
71100        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
71101        dlg.begin(common::MethodInfo {
71102            id: "dfareporting.reports.list",
71103            http_method: hyper::Method::GET,
71104        });
71105
71106        for &field in [
71107            "alt",
71108            "profileId",
71109            "sortOrder",
71110            "sortField",
71111            "scope",
71112            "pageToken",
71113            "maxResults",
71114        ]
71115        .iter()
71116        {
71117            if self._additional_params.contains_key(field) {
71118                dlg.finished(false);
71119                return Err(common::Error::FieldClash(field));
71120            }
71121        }
71122
71123        let mut params = Params::with_capacity(8 + self._additional_params.len());
71124        params.push("profileId", self._profile_id.to_string());
71125        if let Some(value) = self._sort_order.as_ref() {
71126            params.push("sortOrder", value);
71127        }
71128        if let Some(value) = self._sort_field.as_ref() {
71129            params.push("sortField", value);
71130        }
71131        if let Some(value) = self._scope.as_ref() {
71132            params.push("scope", value);
71133        }
71134        if let Some(value) = self._page_token.as_ref() {
71135            params.push("pageToken", value);
71136        }
71137        if let Some(value) = self._max_results.as_ref() {
71138            params.push("maxResults", value.to_string());
71139        }
71140
71141        params.extend(self._additional_params.iter());
71142
71143        params.push("alt", "json");
71144        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports";
71145        if self._scopes.is_empty() {
71146            self._scopes.insert(Scope::Full.as_ref().to_string());
71147        }
71148
71149        #[allow(clippy::single_element_loop)]
71150        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
71151            url = params.uri_replacement(url, param_name, find_this, false);
71152        }
71153        {
71154            let to_remove = ["profileId"];
71155            params.remove_params(&to_remove);
71156        }
71157
71158        let url = params.parse_with_url(&url);
71159
71160        loop {
71161            let token = match self
71162                .hub
71163                .auth
71164                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
71165                .await
71166            {
71167                Ok(token) => token,
71168                Err(e) => match dlg.token(e) {
71169                    Ok(token) => token,
71170                    Err(e) => {
71171                        dlg.finished(false);
71172                        return Err(common::Error::MissingToken(e));
71173                    }
71174                },
71175            };
71176            let mut req_result = {
71177                let client = &self.hub.client;
71178                dlg.pre_request();
71179                let mut req_builder = hyper::Request::builder()
71180                    .method(hyper::Method::GET)
71181                    .uri(url.as_str())
71182                    .header(USER_AGENT, self.hub._user_agent.clone());
71183
71184                if let Some(token) = token.as_ref() {
71185                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
71186                }
71187
71188                let request = req_builder
71189                    .header(CONTENT_LENGTH, 0_u64)
71190                    .body(common::to_body::<String>(None));
71191
71192                client.request(request.unwrap()).await
71193            };
71194
71195            match req_result {
71196                Err(err) => {
71197                    if let common::Retry::After(d) = dlg.http_error(&err) {
71198                        sleep(d).await;
71199                        continue;
71200                    }
71201                    dlg.finished(false);
71202                    return Err(common::Error::HttpError(err));
71203                }
71204                Ok(res) => {
71205                    let (mut parts, body) = res.into_parts();
71206                    let mut body = common::Body::new(body);
71207                    if !parts.status.is_success() {
71208                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71209                        let error = serde_json::from_str(&common::to_string(&bytes));
71210                        let response = common::to_response(parts, bytes.into());
71211
71212                        if let common::Retry::After(d) =
71213                            dlg.http_failure(&response, error.as_ref().ok())
71214                        {
71215                            sleep(d).await;
71216                            continue;
71217                        }
71218
71219                        dlg.finished(false);
71220
71221                        return Err(match error {
71222                            Ok(value) => common::Error::BadRequest(value),
71223                            _ => common::Error::Failure(response),
71224                        });
71225                    }
71226                    let response = {
71227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71228                        let encoded = common::to_string(&bytes);
71229                        match serde_json::from_str(&encoded) {
71230                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
71231                            Err(error) => {
71232                                dlg.response_json_decode_error(&encoded, &error);
71233                                return Err(common::Error::JsonDecodeError(
71234                                    encoded.to_string(),
71235                                    error,
71236                                ));
71237                            }
71238                        }
71239                    };
71240
71241                    dlg.finished(true);
71242                    return Ok(response);
71243                }
71244            }
71245        }
71246    }
71247
71248    /// The DFA user profile ID.
71249    ///
71250    /// Sets the *profile id* path property to the given value.
71251    ///
71252    /// Even though the property as already been set when instantiating this call,
71253    /// we provide this method for API completeness.
71254    pub fn profile_id(mut self, new_value: i64) -> ReportListCall<'a, C> {
71255        self._profile_id = new_value;
71256        self
71257    }
71258    /// Order of sorted results.
71259    ///
71260    /// Sets the *sort order* query property to the given value.
71261    pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, C> {
71262        self._sort_order = Some(new_value.to_string());
71263        self
71264    }
71265    /// The field by which to sort the list.
71266    ///
71267    /// Sets the *sort field* query property to the given value.
71268    pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, C> {
71269        self._sort_field = Some(new_value.to_string());
71270        self
71271    }
71272    /// The scope that defines which results are returned.
71273    ///
71274    /// Sets the *scope* query property to the given value.
71275    pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, C> {
71276        self._scope = Some(new_value.to_string());
71277        self
71278    }
71279    /// The value of the nextToken from the previous result page.
71280    ///
71281    /// Sets the *page token* query property to the given value.
71282    pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, C> {
71283        self._page_token = Some(new_value.to_string());
71284        self
71285    }
71286    /// Maximum number of results to return.
71287    ///
71288    /// Sets the *max results* query property to the given value.
71289    pub fn max_results(mut self, new_value: i32) -> ReportListCall<'a, C> {
71290        self._max_results = Some(new_value);
71291        self
71292    }
71293    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
71294    /// while executing the actual API request.
71295    ///
71296    /// ````text
71297    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
71298    /// ````
71299    ///
71300    /// Sets the *delegate* property to the given value.
71301    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportListCall<'a, C> {
71302        self._delegate = Some(new_value);
71303        self
71304    }
71305
71306    /// Set any additional parameter of the query string used in the request.
71307    /// It should be used to set parameters which are not yet available through their own
71308    /// setters.
71309    ///
71310    /// Please note that this method must not be used to set any of the known parameters
71311    /// which have their own setter method. If done anyway, the request will fail.
71312    ///
71313    /// # Additional Parameters
71314    ///
71315    /// * *alt* (query-string) - Data format for the response.
71316    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
71317    /// * *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.
71318    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
71319    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
71320    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
71321    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
71322    pub fn param<T>(mut self, name: T, value: T) -> ReportListCall<'a, C>
71323    where
71324        T: AsRef<str>,
71325    {
71326        self._additional_params
71327            .insert(name.as_ref().to_string(), value.as_ref().to_string());
71328        self
71329    }
71330
71331    /// Identifies the authorization scope for the method you are building.
71332    ///
71333    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
71334    /// [`Scope::Full`].
71335    ///
71336    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
71337    /// tokens for more than one scope.
71338    ///
71339    /// Usually there is more than one suitable scope to authorize an operation, some of which may
71340    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
71341    /// sufficient, a read-write scope will do as well.
71342    pub fn add_scope<St>(mut self, scope: St) -> ReportListCall<'a, C>
71343    where
71344        St: AsRef<str>,
71345    {
71346        self._scopes.insert(String::from(scope.as_ref()));
71347        self
71348    }
71349    /// Identifies the authorization scope(s) for the method you are building.
71350    ///
71351    /// See [`Self::add_scope()`] for details.
71352    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportListCall<'a, C>
71353    where
71354        I: IntoIterator<Item = St>,
71355        St: AsRef<str>,
71356    {
71357        self._scopes
71358            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
71359        self
71360    }
71361
71362    /// Removes all scopes, and no default scope will be used either.
71363    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
71364    /// for details).
71365    pub fn clear_scopes(mut self) -> ReportListCall<'a, C> {
71366        self._scopes.clear();
71367        self
71368    }
71369}
71370
71371/// Updates a report. This method supports patch semantics.
71372///
71373/// A builder for the *patch* method supported by a *report* resource.
71374/// It is not used directly, but through a [`ReportMethods`] instance.
71375///
71376/// # Example
71377///
71378/// Instantiate a resource method builder
71379///
71380/// ```test_harness,no_run
71381/// # extern crate hyper;
71382/// # extern crate hyper_rustls;
71383/// # extern crate google_dfareporting3d2 as dfareporting3d2;
71384/// use dfareporting3d2::api::Report;
71385/// # async fn dox() {
71386/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
71387///
71388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
71389/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
71390/// #     secret,
71391/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
71392/// # ).build().await.unwrap();
71393///
71394/// # let client = hyper_util::client::legacy::Client::builder(
71395/// #     hyper_util::rt::TokioExecutor::new()
71396/// # )
71397/// # .build(
71398/// #     hyper_rustls::HttpsConnectorBuilder::new()
71399/// #         .with_native_roots()
71400/// #         .unwrap()
71401/// #         .https_or_http()
71402/// #         .enable_http1()
71403/// #         .build()
71404/// # );
71405/// # let mut hub = Dfareporting::new(client, auth);
71406/// // As the method needs a request, you would usually fill it with the desired information
71407/// // into the respective structure. Some of the parts shown here might not be applicable !
71408/// // Values shown here are possibly random and not representative !
71409/// let mut req = Report::default();
71410///
71411/// // You can configure optional parameters by calling the respective setters at will, and
71412/// // execute the final call using `doit()`.
71413/// // Values shown here are possibly random and not representative !
71414/// let result = hub.reports().patch(req, -67, -10)
71415///              .doit().await;
71416/// # }
71417/// ```
71418pub struct ReportPatchCall<'a, C>
71419where
71420    C: 'a,
71421{
71422    hub: &'a Dfareporting<C>,
71423    _request: Report,
71424    _profile_id: i64,
71425    _report_id: i64,
71426    _delegate: Option<&'a mut dyn common::Delegate>,
71427    _additional_params: HashMap<String, String>,
71428    _scopes: BTreeSet<String>,
71429}
71430
71431impl<'a, C> common::CallBuilder for ReportPatchCall<'a, C> {}
71432
71433impl<'a, C> ReportPatchCall<'a, C>
71434where
71435    C: common::Connector,
71436{
71437    /// Perform the operation you have build so far.
71438    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
71439        use std::borrow::Cow;
71440        use std::io::{Read, Seek};
71441
71442        use common::{url::Params, ToParts};
71443        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
71444
71445        let mut dd = common::DefaultDelegate;
71446        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
71447        dlg.begin(common::MethodInfo {
71448            id: "dfareporting.reports.patch",
71449            http_method: hyper::Method::PATCH,
71450        });
71451
71452        for &field in ["alt", "profileId", "reportId"].iter() {
71453            if self._additional_params.contains_key(field) {
71454                dlg.finished(false);
71455                return Err(common::Error::FieldClash(field));
71456            }
71457        }
71458
71459        let mut params = Params::with_capacity(5 + self._additional_params.len());
71460        params.push("profileId", self._profile_id.to_string());
71461        params.push("reportId", self._report_id.to_string());
71462
71463        params.extend(self._additional_params.iter());
71464
71465        params.push("alt", "json");
71466        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}";
71467        if self._scopes.is_empty() {
71468            self._scopes.insert(Scope::Full.as_ref().to_string());
71469        }
71470
71471        #[allow(clippy::single_element_loop)]
71472        for &(find_this, param_name) in
71473            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
71474        {
71475            url = params.uri_replacement(url, param_name, find_this, false);
71476        }
71477        {
71478            let to_remove = ["reportId", "profileId"];
71479            params.remove_params(&to_remove);
71480        }
71481
71482        let url = params.parse_with_url(&url);
71483
71484        let mut json_mime_type = mime::APPLICATION_JSON;
71485        let mut request_value_reader = {
71486            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
71487            common::remove_json_null_values(&mut value);
71488            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
71489            serde_json::to_writer(&mut dst, &value).unwrap();
71490            dst
71491        };
71492        let request_size = request_value_reader
71493            .seek(std::io::SeekFrom::End(0))
71494            .unwrap();
71495        request_value_reader
71496            .seek(std::io::SeekFrom::Start(0))
71497            .unwrap();
71498
71499        loop {
71500            let token = match self
71501                .hub
71502                .auth
71503                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
71504                .await
71505            {
71506                Ok(token) => token,
71507                Err(e) => match dlg.token(e) {
71508                    Ok(token) => token,
71509                    Err(e) => {
71510                        dlg.finished(false);
71511                        return Err(common::Error::MissingToken(e));
71512                    }
71513                },
71514            };
71515            request_value_reader
71516                .seek(std::io::SeekFrom::Start(0))
71517                .unwrap();
71518            let mut req_result = {
71519                let client = &self.hub.client;
71520                dlg.pre_request();
71521                let mut req_builder = hyper::Request::builder()
71522                    .method(hyper::Method::PATCH)
71523                    .uri(url.as_str())
71524                    .header(USER_AGENT, self.hub._user_agent.clone());
71525
71526                if let Some(token) = token.as_ref() {
71527                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
71528                }
71529
71530                let request = req_builder
71531                    .header(CONTENT_TYPE, json_mime_type.to_string())
71532                    .header(CONTENT_LENGTH, request_size as u64)
71533                    .body(common::to_body(
71534                        request_value_reader.get_ref().clone().into(),
71535                    ));
71536
71537                client.request(request.unwrap()).await
71538            };
71539
71540            match req_result {
71541                Err(err) => {
71542                    if let common::Retry::After(d) = dlg.http_error(&err) {
71543                        sleep(d).await;
71544                        continue;
71545                    }
71546                    dlg.finished(false);
71547                    return Err(common::Error::HttpError(err));
71548                }
71549                Ok(res) => {
71550                    let (mut parts, body) = res.into_parts();
71551                    let mut body = common::Body::new(body);
71552                    if !parts.status.is_success() {
71553                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71554                        let error = serde_json::from_str(&common::to_string(&bytes));
71555                        let response = common::to_response(parts, bytes.into());
71556
71557                        if let common::Retry::After(d) =
71558                            dlg.http_failure(&response, error.as_ref().ok())
71559                        {
71560                            sleep(d).await;
71561                            continue;
71562                        }
71563
71564                        dlg.finished(false);
71565
71566                        return Err(match error {
71567                            Ok(value) => common::Error::BadRequest(value),
71568                            _ => common::Error::Failure(response),
71569                        });
71570                    }
71571                    let response = {
71572                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71573                        let encoded = common::to_string(&bytes);
71574                        match serde_json::from_str(&encoded) {
71575                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
71576                            Err(error) => {
71577                                dlg.response_json_decode_error(&encoded, &error);
71578                                return Err(common::Error::JsonDecodeError(
71579                                    encoded.to_string(),
71580                                    error,
71581                                ));
71582                            }
71583                        }
71584                    };
71585
71586                    dlg.finished(true);
71587                    return Ok(response);
71588                }
71589            }
71590        }
71591    }
71592
71593    ///
71594    /// Sets the *request* property to the given value.
71595    ///
71596    /// Even though the property as already been set when instantiating this call,
71597    /// we provide this method for API completeness.
71598    pub fn request(mut self, new_value: Report) -> ReportPatchCall<'a, C> {
71599        self._request = new_value;
71600        self
71601    }
71602    /// The DFA user profile ID.
71603    ///
71604    /// Sets the *profile id* path property to the given value.
71605    ///
71606    /// Even though the property as already been set when instantiating this call,
71607    /// we provide this method for API completeness.
71608    pub fn profile_id(mut self, new_value: i64) -> ReportPatchCall<'a, C> {
71609        self._profile_id = new_value;
71610        self
71611    }
71612    /// The ID of the report.
71613    ///
71614    /// Sets the *report id* path property to the given value.
71615    ///
71616    /// Even though the property as already been set when instantiating this call,
71617    /// we provide this method for API completeness.
71618    pub fn report_id(mut self, new_value: i64) -> ReportPatchCall<'a, C> {
71619        self._report_id = new_value;
71620        self
71621    }
71622    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
71623    /// while executing the actual API request.
71624    ///
71625    /// ````text
71626    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
71627    /// ````
71628    ///
71629    /// Sets the *delegate* property to the given value.
71630    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportPatchCall<'a, C> {
71631        self._delegate = Some(new_value);
71632        self
71633    }
71634
71635    /// Set any additional parameter of the query string used in the request.
71636    /// It should be used to set parameters which are not yet available through their own
71637    /// setters.
71638    ///
71639    /// Please note that this method must not be used to set any of the known parameters
71640    /// which have their own setter method. If done anyway, the request will fail.
71641    ///
71642    /// # Additional Parameters
71643    ///
71644    /// * *alt* (query-string) - Data format for the response.
71645    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
71646    /// * *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.
71647    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
71648    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
71649    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
71650    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
71651    pub fn param<T>(mut self, name: T, value: T) -> ReportPatchCall<'a, C>
71652    where
71653        T: AsRef<str>,
71654    {
71655        self._additional_params
71656            .insert(name.as_ref().to_string(), value.as_ref().to_string());
71657        self
71658    }
71659
71660    /// Identifies the authorization scope for the method you are building.
71661    ///
71662    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
71663    /// [`Scope::Full`].
71664    ///
71665    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
71666    /// tokens for more than one scope.
71667    ///
71668    /// Usually there is more than one suitable scope to authorize an operation, some of which may
71669    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
71670    /// sufficient, a read-write scope will do as well.
71671    pub fn add_scope<St>(mut self, scope: St) -> ReportPatchCall<'a, C>
71672    where
71673        St: AsRef<str>,
71674    {
71675        self._scopes.insert(String::from(scope.as_ref()));
71676        self
71677    }
71678    /// Identifies the authorization scope(s) for the method you are building.
71679    ///
71680    /// See [`Self::add_scope()`] for details.
71681    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportPatchCall<'a, C>
71682    where
71683        I: IntoIterator<Item = St>,
71684        St: AsRef<str>,
71685    {
71686        self._scopes
71687            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
71688        self
71689    }
71690
71691    /// Removes all scopes, and no default scope will be used either.
71692    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
71693    /// for details).
71694    pub fn clear_scopes(mut self) -> ReportPatchCall<'a, C> {
71695        self._scopes.clear();
71696        self
71697    }
71698}
71699
71700/// Runs a report.
71701///
71702/// A builder for the *run* method supported by a *report* resource.
71703/// It is not used directly, but through a [`ReportMethods`] instance.
71704///
71705/// # Example
71706///
71707/// Instantiate a resource method builder
71708///
71709/// ```test_harness,no_run
71710/// # extern crate hyper;
71711/// # extern crate hyper_rustls;
71712/// # extern crate google_dfareporting3d2 as dfareporting3d2;
71713/// # async fn dox() {
71714/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
71715///
71716/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
71717/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
71718/// #     secret,
71719/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
71720/// # ).build().await.unwrap();
71721///
71722/// # let client = hyper_util::client::legacy::Client::builder(
71723/// #     hyper_util::rt::TokioExecutor::new()
71724/// # )
71725/// # .build(
71726/// #     hyper_rustls::HttpsConnectorBuilder::new()
71727/// #         .with_native_roots()
71728/// #         .unwrap()
71729/// #         .https_or_http()
71730/// #         .enable_http1()
71731/// #         .build()
71732/// # );
71733/// # let mut hub = Dfareporting::new(client, auth);
71734/// // You can configure optional parameters by calling the respective setters at will, and
71735/// // execute the final call using `doit()`.
71736/// // Values shown here are possibly random and not representative !
71737/// let result = hub.reports().run(-34, -69)
71738///              .synchronous(false)
71739///              .doit().await;
71740/// # }
71741/// ```
71742pub struct ReportRunCall<'a, C>
71743where
71744    C: 'a,
71745{
71746    hub: &'a Dfareporting<C>,
71747    _profile_id: i64,
71748    _report_id: i64,
71749    _synchronous: Option<bool>,
71750    _delegate: Option<&'a mut dyn common::Delegate>,
71751    _additional_params: HashMap<String, String>,
71752    _scopes: BTreeSet<String>,
71753}
71754
71755impl<'a, C> common::CallBuilder for ReportRunCall<'a, C> {}
71756
71757impl<'a, C> ReportRunCall<'a, C>
71758where
71759    C: common::Connector,
71760{
71761    /// Perform the operation you have build so far.
71762    pub async fn doit(mut self) -> common::Result<(common::Response, File)> {
71763        use std::borrow::Cow;
71764        use std::io::{Read, Seek};
71765
71766        use common::{url::Params, ToParts};
71767        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
71768
71769        let mut dd = common::DefaultDelegate;
71770        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
71771        dlg.begin(common::MethodInfo {
71772            id: "dfareporting.reports.run",
71773            http_method: hyper::Method::POST,
71774        });
71775
71776        for &field in ["alt", "profileId", "reportId", "synchronous"].iter() {
71777            if self._additional_params.contains_key(field) {
71778                dlg.finished(false);
71779                return Err(common::Error::FieldClash(field));
71780            }
71781        }
71782
71783        let mut params = Params::with_capacity(5 + self._additional_params.len());
71784        params.push("profileId", self._profile_id.to_string());
71785        params.push("reportId", self._report_id.to_string());
71786        if let Some(value) = self._synchronous.as_ref() {
71787            params.push("synchronous", value.to_string());
71788        }
71789
71790        params.extend(self._additional_params.iter());
71791
71792        params.push("alt", "json");
71793        let mut url =
71794            self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}/run";
71795        if self._scopes.is_empty() {
71796            self._scopes.insert(Scope::Full.as_ref().to_string());
71797        }
71798
71799        #[allow(clippy::single_element_loop)]
71800        for &(find_this, param_name) in
71801            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
71802        {
71803            url = params.uri_replacement(url, param_name, find_this, false);
71804        }
71805        {
71806            let to_remove = ["reportId", "profileId"];
71807            params.remove_params(&to_remove);
71808        }
71809
71810        let url = params.parse_with_url(&url);
71811
71812        loop {
71813            let token = match self
71814                .hub
71815                .auth
71816                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
71817                .await
71818            {
71819                Ok(token) => token,
71820                Err(e) => match dlg.token(e) {
71821                    Ok(token) => token,
71822                    Err(e) => {
71823                        dlg.finished(false);
71824                        return Err(common::Error::MissingToken(e));
71825                    }
71826                },
71827            };
71828            let mut req_result = {
71829                let client = &self.hub.client;
71830                dlg.pre_request();
71831                let mut req_builder = hyper::Request::builder()
71832                    .method(hyper::Method::POST)
71833                    .uri(url.as_str())
71834                    .header(USER_AGENT, self.hub._user_agent.clone());
71835
71836                if let Some(token) = token.as_ref() {
71837                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
71838                }
71839
71840                let request = req_builder
71841                    .header(CONTENT_LENGTH, 0_u64)
71842                    .body(common::to_body::<String>(None));
71843
71844                client.request(request.unwrap()).await
71845            };
71846
71847            match req_result {
71848                Err(err) => {
71849                    if let common::Retry::After(d) = dlg.http_error(&err) {
71850                        sleep(d).await;
71851                        continue;
71852                    }
71853                    dlg.finished(false);
71854                    return Err(common::Error::HttpError(err));
71855                }
71856                Ok(res) => {
71857                    let (mut parts, body) = res.into_parts();
71858                    let mut body = common::Body::new(body);
71859                    if !parts.status.is_success() {
71860                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71861                        let error = serde_json::from_str(&common::to_string(&bytes));
71862                        let response = common::to_response(parts, bytes.into());
71863
71864                        if let common::Retry::After(d) =
71865                            dlg.http_failure(&response, error.as_ref().ok())
71866                        {
71867                            sleep(d).await;
71868                            continue;
71869                        }
71870
71871                        dlg.finished(false);
71872
71873                        return Err(match error {
71874                            Ok(value) => common::Error::BadRequest(value),
71875                            _ => common::Error::Failure(response),
71876                        });
71877                    }
71878                    let response = {
71879                        let bytes = common::to_bytes(body).await.unwrap_or_default();
71880                        let encoded = common::to_string(&bytes);
71881                        match serde_json::from_str(&encoded) {
71882                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
71883                            Err(error) => {
71884                                dlg.response_json_decode_error(&encoded, &error);
71885                                return Err(common::Error::JsonDecodeError(
71886                                    encoded.to_string(),
71887                                    error,
71888                                ));
71889                            }
71890                        }
71891                    };
71892
71893                    dlg.finished(true);
71894                    return Ok(response);
71895                }
71896            }
71897        }
71898    }
71899
71900    /// The DFA profile ID.
71901    ///
71902    /// Sets the *profile id* path property to the given value.
71903    ///
71904    /// Even though the property as already been set when instantiating this call,
71905    /// we provide this method for API completeness.
71906    pub fn profile_id(mut self, new_value: i64) -> ReportRunCall<'a, C> {
71907        self._profile_id = new_value;
71908        self
71909    }
71910    /// The ID of the report.
71911    ///
71912    /// Sets the *report id* path property to the given value.
71913    ///
71914    /// Even though the property as already been set when instantiating this call,
71915    /// we provide this method for API completeness.
71916    pub fn report_id(mut self, new_value: i64) -> ReportRunCall<'a, C> {
71917        self._report_id = new_value;
71918        self
71919    }
71920    /// If set and true, tries to run the report synchronously.
71921    ///
71922    /// Sets the *synchronous* query property to the given value.
71923    pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, C> {
71924        self._synchronous = Some(new_value);
71925        self
71926    }
71927    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
71928    /// while executing the actual API request.
71929    ///
71930    /// ````text
71931    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
71932    /// ````
71933    ///
71934    /// Sets the *delegate* property to the given value.
71935    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportRunCall<'a, C> {
71936        self._delegate = Some(new_value);
71937        self
71938    }
71939
71940    /// Set any additional parameter of the query string used in the request.
71941    /// It should be used to set parameters which are not yet available through their own
71942    /// setters.
71943    ///
71944    /// Please note that this method must not be used to set any of the known parameters
71945    /// which have their own setter method. If done anyway, the request will fail.
71946    ///
71947    /// # Additional Parameters
71948    ///
71949    /// * *alt* (query-string) - Data format for the response.
71950    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
71951    /// * *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.
71952    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
71953    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
71954    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
71955    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
71956    pub fn param<T>(mut self, name: T, value: T) -> ReportRunCall<'a, C>
71957    where
71958        T: AsRef<str>,
71959    {
71960        self._additional_params
71961            .insert(name.as_ref().to_string(), value.as_ref().to_string());
71962        self
71963    }
71964
71965    /// Identifies the authorization scope for the method you are building.
71966    ///
71967    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
71968    /// [`Scope::Full`].
71969    ///
71970    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
71971    /// tokens for more than one scope.
71972    ///
71973    /// Usually there is more than one suitable scope to authorize an operation, some of which may
71974    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
71975    /// sufficient, a read-write scope will do as well.
71976    pub fn add_scope<St>(mut self, scope: St) -> ReportRunCall<'a, C>
71977    where
71978        St: AsRef<str>,
71979    {
71980        self._scopes.insert(String::from(scope.as_ref()));
71981        self
71982    }
71983    /// Identifies the authorization scope(s) for the method you are building.
71984    ///
71985    /// See [`Self::add_scope()`] for details.
71986    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportRunCall<'a, C>
71987    where
71988        I: IntoIterator<Item = St>,
71989        St: AsRef<str>,
71990    {
71991        self._scopes
71992            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
71993        self
71994    }
71995
71996    /// Removes all scopes, and no default scope will be used either.
71997    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
71998    /// for details).
71999    pub fn clear_scopes(mut self) -> ReportRunCall<'a, C> {
72000        self._scopes.clear();
72001        self
72002    }
72003}
72004
72005/// Updates a report.
72006///
72007/// A builder for the *update* method supported by a *report* resource.
72008/// It is not used directly, but through a [`ReportMethods`] instance.
72009///
72010/// # Example
72011///
72012/// Instantiate a resource method builder
72013///
72014/// ```test_harness,no_run
72015/// # extern crate hyper;
72016/// # extern crate hyper_rustls;
72017/// # extern crate google_dfareporting3d2 as dfareporting3d2;
72018/// use dfareporting3d2::api::Report;
72019/// # async fn dox() {
72020/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72021///
72022/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
72023/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
72024/// #     secret,
72025/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72026/// # ).build().await.unwrap();
72027///
72028/// # let client = hyper_util::client::legacy::Client::builder(
72029/// #     hyper_util::rt::TokioExecutor::new()
72030/// # )
72031/// # .build(
72032/// #     hyper_rustls::HttpsConnectorBuilder::new()
72033/// #         .with_native_roots()
72034/// #         .unwrap()
72035/// #         .https_or_http()
72036/// #         .enable_http1()
72037/// #         .build()
72038/// # );
72039/// # let mut hub = Dfareporting::new(client, auth);
72040/// // As the method needs a request, you would usually fill it with the desired information
72041/// // into the respective structure. Some of the parts shown here might not be applicable !
72042/// // Values shown here are possibly random and not representative !
72043/// let mut req = Report::default();
72044///
72045/// // You can configure optional parameters by calling the respective setters at will, and
72046/// // execute the final call using `doit()`.
72047/// // Values shown here are possibly random and not representative !
72048/// let result = hub.reports().update(req, -89, -22)
72049///              .doit().await;
72050/// # }
72051/// ```
72052pub struct ReportUpdateCall<'a, C>
72053where
72054    C: 'a,
72055{
72056    hub: &'a Dfareporting<C>,
72057    _request: Report,
72058    _profile_id: i64,
72059    _report_id: i64,
72060    _delegate: Option<&'a mut dyn common::Delegate>,
72061    _additional_params: HashMap<String, String>,
72062    _scopes: BTreeSet<String>,
72063}
72064
72065impl<'a, C> common::CallBuilder for ReportUpdateCall<'a, C> {}
72066
72067impl<'a, C> ReportUpdateCall<'a, C>
72068where
72069    C: common::Connector,
72070{
72071    /// Perform the operation you have build so far.
72072    pub async fn doit(mut self) -> common::Result<(common::Response, Report)> {
72073        use std::borrow::Cow;
72074        use std::io::{Read, Seek};
72075
72076        use common::{url::Params, ToParts};
72077        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
72078
72079        let mut dd = common::DefaultDelegate;
72080        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
72081        dlg.begin(common::MethodInfo {
72082            id: "dfareporting.reports.update",
72083            http_method: hyper::Method::PUT,
72084        });
72085
72086        for &field in ["alt", "profileId", "reportId"].iter() {
72087            if self._additional_params.contains_key(field) {
72088                dlg.finished(false);
72089                return Err(common::Error::FieldClash(field));
72090            }
72091        }
72092
72093        let mut params = Params::with_capacity(5 + self._additional_params.len());
72094        params.push("profileId", self._profile_id.to_string());
72095        params.push("reportId", self._report_id.to_string());
72096
72097        params.extend(self._additional_params.iter());
72098
72099        params.push("alt", "json");
72100        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}";
72101        if self._scopes.is_empty() {
72102            self._scopes.insert(Scope::Full.as_ref().to_string());
72103        }
72104
72105        #[allow(clippy::single_element_loop)]
72106        for &(find_this, param_name) in
72107            [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter()
72108        {
72109            url = params.uri_replacement(url, param_name, find_this, false);
72110        }
72111        {
72112            let to_remove = ["reportId", "profileId"];
72113            params.remove_params(&to_remove);
72114        }
72115
72116        let url = params.parse_with_url(&url);
72117
72118        let mut json_mime_type = mime::APPLICATION_JSON;
72119        let mut request_value_reader = {
72120            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
72121            common::remove_json_null_values(&mut value);
72122            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
72123            serde_json::to_writer(&mut dst, &value).unwrap();
72124            dst
72125        };
72126        let request_size = request_value_reader
72127            .seek(std::io::SeekFrom::End(0))
72128            .unwrap();
72129        request_value_reader
72130            .seek(std::io::SeekFrom::Start(0))
72131            .unwrap();
72132
72133        loop {
72134            let token = match self
72135                .hub
72136                .auth
72137                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
72138                .await
72139            {
72140                Ok(token) => token,
72141                Err(e) => match dlg.token(e) {
72142                    Ok(token) => token,
72143                    Err(e) => {
72144                        dlg.finished(false);
72145                        return Err(common::Error::MissingToken(e));
72146                    }
72147                },
72148            };
72149            request_value_reader
72150                .seek(std::io::SeekFrom::Start(0))
72151                .unwrap();
72152            let mut req_result = {
72153                let client = &self.hub.client;
72154                dlg.pre_request();
72155                let mut req_builder = hyper::Request::builder()
72156                    .method(hyper::Method::PUT)
72157                    .uri(url.as_str())
72158                    .header(USER_AGENT, self.hub._user_agent.clone());
72159
72160                if let Some(token) = token.as_ref() {
72161                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
72162                }
72163
72164                let request = req_builder
72165                    .header(CONTENT_TYPE, json_mime_type.to_string())
72166                    .header(CONTENT_LENGTH, request_size as u64)
72167                    .body(common::to_body(
72168                        request_value_reader.get_ref().clone().into(),
72169                    ));
72170
72171                client.request(request.unwrap()).await
72172            };
72173
72174            match req_result {
72175                Err(err) => {
72176                    if let common::Retry::After(d) = dlg.http_error(&err) {
72177                        sleep(d).await;
72178                        continue;
72179                    }
72180                    dlg.finished(false);
72181                    return Err(common::Error::HttpError(err));
72182                }
72183                Ok(res) => {
72184                    let (mut parts, body) = res.into_parts();
72185                    let mut body = common::Body::new(body);
72186                    if !parts.status.is_success() {
72187                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72188                        let error = serde_json::from_str(&common::to_string(&bytes));
72189                        let response = common::to_response(parts, bytes.into());
72190
72191                        if let common::Retry::After(d) =
72192                            dlg.http_failure(&response, error.as_ref().ok())
72193                        {
72194                            sleep(d).await;
72195                            continue;
72196                        }
72197
72198                        dlg.finished(false);
72199
72200                        return Err(match error {
72201                            Ok(value) => common::Error::BadRequest(value),
72202                            _ => common::Error::Failure(response),
72203                        });
72204                    }
72205                    let response = {
72206                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72207                        let encoded = common::to_string(&bytes);
72208                        match serde_json::from_str(&encoded) {
72209                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
72210                            Err(error) => {
72211                                dlg.response_json_decode_error(&encoded, &error);
72212                                return Err(common::Error::JsonDecodeError(
72213                                    encoded.to_string(),
72214                                    error,
72215                                ));
72216                            }
72217                        }
72218                    };
72219
72220                    dlg.finished(true);
72221                    return Ok(response);
72222                }
72223            }
72224        }
72225    }
72226
72227    ///
72228    /// Sets the *request* property to the given value.
72229    ///
72230    /// Even though the property as already been set when instantiating this call,
72231    /// we provide this method for API completeness.
72232    pub fn request(mut self, new_value: Report) -> ReportUpdateCall<'a, C> {
72233        self._request = new_value;
72234        self
72235    }
72236    /// The DFA user profile ID.
72237    ///
72238    /// Sets the *profile id* path property to the given value.
72239    ///
72240    /// Even though the property as already been set when instantiating this call,
72241    /// we provide this method for API completeness.
72242    pub fn profile_id(mut self, new_value: i64) -> ReportUpdateCall<'a, C> {
72243        self._profile_id = new_value;
72244        self
72245    }
72246    /// The ID of the report.
72247    ///
72248    /// Sets the *report id* path property to the given value.
72249    ///
72250    /// Even though the property as already been set when instantiating this call,
72251    /// we provide this method for API completeness.
72252    pub fn report_id(mut self, new_value: i64) -> ReportUpdateCall<'a, C> {
72253        self._report_id = new_value;
72254        self
72255    }
72256    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
72257    /// while executing the actual API request.
72258    ///
72259    /// ````text
72260    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
72261    /// ````
72262    ///
72263    /// Sets the *delegate* property to the given value.
72264    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ReportUpdateCall<'a, C> {
72265        self._delegate = Some(new_value);
72266        self
72267    }
72268
72269    /// Set any additional parameter of the query string used in the request.
72270    /// It should be used to set parameters which are not yet available through their own
72271    /// setters.
72272    ///
72273    /// Please note that this method must not be used to set any of the known parameters
72274    /// which have their own setter method. If done anyway, the request will fail.
72275    ///
72276    /// # Additional Parameters
72277    ///
72278    /// * *alt* (query-string) - Data format for the response.
72279    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
72280    /// * *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.
72281    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
72282    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
72283    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
72284    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
72285    pub fn param<T>(mut self, name: T, value: T) -> ReportUpdateCall<'a, C>
72286    where
72287        T: AsRef<str>,
72288    {
72289        self._additional_params
72290            .insert(name.as_ref().to_string(), value.as_ref().to_string());
72291        self
72292    }
72293
72294    /// Identifies the authorization scope for the method you are building.
72295    ///
72296    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
72297    /// [`Scope::Full`].
72298    ///
72299    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
72300    /// tokens for more than one scope.
72301    ///
72302    /// Usually there is more than one suitable scope to authorize an operation, some of which may
72303    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
72304    /// sufficient, a read-write scope will do as well.
72305    pub fn add_scope<St>(mut self, scope: St) -> ReportUpdateCall<'a, C>
72306    where
72307        St: AsRef<str>,
72308    {
72309        self._scopes.insert(String::from(scope.as_ref()));
72310        self
72311    }
72312    /// Identifies the authorization scope(s) for the method you are building.
72313    ///
72314    /// See [`Self::add_scope()`] for details.
72315    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportUpdateCall<'a, C>
72316    where
72317        I: IntoIterator<Item = St>,
72318        St: AsRef<str>,
72319    {
72320        self._scopes
72321            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
72322        self
72323    }
72324
72325    /// Removes all scopes, and no default scope will be used either.
72326    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
72327    /// for details).
72328    pub fn clear_scopes(mut self) -> ReportUpdateCall<'a, C> {
72329        self._scopes.clear();
72330        self
72331    }
72332}
72333
72334/// Gets one site by ID.
72335///
72336/// A builder for the *get* method supported by a *site* resource.
72337/// It is not used directly, but through a [`SiteMethods`] instance.
72338///
72339/// # Example
72340///
72341/// Instantiate a resource method builder
72342///
72343/// ```test_harness,no_run
72344/// # extern crate hyper;
72345/// # extern crate hyper_rustls;
72346/// # extern crate google_dfareporting3d2 as dfareporting3d2;
72347/// # async fn dox() {
72348/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72349///
72350/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
72351/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
72352/// #     secret,
72353/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72354/// # ).build().await.unwrap();
72355///
72356/// # let client = hyper_util::client::legacy::Client::builder(
72357/// #     hyper_util::rt::TokioExecutor::new()
72358/// # )
72359/// # .build(
72360/// #     hyper_rustls::HttpsConnectorBuilder::new()
72361/// #         .with_native_roots()
72362/// #         .unwrap()
72363/// #         .https_or_http()
72364/// #         .enable_http1()
72365/// #         .build()
72366/// # );
72367/// # let mut hub = Dfareporting::new(client, auth);
72368/// // You can configure optional parameters by calling the respective setters at will, and
72369/// // execute the final call using `doit()`.
72370/// // Values shown here are possibly random and not representative !
72371/// let result = hub.sites().get(-78, -85)
72372///              .doit().await;
72373/// # }
72374/// ```
72375pub struct SiteGetCall<'a, C>
72376where
72377    C: 'a,
72378{
72379    hub: &'a Dfareporting<C>,
72380    _profile_id: i64,
72381    _id: i64,
72382    _delegate: Option<&'a mut dyn common::Delegate>,
72383    _additional_params: HashMap<String, String>,
72384    _scopes: BTreeSet<String>,
72385}
72386
72387impl<'a, C> common::CallBuilder for SiteGetCall<'a, C> {}
72388
72389impl<'a, C> SiteGetCall<'a, C>
72390where
72391    C: common::Connector,
72392{
72393    /// Perform the operation you have build so far.
72394    pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
72395        use std::borrow::Cow;
72396        use std::io::{Read, Seek};
72397
72398        use common::{url::Params, ToParts};
72399        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
72400
72401        let mut dd = common::DefaultDelegate;
72402        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
72403        dlg.begin(common::MethodInfo {
72404            id: "dfareporting.sites.get",
72405            http_method: hyper::Method::GET,
72406        });
72407
72408        for &field in ["alt", "profileId", "id"].iter() {
72409            if self._additional_params.contains_key(field) {
72410                dlg.finished(false);
72411                return Err(common::Error::FieldClash(field));
72412            }
72413        }
72414
72415        let mut params = Params::with_capacity(4 + self._additional_params.len());
72416        params.push("profileId", self._profile_id.to_string());
72417        params.push("id", self._id.to_string());
72418
72419        params.extend(self._additional_params.iter());
72420
72421        params.push("alt", "json");
72422        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites/{id}";
72423        if self._scopes.is_empty() {
72424            self._scopes
72425                .insert(Scope::Dfatrafficking.as_ref().to_string());
72426        }
72427
72428        #[allow(clippy::single_element_loop)]
72429        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
72430            url = params.uri_replacement(url, param_name, find_this, false);
72431        }
72432        {
72433            let to_remove = ["id", "profileId"];
72434            params.remove_params(&to_remove);
72435        }
72436
72437        let url = params.parse_with_url(&url);
72438
72439        loop {
72440            let token = match self
72441                .hub
72442                .auth
72443                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
72444                .await
72445            {
72446                Ok(token) => token,
72447                Err(e) => match dlg.token(e) {
72448                    Ok(token) => token,
72449                    Err(e) => {
72450                        dlg.finished(false);
72451                        return Err(common::Error::MissingToken(e));
72452                    }
72453                },
72454            };
72455            let mut req_result = {
72456                let client = &self.hub.client;
72457                dlg.pre_request();
72458                let mut req_builder = hyper::Request::builder()
72459                    .method(hyper::Method::GET)
72460                    .uri(url.as_str())
72461                    .header(USER_AGENT, self.hub._user_agent.clone());
72462
72463                if let Some(token) = token.as_ref() {
72464                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
72465                }
72466
72467                let request = req_builder
72468                    .header(CONTENT_LENGTH, 0_u64)
72469                    .body(common::to_body::<String>(None));
72470
72471                client.request(request.unwrap()).await
72472            };
72473
72474            match req_result {
72475                Err(err) => {
72476                    if let common::Retry::After(d) = dlg.http_error(&err) {
72477                        sleep(d).await;
72478                        continue;
72479                    }
72480                    dlg.finished(false);
72481                    return Err(common::Error::HttpError(err));
72482                }
72483                Ok(res) => {
72484                    let (mut parts, body) = res.into_parts();
72485                    let mut body = common::Body::new(body);
72486                    if !parts.status.is_success() {
72487                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72488                        let error = serde_json::from_str(&common::to_string(&bytes));
72489                        let response = common::to_response(parts, bytes.into());
72490
72491                        if let common::Retry::After(d) =
72492                            dlg.http_failure(&response, error.as_ref().ok())
72493                        {
72494                            sleep(d).await;
72495                            continue;
72496                        }
72497
72498                        dlg.finished(false);
72499
72500                        return Err(match error {
72501                            Ok(value) => common::Error::BadRequest(value),
72502                            _ => common::Error::Failure(response),
72503                        });
72504                    }
72505                    let response = {
72506                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72507                        let encoded = common::to_string(&bytes);
72508                        match serde_json::from_str(&encoded) {
72509                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
72510                            Err(error) => {
72511                                dlg.response_json_decode_error(&encoded, &error);
72512                                return Err(common::Error::JsonDecodeError(
72513                                    encoded.to_string(),
72514                                    error,
72515                                ));
72516                            }
72517                        }
72518                    };
72519
72520                    dlg.finished(true);
72521                    return Ok(response);
72522                }
72523            }
72524        }
72525    }
72526
72527    /// User profile ID associated with this request.
72528    ///
72529    /// Sets the *profile id* path property to the given value.
72530    ///
72531    /// Even though the property as already been set when instantiating this call,
72532    /// we provide this method for API completeness.
72533    pub fn profile_id(mut self, new_value: i64) -> SiteGetCall<'a, C> {
72534        self._profile_id = new_value;
72535        self
72536    }
72537    /// Site ID.
72538    ///
72539    /// Sets the *id* path property to the given value.
72540    ///
72541    /// Even though the property as already been set when instantiating this call,
72542    /// we provide this method for API completeness.
72543    pub fn id(mut self, new_value: i64) -> SiteGetCall<'a, C> {
72544        self._id = new_value;
72545        self
72546    }
72547    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
72548    /// while executing the actual API request.
72549    ///
72550    /// ````text
72551    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
72552    /// ````
72553    ///
72554    /// Sets the *delegate* property to the given value.
72555    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteGetCall<'a, C> {
72556        self._delegate = Some(new_value);
72557        self
72558    }
72559
72560    /// Set any additional parameter of the query string used in the request.
72561    /// It should be used to set parameters which are not yet available through their own
72562    /// setters.
72563    ///
72564    /// Please note that this method must not be used to set any of the known parameters
72565    /// which have their own setter method. If done anyway, the request will fail.
72566    ///
72567    /// # Additional Parameters
72568    ///
72569    /// * *alt* (query-string) - Data format for the response.
72570    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
72571    /// * *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.
72572    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
72573    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
72574    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
72575    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
72576    pub fn param<T>(mut self, name: T, value: T) -> SiteGetCall<'a, C>
72577    where
72578        T: AsRef<str>,
72579    {
72580        self._additional_params
72581            .insert(name.as_ref().to_string(), value.as_ref().to_string());
72582        self
72583    }
72584
72585    /// Identifies the authorization scope for the method you are building.
72586    ///
72587    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
72588    /// [`Scope::Dfatrafficking`].
72589    ///
72590    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
72591    /// tokens for more than one scope.
72592    ///
72593    /// Usually there is more than one suitable scope to authorize an operation, some of which may
72594    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
72595    /// sufficient, a read-write scope will do as well.
72596    pub fn add_scope<St>(mut self, scope: St) -> SiteGetCall<'a, C>
72597    where
72598        St: AsRef<str>,
72599    {
72600        self._scopes.insert(String::from(scope.as_ref()));
72601        self
72602    }
72603    /// Identifies the authorization scope(s) for the method you are building.
72604    ///
72605    /// See [`Self::add_scope()`] for details.
72606    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteGetCall<'a, C>
72607    where
72608        I: IntoIterator<Item = St>,
72609        St: AsRef<str>,
72610    {
72611        self._scopes
72612            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
72613        self
72614    }
72615
72616    /// Removes all scopes, and no default scope will be used either.
72617    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
72618    /// for details).
72619    pub fn clear_scopes(mut self) -> SiteGetCall<'a, C> {
72620        self._scopes.clear();
72621        self
72622    }
72623}
72624
72625/// Inserts a new site.
72626///
72627/// A builder for the *insert* method supported by a *site* resource.
72628/// It is not used directly, but through a [`SiteMethods`] instance.
72629///
72630/// # Example
72631///
72632/// Instantiate a resource method builder
72633///
72634/// ```test_harness,no_run
72635/// # extern crate hyper;
72636/// # extern crate hyper_rustls;
72637/// # extern crate google_dfareporting3d2 as dfareporting3d2;
72638/// use dfareporting3d2::api::Site;
72639/// # async fn dox() {
72640/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72641///
72642/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
72643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
72644/// #     secret,
72645/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72646/// # ).build().await.unwrap();
72647///
72648/// # let client = hyper_util::client::legacy::Client::builder(
72649/// #     hyper_util::rt::TokioExecutor::new()
72650/// # )
72651/// # .build(
72652/// #     hyper_rustls::HttpsConnectorBuilder::new()
72653/// #         .with_native_roots()
72654/// #         .unwrap()
72655/// #         .https_or_http()
72656/// #         .enable_http1()
72657/// #         .build()
72658/// # );
72659/// # let mut hub = Dfareporting::new(client, auth);
72660/// // As the method needs a request, you would usually fill it with the desired information
72661/// // into the respective structure. Some of the parts shown here might not be applicable !
72662/// // Values shown here are possibly random and not representative !
72663/// let mut req = Site::default();
72664///
72665/// // You can configure optional parameters by calling the respective setters at will, and
72666/// // execute the final call using `doit()`.
72667/// // Values shown here are possibly random and not representative !
72668/// let result = hub.sites().insert(req, -57)
72669///              .doit().await;
72670/// # }
72671/// ```
72672pub struct SiteInsertCall<'a, C>
72673where
72674    C: 'a,
72675{
72676    hub: &'a Dfareporting<C>,
72677    _request: Site,
72678    _profile_id: i64,
72679    _delegate: Option<&'a mut dyn common::Delegate>,
72680    _additional_params: HashMap<String, String>,
72681    _scopes: BTreeSet<String>,
72682}
72683
72684impl<'a, C> common::CallBuilder for SiteInsertCall<'a, C> {}
72685
72686impl<'a, C> SiteInsertCall<'a, C>
72687where
72688    C: common::Connector,
72689{
72690    /// Perform the operation you have build so far.
72691    pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
72692        use std::borrow::Cow;
72693        use std::io::{Read, Seek};
72694
72695        use common::{url::Params, ToParts};
72696        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
72697
72698        let mut dd = common::DefaultDelegate;
72699        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
72700        dlg.begin(common::MethodInfo {
72701            id: "dfareporting.sites.insert",
72702            http_method: hyper::Method::POST,
72703        });
72704
72705        for &field in ["alt", "profileId"].iter() {
72706            if self._additional_params.contains_key(field) {
72707                dlg.finished(false);
72708                return Err(common::Error::FieldClash(field));
72709            }
72710        }
72711
72712        let mut params = Params::with_capacity(4 + self._additional_params.len());
72713        params.push("profileId", self._profile_id.to_string());
72714
72715        params.extend(self._additional_params.iter());
72716
72717        params.push("alt", "json");
72718        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites";
72719        if self._scopes.is_empty() {
72720            self._scopes
72721                .insert(Scope::Dfatrafficking.as_ref().to_string());
72722        }
72723
72724        #[allow(clippy::single_element_loop)]
72725        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
72726            url = params.uri_replacement(url, param_name, find_this, false);
72727        }
72728        {
72729            let to_remove = ["profileId"];
72730            params.remove_params(&to_remove);
72731        }
72732
72733        let url = params.parse_with_url(&url);
72734
72735        let mut json_mime_type = mime::APPLICATION_JSON;
72736        let mut request_value_reader = {
72737            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
72738            common::remove_json_null_values(&mut value);
72739            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
72740            serde_json::to_writer(&mut dst, &value).unwrap();
72741            dst
72742        };
72743        let request_size = request_value_reader
72744            .seek(std::io::SeekFrom::End(0))
72745            .unwrap();
72746        request_value_reader
72747            .seek(std::io::SeekFrom::Start(0))
72748            .unwrap();
72749
72750        loop {
72751            let token = match self
72752                .hub
72753                .auth
72754                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
72755                .await
72756            {
72757                Ok(token) => token,
72758                Err(e) => match dlg.token(e) {
72759                    Ok(token) => token,
72760                    Err(e) => {
72761                        dlg.finished(false);
72762                        return Err(common::Error::MissingToken(e));
72763                    }
72764                },
72765            };
72766            request_value_reader
72767                .seek(std::io::SeekFrom::Start(0))
72768                .unwrap();
72769            let mut req_result = {
72770                let client = &self.hub.client;
72771                dlg.pre_request();
72772                let mut req_builder = hyper::Request::builder()
72773                    .method(hyper::Method::POST)
72774                    .uri(url.as_str())
72775                    .header(USER_AGENT, self.hub._user_agent.clone());
72776
72777                if let Some(token) = token.as_ref() {
72778                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
72779                }
72780
72781                let request = req_builder
72782                    .header(CONTENT_TYPE, json_mime_type.to_string())
72783                    .header(CONTENT_LENGTH, request_size as u64)
72784                    .body(common::to_body(
72785                        request_value_reader.get_ref().clone().into(),
72786                    ));
72787
72788                client.request(request.unwrap()).await
72789            };
72790
72791            match req_result {
72792                Err(err) => {
72793                    if let common::Retry::After(d) = dlg.http_error(&err) {
72794                        sleep(d).await;
72795                        continue;
72796                    }
72797                    dlg.finished(false);
72798                    return Err(common::Error::HttpError(err));
72799                }
72800                Ok(res) => {
72801                    let (mut parts, body) = res.into_parts();
72802                    let mut body = common::Body::new(body);
72803                    if !parts.status.is_success() {
72804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72805                        let error = serde_json::from_str(&common::to_string(&bytes));
72806                        let response = common::to_response(parts, bytes.into());
72807
72808                        if let common::Retry::After(d) =
72809                            dlg.http_failure(&response, error.as_ref().ok())
72810                        {
72811                            sleep(d).await;
72812                            continue;
72813                        }
72814
72815                        dlg.finished(false);
72816
72817                        return Err(match error {
72818                            Ok(value) => common::Error::BadRequest(value),
72819                            _ => common::Error::Failure(response),
72820                        });
72821                    }
72822                    let response = {
72823                        let bytes = common::to_bytes(body).await.unwrap_or_default();
72824                        let encoded = common::to_string(&bytes);
72825                        match serde_json::from_str(&encoded) {
72826                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
72827                            Err(error) => {
72828                                dlg.response_json_decode_error(&encoded, &error);
72829                                return Err(common::Error::JsonDecodeError(
72830                                    encoded.to_string(),
72831                                    error,
72832                                ));
72833                            }
72834                        }
72835                    };
72836
72837                    dlg.finished(true);
72838                    return Ok(response);
72839                }
72840            }
72841        }
72842    }
72843
72844    ///
72845    /// Sets the *request* property to the given value.
72846    ///
72847    /// Even though the property as already been set when instantiating this call,
72848    /// we provide this method for API completeness.
72849    pub fn request(mut self, new_value: Site) -> SiteInsertCall<'a, C> {
72850        self._request = new_value;
72851        self
72852    }
72853    /// User profile ID associated with this request.
72854    ///
72855    /// Sets the *profile id* path property to the given value.
72856    ///
72857    /// Even though the property as already been set when instantiating this call,
72858    /// we provide this method for API completeness.
72859    pub fn profile_id(mut self, new_value: i64) -> SiteInsertCall<'a, C> {
72860        self._profile_id = new_value;
72861        self
72862    }
72863    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
72864    /// while executing the actual API request.
72865    ///
72866    /// ````text
72867    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
72868    /// ````
72869    ///
72870    /// Sets the *delegate* property to the given value.
72871    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteInsertCall<'a, C> {
72872        self._delegate = Some(new_value);
72873        self
72874    }
72875
72876    /// Set any additional parameter of the query string used in the request.
72877    /// It should be used to set parameters which are not yet available through their own
72878    /// setters.
72879    ///
72880    /// Please note that this method must not be used to set any of the known parameters
72881    /// which have their own setter method. If done anyway, the request will fail.
72882    ///
72883    /// # Additional Parameters
72884    ///
72885    /// * *alt* (query-string) - Data format for the response.
72886    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
72887    /// * *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.
72888    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
72889    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
72890    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
72891    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
72892    pub fn param<T>(mut self, name: T, value: T) -> SiteInsertCall<'a, C>
72893    where
72894        T: AsRef<str>,
72895    {
72896        self._additional_params
72897            .insert(name.as_ref().to_string(), value.as_ref().to_string());
72898        self
72899    }
72900
72901    /// Identifies the authorization scope for the method you are building.
72902    ///
72903    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
72904    /// [`Scope::Dfatrafficking`].
72905    ///
72906    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
72907    /// tokens for more than one scope.
72908    ///
72909    /// Usually there is more than one suitable scope to authorize an operation, some of which may
72910    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
72911    /// sufficient, a read-write scope will do as well.
72912    pub fn add_scope<St>(mut self, scope: St) -> SiteInsertCall<'a, C>
72913    where
72914        St: AsRef<str>,
72915    {
72916        self._scopes.insert(String::from(scope.as_ref()));
72917        self
72918    }
72919    /// Identifies the authorization scope(s) for the method you are building.
72920    ///
72921    /// See [`Self::add_scope()`] for details.
72922    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteInsertCall<'a, C>
72923    where
72924        I: IntoIterator<Item = St>,
72925        St: AsRef<str>,
72926    {
72927        self._scopes
72928            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
72929        self
72930    }
72931
72932    /// Removes all scopes, and no default scope will be used either.
72933    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
72934    /// for details).
72935    pub fn clear_scopes(mut self) -> SiteInsertCall<'a, C> {
72936        self._scopes.clear();
72937        self
72938    }
72939}
72940
72941/// Retrieves a list of sites, possibly filtered. This method supports paging.
72942///
72943/// A builder for the *list* method supported by a *site* resource.
72944/// It is not used directly, but through a [`SiteMethods`] instance.
72945///
72946/// # Example
72947///
72948/// Instantiate a resource method builder
72949///
72950/// ```test_harness,no_run
72951/// # extern crate hyper;
72952/// # extern crate hyper_rustls;
72953/// # extern crate google_dfareporting3d2 as dfareporting3d2;
72954/// # async fn dox() {
72955/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72956///
72957/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
72958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
72959/// #     secret,
72960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72961/// # ).build().await.unwrap();
72962///
72963/// # let client = hyper_util::client::legacy::Client::builder(
72964/// #     hyper_util::rt::TokioExecutor::new()
72965/// # )
72966/// # .build(
72967/// #     hyper_rustls::HttpsConnectorBuilder::new()
72968/// #         .with_native_roots()
72969/// #         .unwrap()
72970/// #         .https_or_http()
72971/// #         .enable_http1()
72972/// #         .build()
72973/// # );
72974/// # let mut hub = Dfareporting::new(client, auth);
72975/// // You can configure optional parameters by calling the respective setters at will, and
72976/// // execute the final call using `doit()`.
72977/// // Values shown here are possibly random and not representative !
72978/// let result = hub.sites().list(-15)
72979///              .unmapped_site(true)
72980///              .subaccount_id(-85)
72981///              .sort_order("labore")
72982///              .sort_field("labore")
72983///              .search_string("et")
72984///              .page_token("aliquyam")
72985///              .max_results(-37)
72986///              .add_ids(-52)
72987///              .add_directory_site_ids(-12)
72988///              .add_campaign_ids(-57)
72989///              .approved(true)
72990///              .ad_words_site(false)
72991///              .accepts_publisher_paid_placements(true)
72992///              .accepts_interstitial_placements(false)
72993///              .accepts_in_stream_video_placements(true)
72994///              .doit().await;
72995/// # }
72996/// ```
72997pub struct SiteListCall<'a, C>
72998where
72999    C: 'a,
73000{
73001    hub: &'a Dfareporting<C>,
73002    _profile_id: i64,
73003    _unmapped_site: Option<bool>,
73004    _subaccount_id: Option<i64>,
73005    _sort_order: Option<String>,
73006    _sort_field: Option<String>,
73007    _search_string: Option<String>,
73008    _page_token: Option<String>,
73009    _max_results: Option<i32>,
73010    _ids: Vec<i64>,
73011    _directory_site_ids: Vec<i64>,
73012    _campaign_ids: Vec<i64>,
73013    _approved: Option<bool>,
73014    _ad_words_site: Option<bool>,
73015    _accepts_publisher_paid_placements: Option<bool>,
73016    _accepts_interstitial_placements: Option<bool>,
73017    _accepts_in_stream_video_placements: Option<bool>,
73018    _delegate: Option<&'a mut dyn common::Delegate>,
73019    _additional_params: HashMap<String, String>,
73020    _scopes: BTreeSet<String>,
73021}
73022
73023impl<'a, C> common::CallBuilder for SiteListCall<'a, C> {}
73024
73025impl<'a, C> SiteListCall<'a, C>
73026where
73027    C: common::Connector,
73028{
73029    /// Perform the operation you have build so far.
73030    pub async fn doit(mut self) -> common::Result<(common::Response, SitesListResponse)> {
73031        use std::borrow::Cow;
73032        use std::io::{Read, Seek};
73033
73034        use common::{url::Params, ToParts};
73035        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
73036
73037        let mut dd = common::DefaultDelegate;
73038        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
73039        dlg.begin(common::MethodInfo {
73040            id: "dfareporting.sites.list",
73041            http_method: hyper::Method::GET,
73042        });
73043
73044        for &field in [
73045            "alt",
73046            "profileId",
73047            "unmappedSite",
73048            "subaccountId",
73049            "sortOrder",
73050            "sortField",
73051            "searchString",
73052            "pageToken",
73053            "maxResults",
73054            "ids",
73055            "directorySiteIds",
73056            "campaignIds",
73057            "approved",
73058            "adWordsSite",
73059            "acceptsPublisherPaidPlacements",
73060            "acceptsInterstitialPlacements",
73061            "acceptsInStreamVideoPlacements",
73062        ]
73063        .iter()
73064        {
73065            if self._additional_params.contains_key(field) {
73066                dlg.finished(false);
73067                return Err(common::Error::FieldClash(field));
73068            }
73069        }
73070
73071        let mut params = Params::with_capacity(18 + self._additional_params.len());
73072        params.push("profileId", self._profile_id.to_string());
73073        if let Some(value) = self._unmapped_site.as_ref() {
73074            params.push("unmappedSite", value.to_string());
73075        }
73076        if let Some(value) = self._subaccount_id.as_ref() {
73077            params.push("subaccountId", value.to_string());
73078        }
73079        if let Some(value) = self._sort_order.as_ref() {
73080            params.push("sortOrder", value);
73081        }
73082        if let Some(value) = self._sort_field.as_ref() {
73083            params.push("sortField", value);
73084        }
73085        if let Some(value) = self._search_string.as_ref() {
73086            params.push("searchString", value);
73087        }
73088        if let Some(value) = self._page_token.as_ref() {
73089            params.push("pageToken", value);
73090        }
73091        if let Some(value) = self._max_results.as_ref() {
73092            params.push("maxResults", value.to_string());
73093        }
73094        if !self._ids.is_empty() {
73095            for f in self._ids.iter() {
73096                params.push("ids", f.to_string());
73097            }
73098        }
73099        if !self._directory_site_ids.is_empty() {
73100            for f in self._directory_site_ids.iter() {
73101                params.push("directorySiteIds", f.to_string());
73102            }
73103        }
73104        if !self._campaign_ids.is_empty() {
73105            for f in self._campaign_ids.iter() {
73106                params.push("campaignIds", f.to_string());
73107            }
73108        }
73109        if let Some(value) = self._approved.as_ref() {
73110            params.push("approved", value.to_string());
73111        }
73112        if let Some(value) = self._ad_words_site.as_ref() {
73113            params.push("adWordsSite", value.to_string());
73114        }
73115        if let Some(value) = self._accepts_publisher_paid_placements.as_ref() {
73116            params.push("acceptsPublisherPaidPlacements", value.to_string());
73117        }
73118        if let Some(value) = self._accepts_interstitial_placements.as_ref() {
73119            params.push("acceptsInterstitialPlacements", value.to_string());
73120        }
73121        if let Some(value) = self._accepts_in_stream_video_placements.as_ref() {
73122            params.push("acceptsInStreamVideoPlacements", value.to_string());
73123        }
73124
73125        params.extend(self._additional_params.iter());
73126
73127        params.push("alt", "json");
73128        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites";
73129        if self._scopes.is_empty() {
73130            self._scopes
73131                .insert(Scope::Dfatrafficking.as_ref().to_string());
73132        }
73133
73134        #[allow(clippy::single_element_loop)]
73135        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
73136            url = params.uri_replacement(url, param_name, find_this, false);
73137        }
73138        {
73139            let to_remove = ["profileId"];
73140            params.remove_params(&to_remove);
73141        }
73142
73143        let url = params.parse_with_url(&url);
73144
73145        loop {
73146            let token = match self
73147                .hub
73148                .auth
73149                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
73150                .await
73151            {
73152                Ok(token) => token,
73153                Err(e) => match dlg.token(e) {
73154                    Ok(token) => token,
73155                    Err(e) => {
73156                        dlg.finished(false);
73157                        return Err(common::Error::MissingToken(e));
73158                    }
73159                },
73160            };
73161            let mut req_result = {
73162                let client = &self.hub.client;
73163                dlg.pre_request();
73164                let mut req_builder = hyper::Request::builder()
73165                    .method(hyper::Method::GET)
73166                    .uri(url.as_str())
73167                    .header(USER_AGENT, self.hub._user_agent.clone());
73168
73169                if let Some(token) = token.as_ref() {
73170                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
73171                }
73172
73173                let request = req_builder
73174                    .header(CONTENT_LENGTH, 0_u64)
73175                    .body(common::to_body::<String>(None));
73176
73177                client.request(request.unwrap()).await
73178            };
73179
73180            match req_result {
73181                Err(err) => {
73182                    if let common::Retry::After(d) = dlg.http_error(&err) {
73183                        sleep(d).await;
73184                        continue;
73185                    }
73186                    dlg.finished(false);
73187                    return Err(common::Error::HttpError(err));
73188                }
73189                Ok(res) => {
73190                    let (mut parts, body) = res.into_parts();
73191                    let mut body = common::Body::new(body);
73192                    if !parts.status.is_success() {
73193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73194                        let error = serde_json::from_str(&common::to_string(&bytes));
73195                        let response = common::to_response(parts, bytes.into());
73196
73197                        if let common::Retry::After(d) =
73198                            dlg.http_failure(&response, error.as_ref().ok())
73199                        {
73200                            sleep(d).await;
73201                            continue;
73202                        }
73203
73204                        dlg.finished(false);
73205
73206                        return Err(match error {
73207                            Ok(value) => common::Error::BadRequest(value),
73208                            _ => common::Error::Failure(response),
73209                        });
73210                    }
73211                    let response = {
73212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73213                        let encoded = common::to_string(&bytes);
73214                        match serde_json::from_str(&encoded) {
73215                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
73216                            Err(error) => {
73217                                dlg.response_json_decode_error(&encoded, &error);
73218                                return Err(common::Error::JsonDecodeError(
73219                                    encoded.to_string(),
73220                                    error,
73221                                ));
73222                            }
73223                        }
73224                    };
73225
73226                    dlg.finished(true);
73227                    return Ok(response);
73228                }
73229            }
73230        }
73231    }
73232
73233    /// User profile ID associated with this request.
73234    ///
73235    /// Sets the *profile id* path property to the given value.
73236    ///
73237    /// Even though the property as already been set when instantiating this call,
73238    /// we provide this method for API completeness.
73239    pub fn profile_id(mut self, new_value: i64) -> SiteListCall<'a, C> {
73240        self._profile_id = new_value;
73241        self
73242    }
73243    /// Select only sites that have not been mapped to a directory site.
73244    ///
73245    /// Sets the *unmapped site* query property to the given value.
73246    pub fn unmapped_site(mut self, new_value: bool) -> SiteListCall<'a, C> {
73247        self._unmapped_site = Some(new_value);
73248        self
73249    }
73250    /// Select only sites with this subaccount ID.
73251    ///
73252    /// Sets the *subaccount id* query property to the given value.
73253    pub fn subaccount_id(mut self, new_value: i64) -> SiteListCall<'a, C> {
73254        self._subaccount_id = Some(new_value);
73255        self
73256    }
73257    /// Order of sorted results.
73258    ///
73259    /// Sets the *sort order* query property to the given value.
73260    pub fn sort_order(mut self, new_value: &str) -> SiteListCall<'a, C> {
73261        self._sort_order = Some(new_value.to_string());
73262        self
73263    }
73264    /// Field by which to sort the list.
73265    ///
73266    /// Sets the *sort field* query property to the given value.
73267    pub fn sort_field(mut self, new_value: &str) -> SiteListCall<'a, C> {
73268        self._sort_field = Some(new_value.to_string());
73269        self
73270    }
73271    /// Allows searching for objects by name, ID or keyName. Wildcards (*) are allowed. For example, "site*2015" will return objects with names like "site June 2015", "site April 2015", or simply "site 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "site" will match objects with name "my site", "site 2015", or simply "site".
73272    ///
73273    /// Sets the *search string* query property to the given value.
73274    pub fn search_string(mut self, new_value: &str) -> SiteListCall<'a, C> {
73275        self._search_string = Some(new_value.to_string());
73276        self
73277    }
73278    /// Value of the nextPageToken from the previous result page.
73279    ///
73280    /// Sets the *page token* query property to the given value.
73281    pub fn page_token(mut self, new_value: &str) -> SiteListCall<'a, C> {
73282        self._page_token = Some(new_value.to_string());
73283        self
73284    }
73285    /// Maximum number of results to return.
73286    ///
73287    /// Sets the *max results* query property to the given value.
73288    pub fn max_results(mut self, new_value: i32) -> SiteListCall<'a, C> {
73289        self._max_results = Some(new_value);
73290        self
73291    }
73292    /// Select only sites with these IDs.
73293    ///
73294    /// Append the given value to the *ids* query property.
73295    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
73296    pub fn add_ids(mut self, new_value: i64) -> SiteListCall<'a, C> {
73297        self._ids.push(new_value);
73298        self
73299    }
73300    /// Select only sites with these directory site IDs.
73301    ///
73302    /// Append the given value to the *directory site ids* query property.
73303    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
73304    pub fn add_directory_site_ids(mut self, new_value: i64) -> SiteListCall<'a, C> {
73305        self._directory_site_ids.push(new_value);
73306        self
73307    }
73308    /// Select only sites with these campaign IDs.
73309    ///
73310    /// Append the given value to the *campaign ids* query property.
73311    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
73312    pub fn add_campaign_ids(mut self, new_value: i64) -> SiteListCall<'a, C> {
73313        self._campaign_ids.push(new_value);
73314        self
73315    }
73316    /// Select only approved sites.
73317    ///
73318    /// Sets the *approved* query property to the given value.
73319    pub fn approved(mut self, new_value: bool) -> SiteListCall<'a, C> {
73320        self._approved = Some(new_value);
73321        self
73322    }
73323    /// Select only AdWords sites.
73324    ///
73325    /// Sets the *ad words site* query property to the given value.
73326    pub fn ad_words_site(mut self, new_value: bool) -> SiteListCall<'a, C> {
73327        self._ad_words_site = Some(new_value);
73328        self
73329    }
73330    /// Select only sites that accept publisher paid placements.
73331    ///
73332    /// Sets the *accepts publisher paid placements* query property to the given value.
73333    pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> SiteListCall<'a, C> {
73334        self._accepts_publisher_paid_placements = Some(new_value);
73335        self
73336    }
73337    /// This search filter is no longer supported and will have no effect on the results returned.
73338    ///
73339    /// Sets the *accepts interstitial placements* query property to the given value.
73340    pub fn accepts_interstitial_placements(mut self, new_value: bool) -> SiteListCall<'a, C> {
73341        self._accepts_interstitial_placements = Some(new_value);
73342        self
73343    }
73344    /// This search filter is no longer supported and will have no effect on the results returned.
73345    ///
73346    /// Sets the *accepts in stream video placements* query property to the given value.
73347    pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> SiteListCall<'a, C> {
73348        self._accepts_in_stream_video_placements = Some(new_value);
73349        self
73350    }
73351    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
73352    /// while executing the actual API request.
73353    ///
73354    /// ````text
73355    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
73356    /// ````
73357    ///
73358    /// Sets the *delegate* property to the given value.
73359    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteListCall<'a, C> {
73360        self._delegate = Some(new_value);
73361        self
73362    }
73363
73364    /// Set any additional parameter of the query string used in the request.
73365    /// It should be used to set parameters which are not yet available through their own
73366    /// setters.
73367    ///
73368    /// Please note that this method must not be used to set any of the known parameters
73369    /// which have their own setter method. If done anyway, the request will fail.
73370    ///
73371    /// # Additional Parameters
73372    ///
73373    /// * *alt* (query-string) - Data format for the response.
73374    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
73375    /// * *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.
73376    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
73377    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
73378    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
73379    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
73380    pub fn param<T>(mut self, name: T, value: T) -> SiteListCall<'a, C>
73381    where
73382        T: AsRef<str>,
73383    {
73384        self._additional_params
73385            .insert(name.as_ref().to_string(), value.as_ref().to_string());
73386        self
73387    }
73388
73389    /// Identifies the authorization scope for the method you are building.
73390    ///
73391    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
73392    /// [`Scope::Dfatrafficking`].
73393    ///
73394    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
73395    /// tokens for more than one scope.
73396    ///
73397    /// Usually there is more than one suitable scope to authorize an operation, some of which may
73398    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
73399    /// sufficient, a read-write scope will do as well.
73400    pub fn add_scope<St>(mut self, scope: St) -> SiteListCall<'a, C>
73401    where
73402        St: AsRef<str>,
73403    {
73404        self._scopes.insert(String::from(scope.as_ref()));
73405        self
73406    }
73407    /// Identifies the authorization scope(s) for the method you are building.
73408    ///
73409    /// See [`Self::add_scope()`] for details.
73410    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteListCall<'a, C>
73411    where
73412        I: IntoIterator<Item = St>,
73413        St: AsRef<str>,
73414    {
73415        self._scopes
73416            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
73417        self
73418    }
73419
73420    /// Removes all scopes, and no default scope will be used either.
73421    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
73422    /// for details).
73423    pub fn clear_scopes(mut self) -> SiteListCall<'a, C> {
73424        self._scopes.clear();
73425        self
73426    }
73427}
73428
73429/// Updates an existing site. This method supports patch semantics.
73430///
73431/// A builder for the *patch* method supported by a *site* resource.
73432/// It is not used directly, but through a [`SiteMethods`] instance.
73433///
73434/// # Example
73435///
73436/// Instantiate a resource method builder
73437///
73438/// ```test_harness,no_run
73439/// # extern crate hyper;
73440/// # extern crate hyper_rustls;
73441/// # extern crate google_dfareporting3d2 as dfareporting3d2;
73442/// use dfareporting3d2::api::Site;
73443/// # async fn dox() {
73444/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
73445///
73446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
73447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
73448/// #     secret,
73449/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73450/// # ).build().await.unwrap();
73451///
73452/// # let client = hyper_util::client::legacy::Client::builder(
73453/// #     hyper_util::rt::TokioExecutor::new()
73454/// # )
73455/// # .build(
73456/// #     hyper_rustls::HttpsConnectorBuilder::new()
73457/// #         .with_native_roots()
73458/// #         .unwrap()
73459/// #         .https_or_http()
73460/// #         .enable_http1()
73461/// #         .build()
73462/// # );
73463/// # let mut hub = Dfareporting::new(client, auth);
73464/// // As the method needs a request, you would usually fill it with the desired information
73465/// // into the respective structure. Some of the parts shown here might not be applicable !
73466/// // Values shown here are possibly random and not representative !
73467/// let mut req = Site::default();
73468///
73469/// // You can configure optional parameters by calling the respective setters at will, and
73470/// // execute the final call using `doit()`.
73471/// // Values shown here are possibly random and not representative !
73472/// let result = hub.sites().patch(req, -9, -52)
73473///              .doit().await;
73474/// # }
73475/// ```
73476pub struct SitePatchCall<'a, C>
73477where
73478    C: 'a,
73479{
73480    hub: &'a Dfareporting<C>,
73481    _request: Site,
73482    _profile_id: i64,
73483    _id: i64,
73484    _delegate: Option<&'a mut dyn common::Delegate>,
73485    _additional_params: HashMap<String, String>,
73486    _scopes: BTreeSet<String>,
73487}
73488
73489impl<'a, C> common::CallBuilder for SitePatchCall<'a, C> {}
73490
73491impl<'a, C> SitePatchCall<'a, C>
73492where
73493    C: common::Connector,
73494{
73495    /// Perform the operation you have build so far.
73496    pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
73497        use std::borrow::Cow;
73498        use std::io::{Read, Seek};
73499
73500        use common::{url::Params, ToParts};
73501        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
73502
73503        let mut dd = common::DefaultDelegate;
73504        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
73505        dlg.begin(common::MethodInfo {
73506            id: "dfareporting.sites.patch",
73507            http_method: hyper::Method::PATCH,
73508        });
73509
73510        for &field in ["alt", "profileId", "id"].iter() {
73511            if self._additional_params.contains_key(field) {
73512                dlg.finished(false);
73513                return Err(common::Error::FieldClash(field));
73514            }
73515        }
73516
73517        let mut params = Params::with_capacity(5 + self._additional_params.len());
73518        params.push("profileId", self._profile_id.to_string());
73519        params.push("id", self._id.to_string());
73520
73521        params.extend(self._additional_params.iter());
73522
73523        params.push("alt", "json");
73524        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites";
73525        if self._scopes.is_empty() {
73526            self._scopes
73527                .insert(Scope::Dfatrafficking.as_ref().to_string());
73528        }
73529
73530        #[allow(clippy::single_element_loop)]
73531        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
73532            url = params.uri_replacement(url, param_name, find_this, false);
73533        }
73534        {
73535            let to_remove = ["profileId"];
73536            params.remove_params(&to_remove);
73537        }
73538
73539        let url = params.parse_with_url(&url);
73540
73541        let mut json_mime_type = mime::APPLICATION_JSON;
73542        let mut request_value_reader = {
73543            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
73544            common::remove_json_null_values(&mut value);
73545            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
73546            serde_json::to_writer(&mut dst, &value).unwrap();
73547            dst
73548        };
73549        let request_size = request_value_reader
73550            .seek(std::io::SeekFrom::End(0))
73551            .unwrap();
73552        request_value_reader
73553            .seek(std::io::SeekFrom::Start(0))
73554            .unwrap();
73555
73556        loop {
73557            let token = match self
73558                .hub
73559                .auth
73560                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
73561                .await
73562            {
73563                Ok(token) => token,
73564                Err(e) => match dlg.token(e) {
73565                    Ok(token) => token,
73566                    Err(e) => {
73567                        dlg.finished(false);
73568                        return Err(common::Error::MissingToken(e));
73569                    }
73570                },
73571            };
73572            request_value_reader
73573                .seek(std::io::SeekFrom::Start(0))
73574                .unwrap();
73575            let mut req_result = {
73576                let client = &self.hub.client;
73577                dlg.pre_request();
73578                let mut req_builder = hyper::Request::builder()
73579                    .method(hyper::Method::PATCH)
73580                    .uri(url.as_str())
73581                    .header(USER_AGENT, self.hub._user_agent.clone());
73582
73583                if let Some(token) = token.as_ref() {
73584                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
73585                }
73586
73587                let request = req_builder
73588                    .header(CONTENT_TYPE, json_mime_type.to_string())
73589                    .header(CONTENT_LENGTH, request_size as u64)
73590                    .body(common::to_body(
73591                        request_value_reader.get_ref().clone().into(),
73592                    ));
73593
73594                client.request(request.unwrap()).await
73595            };
73596
73597            match req_result {
73598                Err(err) => {
73599                    if let common::Retry::After(d) = dlg.http_error(&err) {
73600                        sleep(d).await;
73601                        continue;
73602                    }
73603                    dlg.finished(false);
73604                    return Err(common::Error::HttpError(err));
73605                }
73606                Ok(res) => {
73607                    let (mut parts, body) = res.into_parts();
73608                    let mut body = common::Body::new(body);
73609                    if !parts.status.is_success() {
73610                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73611                        let error = serde_json::from_str(&common::to_string(&bytes));
73612                        let response = common::to_response(parts, bytes.into());
73613
73614                        if let common::Retry::After(d) =
73615                            dlg.http_failure(&response, error.as_ref().ok())
73616                        {
73617                            sleep(d).await;
73618                            continue;
73619                        }
73620
73621                        dlg.finished(false);
73622
73623                        return Err(match error {
73624                            Ok(value) => common::Error::BadRequest(value),
73625                            _ => common::Error::Failure(response),
73626                        });
73627                    }
73628                    let response = {
73629                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73630                        let encoded = common::to_string(&bytes);
73631                        match serde_json::from_str(&encoded) {
73632                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
73633                            Err(error) => {
73634                                dlg.response_json_decode_error(&encoded, &error);
73635                                return Err(common::Error::JsonDecodeError(
73636                                    encoded.to_string(),
73637                                    error,
73638                                ));
73639                            }
73640                        }
73641                    };
73642
73643                    dlg.finished(true);
73644                    return Ok(response);
73645                }
73646            }
73647        }
73648    }
73649
73650    ///
73651    /// Sets the *request* property to the given value.
73652    ///
73653    /// Even though the property as already been set when instantiating this call,
73654    /// we provide this method for API completeness.
73655    pub fn request(mut self, new_value: Site) -> SitePatchCall<'a, C> {
73656        self._request = new_value;
73657        self
73658    }
73659    /// User profile ID associated with this request.
73660    ///
73661    /// Sets the *profile id* path property to the given value.
73662    ///
73663    /// Even though the property as already been set when instantiating this call,
73664    /// we provide this method for API completeness.
73665    pub fn profile_id(mut self, new_value: i64) -> SitePatchCall<'a, C> {
73666        self._profile_id = new_value;
73667        self
73668    }
73669    /// Site ID.
73670    ///
73671    /// Sets the *id* query property to the given value.
73672    ///
73673    /// Even though the property as already been set when instantiating this call,
73674    /// we provide this method for API completeness.
73675    pub fn id(mut self, new_value: i64) -> SitePatchCall<'a, C> {
73676        self._id = new_value;
73677        self
73678    }
73679    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
73680    /// while executing the actual API request.
73681    ///
73682    /// ````text
73683    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
73684    /// ````
73685    ///
73686    /// Sets the *delegate* property to the given value.
73687    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SitePatchCall<'a, C> {
73688        self._delegate = Some(new_value);
73689        self
73690    }
73691
73692    /// Set any additional parameter of the query string used in the request.
73693    /// It should be used to set parameters which are not yet available through their own
73694    /// setters.
73695    ///
73696    /// Please note that this method must not be used to set any of the known parameters
73697    /// which have their own setter method. If done anyway, the request will fail.
73698    ///
73699    /// # Additional Parameters
73700    ///
73701    /// * *alt* (query-string) - Data format for the response.
73702    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
73703    /// * *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.
73704    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
73705    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
73706    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
73707    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
73708    pub fn param<T>(mut self, name: T, value: T) -> SitePatchCall<'a, C>
73709    where
73710        T: AsRef<str>,
73711    {
73712        self._additional_params
73713            .insert(name.as_ref().to_string(), value.as_ref().to_string());
73714        self
73715    }
73716
73717    /// Identifies the authorization scope for the method you are building.
73718    ///
73719    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
73720    /// [`Scope::Dfatrafficking`].
73721    ///
73722    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
73723    /// tokens for more than one scope.
73724    ///
73725    /// Usually there is more than one suitable scope to authorize an operation, some of which may
73726    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
73727    /// sufficient, a read-write scope will do as well.
73728    pub fn add_scope<St>(mut self, scope: St) -> SitePatchCall<'a, C>
73729    where
73730        St: AsRef<str>,
73731    {
73732        self._scopes.insert(String::from(scope.as_ref()));
73733        self
73734    }
73735    /// Identifies the authorization scope(s) for the method you are building.
73736    ///
73737    /// See [`Self::add_scope()`] for details.
73738    pub fn add_scopes<I, St>(mut self, scopes: I) -> SitePatchCall<'a, C>
73739    where
73740        I: IntoIterator<Item = St>,
73741        St: AsRef<str>,
73742    {
73743        self._scopes
73744            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
73745        self
73746    }
73747
73748    /// Removes all scopes, and no default scope will be used either.
73749    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
73750    /// for details).
73751    pub fn clear_scopes(mut self) -> SitePatchCall<'a, C> {
73752        self._scopes.clear();
73753        self
73754    }
73755}
73756
73757/// Updates an existing site.
73758///
73759/// A builder for the *update* method supported by a *site* resource.
73760/// It is not used directly, but through a [`SiteMethods`] instance.
73761///
73762/// # Example
73763///
73764/// Instantiate a resource method builder
73765///
73766/// ```test_harness,no_run
73767/// # extern crate hyper;
73768/// # extern crate hyper_rustls;
73769/// # extern crate google_dfareporting3d2 as dfareporting3d2;
73770/// use dfareporting3d2::api::Site;
73771/// # async fn dox() {
73772/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
73773///
73774/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
73775/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
73776/// #     secret,
73777/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73778/// # ).build().await.unwrap();
73779///
73780/// # let client = hyper_util::client::legacy::Client::builder(
73781/// #     hyper_util::rt::TokioExecutor::new()
73782/// # )
73783/// # .build(
73784/// #     hyper_rustls::HttpsConnectorBuilder::new()
73785/// #         .with_native_roots()
73786/// #         .unwrap()
73787/// #         .https_or_http()
73788/// #         .enable_http1()
73789/// #         .build()
73790/// # );
73791/// # let mut hub = Dfareporting::new(client, auth);
73792/// // As the method needs a request, you would usually fill it with the desired information
73793/// // into the respective structure. Some of the parts shown here might not be applicable !
73794/// // Values shown here are possibly random and not representative !
73795/// let mut req = Site::default();
73796///
73797/// // You can configure optional parameters by calling the respective setters at will, and
73798/// // execute the final call using `doit()`.
73799/// // Values shown here are possibly random and not representative !
73800/// let result = hub.sites().update(req, -22)
73801///              .doit().await;
73802/// # }
73803/// ```
73804pub struct SiteUpdateCall<'a, C>
73805where
73806    C: 'a,
73807{
73808    hub: &'a Dfareporting<C>,
73809    _request: Site,
73810    _profile_id: i64,
73811    _delegate: Option<&'a mut dyn common::Delegate>,
73812    _additional_params: HashMap<String, String>,
73813    _scopes: BTreeSet<String>,
73814}
73815
73816impl<'a, C> common::CallBuilder for SiteUpdateCall<'a, C> {}
73817
73818impl<'a, C> SiteUpdateCall<'a, C>
73819where
73820    C: common::Connector,
73821{
73822    /// Perform the operation you have build so far.
73823    pub async fn doit(mut self) -> common::Result<(common::Response, Site)> {
73824        use std::borrow::Cow;
73825        use std::io::{Read, Seek};
73826
73827        use common::{url::Params, ToParts};
73828        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
73829
73830        let mut dd = common::DefaultDelegate;
73831        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
73832        dlg.begin(common::MethodInfo {
73833            id: "dfareporting.sites.update",
73834            http_method: hyper::Method::PUT,
73835        });
73836
73837        for &field in ["alt", "profileId"].iter() {
73838            if self._additional_params.contains_key(field) {
73839                dlg.finished(false);
73840                return Err(common::Error::FieldClash(field));
73841            }
73842        }
73843
73844        let mut params = Params::with_capacity(4 + self._additional_params.len());
73845        params.push("profileId", self._profile_id.to_string());
73846
73847        params.extend(self._additional_params.iter());
73848
73849        params.push("alt", "json");
73850        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites";
73851        if self._scopes.is_empty() {
73852            self._scopes
73853                .insert(Scope::Dfatrafficking.as_ref().to_string());
73854        }
73855
73856        #[allow(clippy::single_element_loop)]
73857        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
73858            url = params.uri_replacement(url, param_name, find_this, false);
73859        }
73860        {
73861            let to_remove = ["profileId"];
73862            params.remove_params(&to_remove);
73863        }
73864
73865        let url = params.parse_with_url(&url);
73866
73867        let mut json_mime_type = mime::APPLICATION_JSON;
73868        let mut request_value_reader = {
73869            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
73870            common::remove_json_null_values(&mut value);
73871            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
73872            serde_json::to_writer(&mut dst, &value).unwrap();
73873            dst
73874        };
73875        let request_size = request_value_reader
73876            .seek(std::io::SeekFrom::End(0))
73877            .unwrap();
73878        request_value_reader
73879            .seek(std::io::SeekFrom::Start(0))
73880            .unwrap();
73881
73882        loop {
73883            let token = match self
73884                .hub
73885                .auth
73886                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
73887                .await
73888            {
73889                Ok(token) => token,
73890                Err(e) => match dlg.token(e) {
73891                    Ok(token) => token,
73892                    Err(e) => {
73893                        dlg.finished(false);
73894                        return Err(common::Error::MissingToken(e));
73895                    }
73896                },
73897            };
73898            request_value_reader
73899                .seek(std::io::SeekFrom::Start(0))
73900                .unwrap();
73901            let mut req_result = {
73902                let client = &self.hub.client;
73903                dlg.pre_request();
73904                let mut req_builder = hyper::Request::builder()
73905                    .method(hyper::Method::PUT)
73906                    .uri(url.as_str())
73907                    .header(USER_AGENT, self.hub._user_agent.clone());
73908
73909                if let Some(token) = token.as_ref() {
73910                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
73911                }
73912
73913                let request = req_builder
73914                    .header(CONTENT_TYPE, json_mime_type.to_string())
73915                    .header(CONTENT_LENGTH, request_size as u64)
73916                    .body(common::to_body(
73917                        request_value_reader.get_ref().clone().into(),
73918                    ));
73919
73920                client.request(request.unwrap()).await
73921            };
73922
73923            match req_result {
73924                Err(err) => {
73925                    if let common::Retry::After(d) = dlg.http_error(&err) {
73926                        sleep(d).await;
73927                        continue;
73928                    }
73929                    dlg.finished(false);
73930                    return Err(common::Error::HttpError(err));
73931                }
73932                Ok(res) => {
73933                    let (mut parts, body) = res.into_parts();
73934                    let mut body = common::Body::new(body);
73935                    if !parts.status.is_success() {
73936                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73937                        let error = serde_json::from_str(&common::to_string(&bytes));
73938                        let response = common::to_response(parts, bytes.into());
73939
73940                        if let common::Retry::After(d) =
73941                            dlg.http_failure(&response, error.as_ref().ok())
73942                        {
73943                            sleep(d).await;
73944                            continue;
73945                        }
73946
73947                        dlg.finished(false);
73948
73949                        return Err(match error {
73950                            Ok(value) => common::Error::BadRequest(value),
73951                            _ => common::Error::Failure(response),
73952                        });
73953                    }
73954                    let response = {
73955                        let bytes = common::to_bytes(body).await.unwrap_or_default();
73956                        let encoded = common::to_string(&bytes);
73957                        match serde_json::from_str(&encoded) {
73958                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
73959                            Err(error) => {
73960                                dlg.response_json_decode_error(&encoded, &error);
73961                                return Err(common::Error::JsonDecodeError(
73962                                    encoded.to_string(),
73963                                    error,
73964                                ));
73965                            }
73966                        }
73967                    };
73968
73969                    dlg.finished(true);
73970                    return Ok(response);
73971                }
73972            }
73973        }
73974    }
73975
73976    ///
73977    /// Sets the *request* property to the given value.
73978    ///
73979    /// Even though the property as already been set when instantiating this call,
73980    /// we provide this method for API completeness.
73981    pub fn request(mut self, new_value: Site) -> SiteUpdateCall<'a, C> {
73982        self._request = new_value;
73983        self
73984    }
73985    /// User profile ID associated with this request.
73986    ///
73987    /// Sets the *profile id* path property to the given value.
73988    ///
73989    /// Even though the property as already been set when instantiating this call,
73990    /// we provide this method for API completeness.
73991    pub fn profile_id(mut self, new_value: i64) -> SiteUpdateCall<'a, C> {
73992        self._profile_id = new_value;
73993        self
73994    }
73995    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
73996    /// while executing the actual API request.
73997    ///
73998    /// ````text
73999    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
74000    /// ````
74001    ///
74002    /// Sets the *delegate* property to the given value.
74003    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SiteUpdateCall<'a, C> {
74004        self._delegate = Some(new_value);
74005        self
74006    }
74007
74008    /// Set any additional parameter of the query string used in the request.
74009    /// It should be used to set parameters which are not yet available through their own
74010    /// setters.
74011    ///
74012    /// Please note that this method must not be used to set any of the known parameters
74013    /// which have their own setter method. If done anyway, the request will fail.
74014    ///
74015    /// # Additional Parameters
74016    ///
74017    /// * *alt* (query-string) - Data format for the response.
74018    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
74019    /// * *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.
74020    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
74021    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
74022    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
74023    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
74024    pub fn param<T>(mut self, name: T, value: T) -> SiteUpdateCall<'a, C>
74025    where
74026        T: AsRef<str>,
74027    {
74028        self._additional_params
74029            .insert(name.as_ref().to_string(), value.as_ref().to_string());
74030        self
74031    }
74032
74033    /// Identifies the authorization scope for the method you are building.
74034    ///
74035    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
74036    /// [`Scope::Dfatrafficking`].
74037    ///
74038    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
74039    /// tokens for more than one scope.
74040    ///
74041    /// Usually there is more than one suitable scope to authorize an operation, some of which may
74042    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
74043    /// sufficient, a read-write scope will do as well.
74044    pub fn add_scope<St>(mut self, scope: St) -> SiteUpdateCall<'a, C>
74045    where
74046        St: AsRef<str>,
74047    {
74048        self._scopes.insert(String::from(scope.as_ref()));
74049        self
74050    }
74051    /// Identifies the authorization scope(s) for the method you are building.
74052    ///
74053    /// See [`Self::add_scope()`] for details.
74054    pub fn add_scopes<I, St>(mut self, scopes: I) -> SiteUpdateCall<'a, C>
74055    where
74056        I: IntoIterator<Item = St>,
74057        St: AsRef<str>,
74058    {
74059        self._scopes
74060            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
74061        self
74062    }
74063
74064    /// Removes all scopes, and no default scope will be used either.
74065    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
74066    /// for details).
74067    pub fn clear_scopes(mut self) -> SiteUpdateCall<'a, C> {
74068        self._scopes.clear();
74069        self
74070    }
74071}
74072
74073/// Gets one size by ID.
74074///
74075/// A builder for the *get* method supported by a *size* resource.
74076/// It is not used directly, but through a [`SizeMethods`] instance.
74077///
74078/// # Example
74079///
74080/// Instantiate a resource method builder
74081///
74082/// ```test_harness,no_run
74083/// # extern crate hyper;
74084/// # extern crate hyper_rustls;
74085/// # extern crate google_dfareporting3d2 as dfareporting3d2;
74086/// # async fn dox() {
74087/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
74088///
74089/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
74090/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
74091/// #     secret,
74092/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
74093/// # ).build().await.unwrap();
74094///
74095/// # let client = hyper_util::client::legacy::Client::builder(
74096/// #     hyper_util::rt::TokioExecutor::new()
74097/// # )
74098/// # .build(
74099/// #     hyper_rustls::HttpsConnectorBuilder::new()
74100/// #         .with_native_roots()
74101/// #         .unwrap()
74102/// #         .https_or_http()
74103/// #         .enable_http1()
74104/// #         .build()
74105/// # );
74106/// # let mut hub = Dfareporting::new(client, auth);
74107/// // You can configure optional parameters by calling the respective setters at will, and
74108/// // execute the final call using `doit()`.
74109/// // Values shown here are possibly random and not representative !
74110/// let result = hub.sizes().get(-36, -43)
74111///              .doit().await;
74112/// # }
74113/// ```
74114pub struct SizeGetCall<'a, C>
74115where
74116    C: 'a,
74117{
74118    hub: &'a Dfareporting<C>,
74119    _profile_id: i64,
74120    _id: i64,
74121    _delegate: Option<&'a mut dyn common::Delegate>,
74122    _additional_params: HashMap<String, String>,
74123    _scopes: BTreeSet<String>,
74124}
74125
74126impl<'a, C> common::CallBuilder for SizeGetCall<'a, C> {}
74127
74128impl<'a, C> SizeGetCall<'a, C>
74129where
74130    C: common::Connector,
74131{
74132    /// Perform the operation you have build so far.
74133    pub async fn doit(mut self) -> common::Result<(common::Response, Size)> {
74134        use std::borrow::Cow;
74135        use std::io::{Read, Seek};
74136
74137        use common::{url::Params, ToParts};
74138        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
74139
74140        let mut dd = common::DefaultDelegate;
74141        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
74142        dlg.begin(common::MethodInfo {
74143            id: "dfareporting.sizes.get",
74144            http_method: hyper::Method::GET,
74145        });
74146
74147        for &field in ["alt", "profileId", "id"].iter() {
74148            if self._additional_params.contains_key(field) {
74149                dlg.finished(false);
74150                return Err(common::Error::FieldClash(field));
74151            }
74152        }
74153
74154        let mut params = Params::with_capacity(4 + self._additional_params.len());
74155        params.push("profileId", self._profile_id.to_string());
74156        params.push("id", self._id.to_string());
74157
74158        params.extend(self._additional_params.iter());
74159
74160        params.push("alt", "json");
74161        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes/{id}";
74162        if self._scopes.is_empty() {
74163            self._scopes
74164                .insert(Scope::Dfatrafficking.as_ref().to_string());
74165        }
74166
74167        #[allow(clippy::single_element_loop)]
74168        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
74169            url = params.uri_replacement(url, param_name, find_this, false);
74170        }
74171        {
74172            let to_remove = ["id", "profileId"];
74173            params.remove_params(&to_remove);
74174        }
74175
74176        let url = params.parse_with_url(&url);
74177
74178        loop {
74179            let token = match self
74180                .hub
74181                .auth
74182                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
74183                .await
74184            {
74185                Ok(token) => token,
74186                Err(e) => match dlg.token(e) {
74187                    Ok(token) => token,
74188                    Err(e) => {
74189                        dlg.finished(false);
74190                        return Err(common::Error::MissingToken(e));
74191                    }
74192                },
74193            };
74194            let mut req_result = {
74195                let client = &self.hub.client;
74196                dlg.pre_request();
74197                let mut req_builder = hyper::Request::builder()
74198                    .method(hyper::Method::GET)
74199                    .uri(url.as_str())
74200                    .header(USER_AGENT, self.hub._user_agent.clone());
74201
74202                if let Some(token) = token.as_ref() {
74203                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
74204                }
74205
74206                let request = req_builder
74207                    .header(CONTENT_LENGTH, 0_u64)
74208                    .body(common::to_body::<String>(None));
74209
74210                client.request(request.unwrap()).await
74211            };
74212
74213            match req_result {
74214                Err(err) => {
74215                    if let common::Retry::After(d) = dlg.http_error(&err) {
74216                        sleep(d).await;
74217                        continue;
74218                    }
74219                    dlg.finished(false);
74220                    return Err(common::Error::HttpError(err));
74221                }
74222                Ok(res) => {
74223                    let (mut parts, body) = res.into_parts();
74224                    let mut body = common::Body::new(body);
74225                    if !parts.status.is_success() {
74226                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74227                        let error = serde_json::from_str(&common::to_string(&bytes));
74228                        let response = common::to_response(parts, bytes.into());
74229
74230                        if let common::Retry::After(d) =
74231                            dlg.http_failure(&response, error.as_ref().ok())
74232                        {
74233                            sleep(d).await;
74234                            continue;
74235                        }
74236
74237                        dlg.finished(false);
74238
74239                        return Err(match error {
74240                            Ok(value) => common::Error::BadRequest(value),
74241                            _ => common::Error::Failure(response),
74242                        });
74243                    }
74244                    let response = {
74245                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74246                        let encoded = common::to_string(&bytes);
74247                        match serde_json::from_str(&encoded) {
74248                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
74249                            Err(error) => {
74250                                dlg.response_json_decode_error(&encoded, &error);
74251                                return Err(common::Error::JsonDecodeError(
74252                                    encoded.to_string(),
74253                                    error,
74254                                ));
74255                            }
74256                        }
74257                    };
74258
74259                    dlg.finished(true);
74260                    return Ok(response);
74261                }
74262            }
74263        }
74264    }
74265
74266    /// User profile ID associated with this request.
74267    ///
74268    /// Sets the *profile id* path property to the given value.
74269    ///
74270    /// Even though the property as already been set when instantiating this call,
74271    /// we provide this method for API completeness.
74272    pub fn profile_id(mut self, new_value: i64) -> SizeGetCall<'a, C> {
74273        self._profile_id = new_value;
74274        self
74275    }
74276    /// Size ID.
74277    ///
74278    /// Sets the *id* path property to the given value.
74279    ///
74280    /// Even though the property as already been set when instantiating this call,
74281    /// we provide this method for API completeness.
74282    pub fn id(mut self, new_value: i64) -> SizeGetCall<'a, C> {
74283        self._id = new_value;
74284        self
74285    }
74286    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
74287    /// while executing the actual API request.
74288    ///
74289    /// ````text
74290    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
74291    /// ````
74292    ///
74293    /// Sets the *delegate* property to the given value.
74294    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SizeGetCall<'a, C> {
74295        self._delegate = Some(new_value);
74296        self
74297    }
74298
74299    /// Set any additional parameter of the query string used in the request.
74300    /// It should be used to set parameters which are not yet available through their own
74301    /// setters.
74302    ///
74303    /// Please note that this method must not be used to set any of the known parameters
74304    /// which have their own setter method. If done anyway, the request will fail.
74305    ///
74306    /// # Additional Parameters
74307    ///
74308    /// * *alt* (query-string) - Data format for the response.
74309    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
74310    /// * *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.
74311    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
74312    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
74313    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
74314    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
74315    pub fn param<T>(mut self, name: T, value: T) -> SizeGetCall<'a, C>
74316    where
74317        T: AsRef<str>,
74318    {
74319        self._additional_params
74320            .insert(name.as_ref().to_string(), value.as_ref().to_string());
74321        self
74322    }
74323
74324    /// Identifies the authorization scope for the method you are building.
74325    ///
74326    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
74327    /// [`Scope::Dfatrafficking`].
74328    ///
74329    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
74330    /// tokens for more than one scope.
74331    ///
74332    /// Usually there is more than one suitable scope to authorize an operation, some of which may
74333    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
74334    /// sufficient, a read-write scope will do as well.
74335    pub fn add_scope<St>(mut self, scope: St) -> SizeGetCall<'a, C>
74336    where
74337        St: AsRef<str>,
74338    {
74339        self._scopes.insert(String::from(scope.as_ref()));
74340        self
74341    }
74342    /// Identifies the authorization scope(s) for the method you are building.
74343    ///
74344    /// See [`Self::add_scope()`] for details.
74345    pub fn add_scopes<I, St>(mut self, scopes: I) -> SizeGetCall<'a, C>
74346    where
74347        I: IntoIterator<Item = St>,
74348        St: AsRef<str>,
74349    {
74350        self._scopes
74351            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
74352        self
74353    }
74354
74355    /// Removes all scopes, and no default scope will be used either.
74356    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
74357    /// for details).
74358    pub fn clear_scopes(mut self) -> SizeGetCall<'a, C> {
74359        self._scopes.clear();
74360        self
74361    }
74362}
74363
74364/// Inserts a new size.
74365///
74366/// A builder for the *insert* method supported by a *size* resource.
74367/// It is not used directly, but through a [`SizeMethods`] instance.
74368///
74369/// # Example
74370///
74371/// Instantiate a resource method builder
74372///
74373/// ```test_harness,no_run
74374/// # extern crate hyper;
74375/// # extern crate hyper_rustls;
74376/// # extern crate google_dfareporting3d2 as dfareporting3d2;
74377/// use dfareporting3d2::api::Size;
74378/// # async fn dox() {
74379/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
74380///
74381/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
74382/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
74383/// #     secret,
74384/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
74385/// # ).build().await.unwrap();
74386///
74387/// # let client = hyper_util::client::legacy::Client::builder(
74388/// #     hyper_util::rt::TokioExecutor::new()
74389/// # )
74390/// # .build(
74391/// #     hyper_rustls::HttpsConnectorBuilder::new()
74392/// #         .with_native_roots()
74393/// #         .unwrap()
74394/// #         .https_or_http()
74395/// #         .enable_http1()
74396/// #         .build()
74397/// # );
74398/// # let mut hub = Dfareporting::new(client, auth);
74399/// // As the method needs a request, you would usually fill it with the desired information
74400/// // into the respective structure. Some of the parts shown here might not be applicable !
74401/// // Values shown here are possibly random and not representative !
74402/// let mut req = Size::default();
74403///
74404/// // You can configure optional parameters by calling the respective setters at will, and
74405/// // execute the final call using `doit()`.
74406/// // Values shown here are possibly random and not representative !
74407/// let result = hub.sizes().insert(req, -3)
74408///              .doit().await;
74409/// # }
74410/// ```
74411pub struct SizeInsertCall<'a, C>
74412where
74413    C: 'a,
74414{
74415    hub: &'a Dfareporting<C>,
74416    _request: Size,
74417    _profile_id: i64,
74418    _delegate: Option<&'a mut dyn common::Delegate>,
74419    _additional_params: HashMap<String, String>,
74420    _scopes: BTreeSet<String>,
74421}
74422
74423impl<'a, C> common::CallBuilder for SizeInsertCall<'a, C> {}
74424
74425impl<'a, C> SizeInsertCall<'a, C>
74426where
74427    C: common::Connector,
74428{
74429    /// Perform the operation you have build so far.
74430    pub async fn doit(mut self) -> common::Result<(common::Response, Size)> {
74431        use std::borrow::Cow;
74432        use std::io::{Read, Seek};
74433
74434        use common::{url::Params, ToParts};
74435        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
74436
74437        let mut dd = common::DefaultDelegate;
74438        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
74439        dlg.begin(common::MethodInfo {
74440            id: "dfareporting.sizes.insert",
74441            http_method: hyper::Method::POST,
74442        });
74443
74444        for &field in ["alt", "profileId"].iter() {
74445            if self._additional_params.contains_key(field) {
74446                dlg.finished(false);
74447                return Err(common::Error::FieldClash(field));
74448            }
74449        }
74450
74451        let mut params = Params::with_capacity(4 + self._additional_params.len());
74452        params.push("profileId", self._profile_id.to_string());
74453
74454        params.extend(self._additional_params.iter());
74455
74456        params.push("alt", "json");
74457        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes";
74458        if self._scopes.is_empty() {
74459            self._scopes
74460                .insert(Scope::Dfatrafficking.as_ref().to_string());
74461        }
74462
74463        #[allow(clippy::single_element_loop)]
74464        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
74465            url = params.uri_replacement(url, param_name, find_this, false);
74466        }
74467        {
74468            let to_remove = ["profileId"];
74469            params.remove_params(&to_remove);
74470        }
74471
74472        let url = params.parse_with_url(&url);
74473
74474        let mut json_mime_type = mime::APPLICATION_JSON;
74475        let mut request_value_reader = {
74476            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
74477            common::remove_json_null_values(&mut value);
74478            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
74479            serde_json::to_writer(&mut dst, &value).unwrap();
74480            dst
74481        };
74482        let request_size = request_value_reader
74483            .seek(std::io::SeekFrom::End(0))
74484            .unwrap();
74485        request_value_reader
74486            .seek(std::io::SeekFrom::Start(0))
74487            .unwrap();
74488
74489        loop {
74490            let token = match self
74491                .hub
74492                .auth
74493                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
74494                .await
74495            {
74496                Ok(token) => token,
74497                Err(e) => match dlg.token(e) {
74498                    Ok(token) => token,
74499                    Err(e) => {
74500                        dlg.finished(false);
74501                        return Err(common::Error::MissingToken(e));
74502                    }
74503                },
74504            };
74505            request_value_reader
74506                .seek(std::io::SeekFrom::Start(0))
74507                .unwrap();
74508            let mut req_result = {
74509                let client = &self.hub.client;
74510                dlg.pre_request();
74511                let mut req_builder = hyper::Request::builder()
74512                    .method(hyper::Method::POST)
74513                    .uri(url.as_str())
74514                    .header(USER_AGENT, self.hub._user_agent.clone());
74515
74516                if let Some(token) = token.as_ref() {
74517                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
74518                }
74519
74520                let request = req_builder
74521                    .header(CONTENT_TYPE, json_mime_type.to_string())
74522                    .header(CONTENT_LENGTH, request_size as u64)
74523                    .body(common::to_body(
74524                        request_value_reader.get_ref().clone().into(),
74525                    ));
74526
74527                client.request(request.unwrap()).await
74528            };
74529
74530            match req_result {
74531                Err(err) => {
74532                    if let common::Retry::After(d) = dlg.http_error(&err) {
74533                        sleep(d).await;
74534                        continue;
74535                    }
74536                    dlg.finished(false);
74537                    return Err(common::Error::HttpError(err));
74538                }
74539                Ok(res) => {
74540                    let (mut parts, body) = res.into_parts();
74541                    let mut body = common::Body::new(body);
74542                    if !parts.status.is_success() {
74543                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74544                        let error = serde_json::from_str(&common::to_string(&bytes));
74545                        let response = common::to_response(parts, bytes.into());
74546
74547                        if let common::Retry::After(d) =
74548                            dlg.http_failure(&response, error.as_ref().ok())
74549                        {
74550                            sleep(d).await;
74551                            continue;
74552                        }
74553
74554                        dlg.finished(false);
74555
74556                        return Err(match error {
74557                            Ok(value) => common::Error::BadRequest(value),
74558                            _ => common::Error::Failure(response),
74559                        });
74560                    }
74561                    let response = {
74562                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74563                        let encoded = common::to_string(&bytes);
74564                        match serde_json::from_str(&encoded) {
74565                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
74566                            Err(error) => {
74567                                dlg.response_json_decode_error(&encoded, &error);
74568                                return Err(common::Error::JsonDecodeError(
74569                                    encoded.to_string(),
74570                                    error,
74571                                ));
74572                            }
74573                        }
74574                    };
74575
74576                    dlg.finished(true);
74577                    return Ok(response);
74578                }
74579            }
74580        }
74581    }
74582
74583    ///
74584    /// Sets the *request* property to the given value.
74585    ///
74586    /// Even though the property as already been set when instantiating this call,
74587    /// we provide this method for API completeness.
74588    pub fn request(mut self, new_value: Size) -> SizeInsertCall<'a, C> {
74589        self._request = new_value;
74590        self
74591    }
74592    /// User profile ID associated with this request.
74593    ///
74594    /// Sets the *profile id* path property to the given value.
74595    ///
74596    /// Even though the property as already been set when instantiating this call,
74597    /// we provide this method for API completeness.
74598    pub fn profile_id(mut self, new_value: i64) -> SizeInsertCall<'a, C> {
74599        self._profile_id = new_value;
74600        self
74601    }
74602    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
74603    /// while executing the actual API request.
74604    ///
74605    /// ````text
74606    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
74607    /// ````
74608    ///
74609    /// Sets the *delegate* property to the given value.
74610    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SizeInsertCall<'a, C> {
74611        self._delegate = Some(new_value);
74612        self
74613    }
74614
74615    /// Set any additional parameter of the query string used in the request.
74616    /// It should be used to set parameters which are not yet available through their own
74617    /// setters.
74618    ///
74619    /// Please note that this method must not be used to set any of the known parameters
74620    /// which have their own setter method. If done anyway, the request will fail.
74621    ///
74622    /// # Additional Parameters
74623    ///
74624    /// * *alt* (query-string) - Data format for the response.
74625    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
74626    /// * *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.
74627    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
74628    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
74629    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
74630    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
74631    pub fn param<T>(mut self, name: T, value: T) -> SizeInsertCall<'a, C>
74632    where
74633        T: AsRef<str>,
74634    {
74635        self._additional_params
74636            .insert(name.as_ref().to_string(), value.as_ref().to_string());
74637        self
74638    }
74639
74640    /// Identifies the authorization scope for the method you are building.
74641    ///
74642    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
74643    /// [`Scope::Dfatrafficking`].
74644    ///
74645    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
74646    /// tokens for more than one scope.
74647    ///
74648    /// Usually there is more than one suitable scope to authorize an operation, some of which may
74649    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
74650    /// sufficient, a read-write scope will do as well.
74651    pub fn add_scope<St>(mut self, scope: St) -> SizeInsertCall<'a, C>
74652    where
74653        St: AsRef<str>,
74654    {
74655        self._scopes.insert(String::from(scope.as_ref()));
74656        self
74657    }
74658    /// Identifies the authorization scope(s) for the method you are building.
74659    ///
74660    /// See [`Self::add_scope()`] for details.
74661    pub fn add_scopes<I, St>(mut self, scopes: I) -> SizeInsertCall<'a, C>
74662    where
74663        I: IntoIterator<Item = St>,
74664        St: AsRef<str>,
74665    {
74666        self._scopes
74667            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
74668        self
74669    }
74670
74671    /// Removes all scopes, and no default scope will be used either.
74672    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
74673    /// for details).
74674    pub fn clear_scopes(mut self) -> SizeInsertCall<'a, C> {
74675        self._scopes.clear();
74676        self
74677    }
74678}
74679
74680/// Retrieves a list of sizes, possibly filtered. Retrieved sizes are globally unique and may include values not currently in use by your account. Due to this, the list of sizes returned by this method may differ from the list seen in the Trafficking UI.
74681///
74682/// A builder for the *list* method supported by a *size* resource.
74683/// It is not used directly, but through a [`SizeMethods`] instance.
74684///
74685/// # Example
74686///
74687/// Instantiate a resource method builder
74688///
74689/// ```test_harness,no_run
74690/// # extern crate hyper;
74691/// # extern crate hyper_rustls;
74692/// # extern crate google_dfareporting3d2 as dfareporting3d2;
74693/// # async fn dox() {
74694/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
74695///
74696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
74697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
74698/// #     secret,
74699/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
74700/// # ).build().await.unwrap();
74701///
74702/// # let client = hyper_util::client::legacy::Client::builder(
74703/// #     hyper_util::rt::TokioExecutor::new()
74704/// # )
74705/// # .build(
74706/// #     hyper_rustls::HttpsConnectorBuilder::new()
74707/// #         .with_native_roots()
74708/// #         .unwrap()
74709/// #         .https_or_http()
74710/// #         .enable_http1()
74711/// #         .build()
74712/// # );
74713/// # let mut hub = Dfareporting::new(client, auth);
74714/// // You can configure optional parameters by calling the respective setters at will, and
74715/// // execute the final call using `doit()`.
74716/// // Values shown here are possibly random and not representative !
74717/// let result = hub.sizes().list(-98)
74718///              .width(-88)
74719///              .add_ids(-94)
74720///              .iab_standard(false)
74721///              .height(-2)
74722///              .doit().await;
74723/// # }
74724/// ```
74725pub struct SizeListCall<'a, C>
74726where
74727    C: 'a,
74728{
74729    hub: &'a Dfareporting<C>,
74730    _profile_id: i64,
74731    _width: Option<i32>,
74732    _ids: Vec<i64>,
74733    _iab_standard: Option<bool>,
74734    _height: Option<i32>,
74735    _delegate: Option<&'a mut dyn common::Delegate>,
74736    _additional_params: HashMap<String, String>,
74737    _scopes: BTreeSet<String>,
74738}
74739
74740impl<'a, C> common::CallBuilder for SizeListCall<'a, C> {}
74741
74742impl<'a, C> SizeListCall<'a, C>
74743where
74744    C: common::Connector,
74745{
74746    /// Perform the operation you have build so far.
74747    pub async fn doit(mut self) -> common::Result<(common::Response, SizesListResponse)> {
74748        use std::borrow::Cow;
74749        use std::io::{Read, Seek};
74750
74751        use common::{url::Params, ToParts};
74752        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
74753
74754        let mut dd = common::DefaultDelegate;
74755        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
74756        dlg.begin(common::MethodInfo {
74757            id: "dfareporting.sizes.list",
74758            http_method: hyper::Method::GET,
74759        });
74760
74761        for &field in ["alt", "profileId", "width", "ids", "iabStandard", "height"].iter() {
74762            if self._additional_params.contains_key(field) {
74763                dlg.finished(false);
74764                return Err(common::Error::FieldClash(field));
74765            }
74766        }
74767
74768        let mut params = Params::with_capacity(7 + self._additional_params.len());
74769        params.push("profileId", self._profile_id.to_string());
74770        if let Some(value) = self._width.as_ref() {
74771            params.push("width", value.to_string());
74772        }
74773        if !self._ids.is_empty() {
74774            for f in self._ids.iter() {
74775                params.push("ids", f.to_string());
74776            }
74777        }
74778        if let Some(value) = self._iab_standard.as_ref() {
74779            params.push("iabStandard", value.to_string());
74780        }
74781        if let Some(value) = self._height.as_ref() {
74782            params.push("height", value.to_string());
74783        }
74784
74785        params.extend(self._additional_params.iter());
74786
74787        params.push("alt", "json");
74788        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes";
74789        if self._scopes.is_empty() {
74790            self._scopes
74791                .insert(Scope::Dfatrafficking.as_ref().to_string());
74792        }
74793
74794        #[allow(clippy::single_element_loop)]
74795        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
74796            url = params.uri_replacement(url, param_name, find_this, false);
74797        }
74798        {
74799            let to_remove = ["profileId"];
74800            params.remove_params(&to_remove);
74801        }
74802
74803        let url = params.parse_with_url(&url);
74804
74805        loop {
74806            let token = match self
74807                .hub
74808                .auth
74809                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
74810                .await
74811            {
74812                Ok(token) => token,
74813                Err(e) => match dlg.token(e) {
74814                    Ok(token) => token,
74815                    Err(e) => {
74816                        dlg.finished(false);
74817                        return Err(common::Error::MissingToken(e));
74818                    }
74819                },
74820            };
74821            let mut req_result = {
74822                let client = &self.hub.client;
74823                dlg.pre_request();
74824                let mut req_builder = hyper::Request::builder()
74825                    .method(hyper::Method::GET)
74826                    .uri(url.as_str())
74827                    .header(USER_AGENT, self.hub._user_agent.clone());
74828
74829                if let Some(token) = token.as_ref() {
74830                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
74831                }
74832
74833                let request = req_builder
74834                    .header(CONTENT_LENGTH, 0_u64)
74835                    .body(common::to_body::<String>(None));
74836
74837                client.request(request.unwrap()).await
74838            };
74839
74840            match req_result {
74841                Err(err) => {
74842                    if let common::Retry::After(d) = dlg.http_error(&err) {
74843                        sleep(d).await;
74844                        continue;
74845                    }
74846                    dlg.finished(false);
74847                    return Err(common::Error::HttpError(err));
74848                }
74849                Ok(res) => {
74850                    let (mut parts, body) = res.into_parts();
74851                    let mut body = common::Body::new(body);
74852                    if !parts.status.is_success() {
74853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74854                        let error = serde_json::from_str(&common::to_string(&bytes));
74855                        let response = common::to_response(parts, bytes.into());
74856
74857                        if let common::Retry::After(d) =
74858                            dlg.http_failure(&response, error.as_ref().ok())
74859                        {
74860                            sleep(d).await;
74861                            continue;
74862                        }
74863
74864                        dlg.finished(false);
74865
74866                        return Err(match error {
74867                            Ok(value) => common::Error::BadRequest(value),
74868                            _ => common::Error::Failure(response),
74869                        });
74870                    }
74871                    let response = {
74872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
74873                        let encoded = common::to_string(&bytes);
74874                        match serde_json::from_str(&encoded) {
74875                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
74876                            Err(error) => {
74877                                dlg.response_json_decode_error(&encoded, &error);
74878                                return Err(common::Error::JsonDecodeError(
74879                                    encoded.to_string(),
74880                                    error,
74881                                ));
74882                            }
74883                        }
74884                    };
74885
74886                    dlg.finished(true);
74887                    return Ok(response);
74888                }
74889            }
74890        }
74891    }
74892
74893    /// User profile ID associated with this request.
74894    ///
74895    /// Sets the *profile id* path property to the given value.
74896    ///
74897    /// Even though the property as already been set when instantiating this call,
74898    /// we provide this method for API completeness.
74899    pub fn profile_id(mut self, new_value: i64) -> SizeListCall<'a, C> {
74900        self._profile_id = new_value;
74901        self
74902    }
74903    /// Select only sizes with this width.
74904    ///
74905    /// Sets the *width* query property to the given value.
74906    pub fn width(mut self, new_value: i32) -> SizeListCall<'a, C> {
74907        self._width = Some(new_value);
74908        self
74909    }
74910    /// Select only sizes with these IDs.
74911    ///
74912    /// Append the given value to the *ids* query property.
74913    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
74914    pub fn add_ids(mut self, new_value: i64) -> SizeListCall<'a, C> {
74915        self._ids.push(new_value);
74916        self
74917    }
74918    /// Select only IAB standard sizes.
74919    ///
74920    /// Sets the *iab standard* query property to the given value.
74921    pub fn iab_standard(mut self, new_value: bool) -> SizeListCall<'a, C> {
74922        self._iab_standard = Some(new_value);
74923        self
74924    }
74925    /// Select only sizes with this height.
74926    ///
74927    /// Sets the *height* query property to the given value.
74928    pub fn height(mut self, new_value: i32) -> SizeListCall<'a, C> {
74929        self._height = Some(new_value);
74930        self
74931    }
74932    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
74933    /// while executing the actual API request.
74934    ///
74935    /// ````text
74936    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
74937    /// ````
74938    ///
74939    /// Sets the *delegate* property to the given value.
74940    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SizeListCall<'a, C> {
74941        self._delegate = Some(new_value);
74942        self
74943    }
74944
74945    /// Set any additional parameter of the query string used in the request.
74946    /// It should be used to set parameters which are not yet available through their own
74947    /// setters.
74948    ///
74949    /// Please note that this method must not be used to set any of the known parameters
74950    /// which have their own setter method. If done anyway, the request will fail.
74951    ///
74952    /// # Additional Parameters
74953    ///
74954    /// * *alt* (query-string) - Data format for the response.
74955    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
74956    /// * *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.
74957    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
74958    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
74959    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
74960    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
74961    pub fn param<T>(mut self, name: T, value: T) -> SizeListCall<'a, C>
74962    where
74963        T: AsRef<str>,
74964    {
74965        self._additional_params
74966            .insert(name.as_ref().to_string(), value.as_ref().to_string());
74967        self
74968    }
74969
74970    /// Identifies the authorization scope for the method you are building.
74971    ///
74972    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
74973    /// [`Scope::Dfatrafficking`].
74974    ///
74975    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
74976    /// tokens for more than one scope.
74977    ///
74978    /// Usually there is more than one suitable scope to authorize an operation, some of which may
74979    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
74980    /// sufficient, a read-write scope will do as well.
74981    pub fn add_scope<St>(mut self, scope: St) -> SizeListCall<'a, C>
74982    where
74983        St: AsRef<str>,
74984    {
74985        self._scopes.insert(String::from(scope.as_ref()));
74986        self
74987    }
74988    /// Identifies the authorization scope(s) for the method you are building.
74989    ///
74990    /// See [`Self::add_scope()`] for details.
74991    pub fn add_scopes<I, St>(mut self, scopes: I) -> SizeListCall<'a, C>
74992    where
74993        I: IntoIterator<Item = St>,
74994        St: AsRef<str>,
74995    {
74996        self._scopes
74997            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
74998        self
74999    }
75000
75001    /// Removes all scopes, and no default scope will be used either.
75002    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
75003    /// for details).
75004    pub fn clear_scopes(mut self) -> SizeListCall<'a, C> {
75005        self._scopes.clear();
75006        self
75007    }
75008}
75009
75010/// Gets one subaccount by ID.
75011///
75012/// A builder for the *get* method supported by a *subaccount* resource.
75013/// It is not used directly, but through a [`SubaccountMethods`] instance.
75014///
75015/// # Example
75016///
75017/// Instantiate a resource method builder
75018///
75019/// ```test_harness,no_run
75020/// # extern crate hyper;
75021/// # extern crate hyper_rustls;
75022/// # extern crate google_dfareporting3d2 as dfareporting3d2;
75023/// # async fn dox() {
75024/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
75025///
75026/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
75027/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
75028/// #     secret,
75029/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
75030/// # ).build().await.unwrap();
75031///
75032/// # let client = hyper_util::client::legacy::Client::builder(
75033/// #     hyper_util::rt::TokioExecutor::new()
75034/// # )
75035/// # .build(
75036/// #     hyper_rustls::HttpsConnectorBuilder::new()
75037/// #         .with_native_roots()
75038/// #         .unwrap()
75039/// #         .https_or_http()
75040/// #         .enable_http1()
75041/// #         .build()
75042/// # );
75043/// # let mut hub = Dfareporting::new(client, auth);
75044/// // You can configure optional parameters by calling the respective setters at will, and
75045/// // execute the final call using `doit()`.
75046/// // Values shown here are possibly random and not representative !
75047/// let result = hub.subaccounts().get(-82, -72)
75048///              .doit().await;
75049/// # }
75050/// ```
75051pub struct SubaccountGetCall<'a, C>
75052where
75053    C: 'a,
75054{
75055    hub: &'a Dfareporting<C>,
75056    _profile_id: i64,
75057    _id: i64,
75058    _delegate: Option<&'a mut dyn common::Delegate>,
75059    _additional_params: HashMap<String, String>,
75060    _scopes: BTreeSet<String>,
75061}
75062
75063impl<'a, C> common::CallBuilder for SubaccountGetCall<'a, C> {}
75064
75065impl<'a, C> SubaccountGetCall<'a, C>
75066where
75067    C: common::Connector,
75068{
75069    /// Perform the operation you have build so far.
75070    pub async fn doit(mut self) -> common::Result<(common::Response, Subaccount)> {
75071        use std::borrow::Cow;
75072        use std::io::{Read, Seek};
75073
75074        use common::{url::Params, ToParts};
75075        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
75076
75077        let mut dd = common::DefaultDelegate;
75078        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
75079        dlg.begin(common::MethodInfo {
75080            id: "dfareporting.subaccounts.get",
75081            http_method: hyper::Method::GET,
75082        });
75083
75084        for &field in ["alt", "profileId", "id"].iter() {
75085            if self._additional_params.contains_key(field) {
75086                dlg.finished(false);
75087                return Err(common::Error::FieldClash(field));
75088            }
75089        }
75090
75091        let mut params = Params::with_capacity(4 + self._additional_params.len());
75092        params.push("profileId", self._profile_id.to_string());
75093        params.push("id", self._id.to_string());
75094
75095        params.extend(self._additional_params.iter());
75096
75097        params.push("alt", "json");
75098        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts/{id}";
75099        if self._scopes.is_empty() {
75100            self._scopes
75101                .insert(Scope::Dfatrafficking.as_ref().to_string());
75102        }
75103
75104        #[allow(clippy::single_element_loop)]
75105        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
75106            url = params.uri_replacement(url, param_name, find_this, false);
75107        }
75108        {
75109            let to_remove = ["id", "profileId"];
75110            params.remove_params(&to_remove);
75111        }
75112
75113        let url = params.parse_with_url(&url);
75114
75115        loop {
75116            let token = match self
75117                .hub
75118                .auth
75119                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
75120                .await
75121            {
75122                Ok(token) => token,
75123                Err(e) => match dlg.token(e) {
75124                    Ok(token) => token,
75125                    Err(e) => {
75126                        dlg.finished(false);
75127                        return Err(common::Error::MissingToken(e));
75128                    }
75129                },
75130            };
75131            let mut req_result = {
75132                let client = &self.hub.client;
75133                dlg.pre_request();
75134                let mut req_builder = hyper::Request::builder()
75135                    .method(hyper::Method::GET)
75136                    .uri(url.as_str())
75137                    .header(USER_AGENT, self.hub._user_agent.clone());
75138
75139                if let Some(token) = token.as_ref() {
75140                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
75141                }
75142
75143                let request = req_builder
75144                    .header(CONTENT_LENGTH, 0_u64)
75145                    .body(common::to_body::<String>(None));
75146
75147                client.request(request.unwrap()).await
75148            };
75149
75150            match req_result {
75151                Err(err) => {
75152                    if let common::Retry::After(d) = dlg.http_error(&err) {
75153                        sleep(d).await;
75154                        continue;
75155                    }
75156                    dlg.finished(false);
75157                    return Err(common::Error::HttpError(err));
75158                }
75159                Ok(res) => {
75160                    let (mut parts, body) = res.into_parts();
75161                    let mut body = common::Body::new(body);
75162                    if !parts.status.is_success() {
75163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75164                        let error = serde_json::from_str(&common::to_string(&bytes));
75165                        let response = common::to_response(parts, bytes.into());
75166
75167                        if let common::Retry::After(d) =
75168                            dlg.http_failure(&response, error.as_ref().ok())
75169                        {
75170                            sleep(d).await;
75171                            continue;
75172                        }
75173
75174                        dlg.finished(false);
75175
75176                        return Err(match error {
75177                            Ok(value) => common::Error::BadRequest(value),
75178                            _ => common::Error::Failure(response),
75179                        });
75180                    }
75181                    let response = {
75182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75183                        let encoded = common::to_string(&bytes);
75184                        match serde_json::from_str(&encoded) {
75185                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
75186                            Err(error) => {
75187                                dlg.response_json_decode_error(&encoded, &error);
75188                                return Err(common::Error::JsonDecodeError(
75189                                    encoded.to_string(),
75190                                    error,
75191                                ));
75192                            }
75193                        }
75194                    };
75195
75196                    dlg.finished(true);
75197                    return Ok(response);
75198                }
75199            }
75200        }
75201    }
75202
75203    /// User profile ID associated with this request.
75204    ///
75205    /// Sets the *profile id* path property to the given value.
75206    ///
75207    /// Even though the property as already been set when instantiating this call,
75208    /// we provide this method for API completeness.
75209    pub fn profile_id(mut self, new_value: i64) -> SubaccountGetCall<'a, C> {
75210        self._profile_id = new_value;
75211        self
75212    }
75213    /// Subaccount ID.
75214    ///
75215    /// Sets the *id* path property to the given value.
75216    ///
75217    /// Even though the property as already been set when instantiating this call,
75218    /// we provide this method for API completeness.
75219    pub fn id(mut self, new_value: i64) -> SubaccountGetCall<'a, C> {
75220        self._id = new_value;
75221        self
75222    }
75223    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
75224    /// while executing the actual API request.
75225    ///
75226    /// ````text
75227    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
75228    /// ````
75229    ///
75230    /// Sets the *delegate* property to the given value.
75231    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SubaccountGetCall<'a, C> {
75232        self._delegate = Some(new_value);
75233        self
75234    }
75235
75236    /// Set any additional parameter of the query string used in the request.
75237    /// It should be used to set parameters which are not yet available through their own
75238    /// setters.
75239    ///
75240    /// Please note that this method must not be used to set any of the known parameters
75241    /// which have their own setter method. If done anyway, the request will fail.
75242    ///
75243    /// # Additional Parameters
75244    ///
75245    /// * *alt* (query-string) - Data format for the response.
75246    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
75247    /// * *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.
75248    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
75249    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
75250    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
75251    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
75252    pub fn param<T>(mut self, name: T, value: T) -> SubaccountGetCall<'a, C>
75253    where
75254        T: AsRef<str>,
75255    {
75256        self._additional_params
75257            .insert(name.as_ref().to_string(), value.as_ref().to_string());
75258        self
75259    }
75260
75261    /// Identifies the authorization scope for the method you are building.
75262    ///
75263    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
75264    /// [`Scope::Dfatrafficking`].
75265    ///
75266    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
75267    /// tokens for more than one scope.
75268    ///
75269    /// Usually there is more than one suitable scope to authorize an operation, some of which may
75270    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
75271    /// sufficient, a read-write scope will do as well.
75272    pub fn add_scope<St>(mut self, scope: St) -> SubaccountGetCall<'a, C>
75273    where
75274        St: AsRef<str>,
75275    {
75276        self._scopes.insert(String::from(scope.as_ref()));
75277        self
75278    }
75279    /// Identifies the authorization scope(s) for the method you are building.
75280    ///
75281    /// See [`Self::add_scope()`] for details.
75282    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubaccountGetCall<'a, C>
75283    where
75284        I: IntoIterator<Item = St>,
75285        St: AsRef<str>,
75286    {
75287        self._scopes
75288            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
75289        self
75290    }
75291
75292    /// Removes all scopes, and no default scope will be used either.
75293    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
75294    /// for details).
75295    pub fn clear_scopes(mut self) -> SubaccountGetCall<'a, C> {
75296        self._scopes.clear();
75297        self
75298    }
75299}
75300
75301/// Inserts a new subaccount.
75302///
75303/// A builder for the *insert* method supported by a *subaccount* resource.
75304/// It is not used directly, but through a [`SubaccountMethods`] instance.
75305///
75306/// # Example
75307///
75308/// Instantiate a resource method builder
75309///
75310/// ```test_harness,no_run
75311/// # extern crate hyper;
75312/// # extern crate hyper_rustls;
75313/// # extern crate google_dfareporting3d2 as dfareporting3d2;
75314/// use dfareporting3d2::api::Subaccount;
75315/// # async fn dox() {
75316/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
75317///
75318/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
75319/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
75320/// #     secret,
75321/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
75322/// # ).build().await.unwrap();
75323///
75324/// # let client = hyper_util::client::legacy::Client::builder(
75325/// #     hyper_util::rt::TokioExecutor::new()
75326/// # )
75327/// # .build(
75328/// #     hyper_rustls::HttpsConnectorBuilder::new()
75329/// #         .with_native_roots()
75330/// #         .unwrap()
75331/// #         .https_or_http()
75332/// #         .enable_http1()
75333/// #         .build()
75334/// # );
75335/// # let mut hub = Dfareporting::new(client, auth);
75336/// // As the method needs a request, you would usually fill it with the desired information
75337/// // into the respective structure. Some of the parts shown here might not be applicable !
75338/// // Values shown here are possibly random and not representative !
75339/// let mut req = Subaccount::default();
75340///
75341/// // You can configure optional parameters by calling the respective setters at will, and
75342/// // execute the final call using `doit()`.
75343/// // Values shown here are possibly random and not representative !
75344/// let result = hub.subaccounts().insert(req, -12)
75345///              .doit().await;
75346/// # }
75347/// ```
75348pub struct SubaccountInsertCall<'a, C>
75349where
75350    C: 'a,
75351{
75352    hub: &'a Dfareporting<C>,
75353    _request: Subaccount,
75354    _profile_id: i64,
75355    _delegate: Option<&'a mut dyn common::Delegate>,
75356    _additional_params: HashMap<String, String>,
75357    _scopes: BTreeSet<String>,
75358}
75359
75360impl<'a, C> common::CallBuilder for SubaccountInsertCall<'a, C> {}
75361
75362impl<'a, C> SubaccountInsertCall<'a, C>
75363where
75364    C: common::Connector,
75365{
75366    /// Perform the operation you have build so far.
75367    pub async fn doit(mut self) -> common::Result<(common::Response, Subaccount)> {
75368        use std::borrow::Cow;
75369        use std::io::{Read, Seek};
75370
75371        use common::{url::Params, ToParts};
75372        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
75373
75374        let mut dd = common::DefaultDelegate;
75375        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
75376        dlg.begin(common::MethodInfo {
75377            id: "dfareporting.subaccounts.insert",
75378            http_method: hyper::Method::POST,
75379        });
75380
75381        for &field in ["alt", "profileId"].iter() {
75382            if self._additional_params.contains_key(field) {
75383                dlg.finished(false);
75384                return Err(common::Error::FieldClash(field));
75385            }
75386        }
75387
75388        let mut params = Params::with_capacity(4 + self._additional_params.len());
75389        params.push("profileId", self._profile_id.to_string());
75390
75391        params.extend(self._additional_params.iter());
75392
75393        params.push("alt", "json");
75394        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts";
75395        if self._scopes.is_empty() {
75396            self._scopes
75397                .insert(Scope::Dfatrafficking.as_ref().to_string());
75398        }
75399
75400        #[allow(clippy::single_element_loop)]
75401        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
75402            url = params.uri_replacement(url, param_name, find_this, false);
75403        }
75404        {
75405            let to_remove = ["profileId"];
75406            params.remove_params(&to_remove);
75407        }
75408
75409        let url = params.parse_with_url(&url);
75410
75411        let mut json_mime_type = mime::APPLICATION_JSON;
75412        let mut request_value_reader = {
75413            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
75414            common::remove_json_null_values(&mut value);
75415            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
75416            serde_json::to_writer(&mut dst, &value).unwrap();
75417            dst
75418        };
75419        let request_size = request_value_reader
75420            .seek(std::io::SeekFrom::End(0))
75421            .unwrap();
75422        request_value_reader
75423            .seek(std::io::SeekFrom::Start(0))
75424            .unwrap();
75425
75426        loop {
75427            let token = match self
75428                .hub
75429                .auth
75430                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
75431                .await
75432            {
75433                Ok(token) => token,
75434                Err(e) => match dlg.token(e) {
75435                    Ok(token) => token,
75436                    Err(e) => {
75437                        dlg.finished(false);
75438                        return Err(common::Error::MissingToken(e));
75439                    }
75440                },
75441            };
75442            request_value_reader
75443                .seek(std::io::SeekFrom::Start(0))
75444                .unwrap();
75445            let mut req_result = {
75446                let client = &self.hub.client;
75447                dlg.pre_request();
75448                let mut req_builder = hyper::Request::builder()
75449                    .method(hyper::Method::POST)
75450                    .uri(url.as_str())
75451                    .header(USER_AGENT, self.hub._user_agent.clone());
75452
75453                if let Some(token) = token.as_ref() {
75454                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
75455                }
75456
75457                let request = req_builder
75458                    .header(CONTENT_TYPE, json_mime_type.to_string())
75459                    .header(CONTENT_LENGTH, request_size as u64)
75460                    .body(common::to_body(
75461                        request_value_reader.get_ref().clone().into(),
75462                    ));
75463
75464                client.request(request.unwrap()).await
75465            };
75466
75467            match req_result {
75468                Err(err) => {
75469                    if let common::Retry::After(d) = dlg.http_error(&err) {
75470                        sleep(d).await;
75471                        continue;
75472                    }
75473                    dlg.finished(false);
75474                    return Err(common::Error::HttpError(err));
75475                }
75476                Ok(res) => {
75477                    let (mut parts, body) = res.into_parts();
75478                    let mut body = common::Body::new(body);
75479                    if !parts.status.is_success() {
75480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75481                        let error = serde_json::from_str(&common::to_string(&bytes));
75482                        let response = common::to_response(parts, bytes.into());
75483
75484                        if let common::Retry::After(d) =
75485                            dlg.http_failure(&response, error.as_ref().ok())
75486                        {
75487                            sleep(d).await;
75488                            continue;
75489                        }
75490
75491                        dlg.finished(false);
75492
75493                        return Err(match error {
75494                            Ok(value) => common::Error::BadRequest(value),
75495                            _ => common::Error::Failure(response),
75496                        });
75497                    }
75498                    let response = {
75499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75500                        let encoded = common::to_string(&bytes);
75501                        match serde_json::from_str(&encoded) {
75502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
75503                            Err(error) => {
75504                                dlg.response_json_decode_error(&encoded, &error);
75505                                return Err(common::Error::JsonDecodeError(
75506                                    encoded.to_string(),
75507                                    error,
75508                                ));
75509                            }
75510                        }
75511                    };
75512
75513                    dlg.finished(true);
75514                    return Ok(response);
75515                }
75516            }
75517        }
75518    }
75519
75520    ///
75521    /// Sets the *request* property to the given value.
75522    ///
75523    /// Even though the property as already been set when instantiating this call,
75524    /// we provide this method for API completeness.
75525    pub fn request(mut self, new_value: Subaccount) -> SubaccountInsertCall<'a, C> {
75526        self._request = new_value;
75527        self
75528    }
75529    /// User profile ID associated with this request.
75530    ///
75531    /// Sets the *profile id* path property to the given value.
75532    ///
75533    /// Even though the property as already been set when instantiating this call,
75534    /// we provide this method for API completeness.
75535    pub fn profile_id(mut self, new_value: i64) -> SubaccountInsertCall<'a, C> {
75536        self._profile_id = new_value;
75537        self
75538    }
75539    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
75540    /// while executing the actual API request.
75541    ///
75542    /// ````text
75543    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
75544    /// ````
75545    ///
75546    /// Sets the *delegate* property to the given value.
75547    pub fn delegate(
75548        mut self,
75549        new_value: &'a mut dyn common::Delegate,
75550    ) -> SubaccountInsertCall<'a, C> {
75551        self._delegate = Some(new_value);
75552        self
75553    }
75554
75555    /// Set any additional parameter of the query string used in the request.
75556    /// It should be used to set parameters which are not yet available through their own
75557    /// setters.
75558    ///
75559    /// Please note that this method must not be used to set any of the known parameters
75560    /// which have their own setter method. If done anyway, the request will fail.
75561    ///
75562    /// # Additional Parameters
75563    ///
75564    /// * *alt* (query-string) - Data format for the response.
75565    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
75566    /// * *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.
75567    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
75568    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
75569    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
75570    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
75571    pub fn param<T>(mut self, name: T, value: T) -> SubaccountInsertCall<'a, C>
75572    where
75573        T: AsRef<str>,
75574    {
75575        self._additional_params
75576            .insert(name.as_ref().to_string(), value.as_ref().to_string());
75577        self
75578    }
75579
75580    /// Identifies the authorization scope for the method you are building.
75581    ///
75582    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
75583    /// [`Scope::Dfatrafficking`].
75584    ///
75585    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
75586    /// tokens for more than one scope.
75587    ///
75588    /// Usually there is more than one suitable scope to authorize an operation, some of which may
75589    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
75590    /// sufficient, a read-write scope will do as well.
75591    pub fn add_scope<St>(mut self, scope: St) -> SubaccountInsertCall<'a, C>
75592    where
75593        St: AsRef<str>,
75594    {
75595        self._scopes.insert(String::from(scope.as_ref()));
75596        self
75597    }
75598    /// Identifies the authorization scope(s) for the method you are building.
75599    ///
75600    /// See [`Self::add_scope()`] for details.
75601    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubaccountInsertCall<'a, C>
75602    where
75603        I: IntoIterator<Item = St>,
75604        St: AsRef<str>,
75605    {
75606        self._scopes
75607            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
75608        self
75609    }
75610
75611    /// Removes all scopes, and no default scope will be used either.
75612    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
75613    /// for details).
75614    pub fn clear_scopes(mut self) -> SubaccountInsertCall<'a, C> {
75615        self._scopes.clear();
75616        self
75617    }
75618}
75619
75620/// Gets a list of subaccounts, possibly filtered. This method supports paging.
75621///
75622/// A builder for the *list* method supported by a *subaccount* resource.
75623/// It is not used directly, but through a [`SubaccountMethods`] instance.
75624///
75625/// # Example
75626///
75627/// Instantiate a resource method builder
75628///
75629/// ```test_harness,no_run
75630/// # extern crate hyper;
75631/// # extern crate hyper_rustls;
75632/// # extern crate google_dfareporting3d2 as dfareporting3d2;
75633/// # async fn dox() {
75634/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
75635///
75636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
75637/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
75638/// #     secret,
75639/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
75640/// # ).build().await.unwrap();
75641///
75642/// # let client = hyper_util::client::legacy::Client::builder(
75643/// #     hyper_util::rt::TokioExecutor::new()
75644/// # )
75645/// # .build(
75646/// #     hyper_rustls::HttpsConnectorBuilder::new()
75647/// #         .with_native_roots()
75648/// #         .unwrap()
75649/// #         .https_or_http()
75650/// #         .enable_http1()
75651/// #         .build()
75652/// # );
75653/// # let mut hub = Dfareporting::new(client, auth);
75654/// // You can configure optional parameters by calling the respective setters at will, and
75655/// // execute the final call using `doit()`.
75656/// // Values shown here are possibly random and not representative !
75657/// let result = hub.subaccounts().list(-93)
75658///              .sort_order("no")
75659///              .sort_field("sit")
75660///              .search_string("est")
75661///              .page_token("elitr")
75662///              .max_results(-22)
75663///              .add_ids(-96)
75664///              .doit().await;
75665/// # }
75666/// ```
75667pub struct SubaccountListCall<'a, C>
75668where
75669    C: 'a,
75670{
75671    hub: &'a Dfareporting<C>,
75672    _profile_id: i64,
75673    _sort_order: Option<String>,
75674    _sort_field: Option<String>,
75675    _search_string: Option<String>,
75676    _page_token: Option<String>,
75677    _max_results: Option<i32>,
75678    _ids: Vec<i64>,
75679    _delegate: Option<&'a mut dyn common::Delegate>,
75680    _additional_params: HashMap<String, String>,
75681    _scopes: BTreeSet<String>,
75682}
75683
75684impl<'a, C> common::CallBuilder for SubaccountListCall<'a, C> {}
75685
75686impl<'a, C> SubaccountListCall<'a, C>
75687where
75688    C: common::Connector,
75689{
75690    /// Perform the operation you have build so far.
75691    pub async fn doit(mut self) -> common::Result<(common::Response, SubaccountsListResponse)> {
75692        use std::borrow::Cow;
75693        use std::io::{Read, Seek};
75694
75695        use common::{url::Params, ToParts};
75696        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
75697
75698        let mut dd = common::DefaultDelegate;
75699        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
75700        dlg.begin(common::MethodInfo {
75701            id: "dfareporting.subaccounts.list",
75702            http_method: hyper::Method::GET,
75703        });
75704
75705        for &field in [
75706            "alt",
75707            "profileId",
75708            "sortOrder",
75709            "sortField",
75710            "searchString",
75711            "pageToken",
75712            "maxResults",
75713            "ids",
75714        ]
75715        .iter()
75716        {
75717            if self._additional_params.contains_key(field) {
75718                dlg.finished(false);
75719                return Err(common::Error::FieldClash(field));
75720            }
75721        }
75722
75723        let mut params = Params::with_capacity(9 + self._additional_params.len());
75724        params.push("profileId", self._profile_id.to_string());
75725        if let Some(value) = self._sort_order.as_ref() {
75726            params.push("sortOrder", value);
75727        }
75728        if let Some(value) = self._sort_field.as_ref() {
75729            params.push("sortField", value);
75730        }
75731        if let Some(value) = self._search_string.as_ref() {
75732            params.push("searchString", value);
75733        }
75734        if let Some(value) = self._page_token.as_ref() {
75735            params.push("pageToken", value);
75736        }
75737        if let Some(value) = self._max_results.as_ref() {
75738            params.push("maxResults", value.to_string());
75739        }
75740        if !self._ids.is_empty() {
75741            for f in self._ids.iter() {
75742                params.push("ids", f.to_string());
75743            }
75744        }
75745
75746        params.extend(self._additional_params.iter());
75747
75748        params.push("alt", "json");
75749        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts";
75750        if self._scopes.is_empty() {
75751            self._scopes
75752                .insert(Scope::Dfatrafficking.as_ref().to_string());
75753        }
75754
75755        #[allow(clippy::single_element_loop)]
75756        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
75757            url = params.uri_replacement(url, param_name, find_this, false);
75758        }
75759        {
75760            let to_remove = ["profileId"];
75761            params.remove_params(&to_remove);
75762        }
75763
75764        let url = params.parse_with_url(&url);
75765
75766        loop {
75767            let token = match self
75768                .hub
75769                .auth
75770                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
75771                .await
75772            {
75773                Ok(token) => token,
75774                Err(e) => match dlg.token(e) {
75775                    Ok(token) => token,
75776                    Err(e) => {
75777                        dlg.finished(false);
75778                        return Err(common::Error::MissingToken(e));
75779                    }
75780                },
75781            };
75782            let mut req_result = {
75783                let client = &self.hub.client;
75784                dlg.pre_request();
75785                let mut req_builder = hyper::Request::builder()
75786                    .method(hyper::Method::GET)
75787                    .uri(url.as_str())
75788                    .header(USER_AGENT, self.hub._user_agent.clone());
75789
75790                if let Some(token) = token.as_ref() {
75791                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
75792                }
75793
75794                let request = req_builder
75795                    .header(CONTENT_LENGTH, 0_u64)
75796                    .body(common::to_body::<String>(None));
75797
75798                client.request(request.unwrap()).await
75799            };
75800
75801            match req_result {
75802                Err(err) => {
75803                    if let common::Retry::After(d) = dlg.http_error(&err) {
75804                        sleep(d).await;
75805                        continue;
75806                    }
75807                    dlg.finished(false);
75808                    return Err(common::Error::HttpError(err));
75809                }
75810                Ok(res) => {
75811                    let (mut parts, body) = res.into_parts();
75812                    let mut body = common::Body::new(body);
75813                    if !parts.status.is_success() {
75814                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75815                        let error = serde_json::from_str(&common::to_string(&bytes));
75816                        let response = common::to_response(parts, bytes.into());
75817
75818                        if let common::Retry::After(d) =
75819                            dlg.http_failure(&response, error.as_ref().ok())
75820                        {
75821                            sleep(d).await;
75822                            continue;
75823                        }
75824
75825                        dlg.finished(false);
75826
75827                        return Err(match error {
75828                            Ok(value) => common::Error::BadRequest(value),
75829                            _ => common::Error::Failure(response),
75830                        });
75831                    }
75832                    let response = {
75833                        let bytes = common::to_bytes(body).await.unwrap_or_default();
75834                        let encoded = common::to_string(&bytes);
75835                        match serde_json::from_str(&encoded) {
75836                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
75837                            Err(error) => {
75838                                dlg.response_json_decode_error(&encoded, &error);
75839                                return Err(common::Error::JsonDecodeError(
75840                                    encoded.to_string(),
75841                                    error,
75842                                ));
75843                            }
75844                        }
75845                    };
75846
75847                    dlg.finished(true);
75848                    return Ok(response);
75849                }
75850            }
75851        }
75852    }
75853
75854    /// User profile ID associated with this request.
75855    ///
75856    /// Sets the *profile id* path property to the given value.
75857    ///
75858    /// Even though the property as already been set when instantiating this call,
75859    /// we provide this method for API completeness.
75860    pub fn profile_id(mut self, new_value: i64) -> SubaccountListCall<'a, C> {
75861        self._profile_id = new_value;
75862        self
75863    }
75864    /// Order of sorted results.
75865    ///
75866    /// Sets the *sort order* query property to the given value.
75867    pub fn sort_order(mut self, new_value: &str) -> SubaccountListCall<'a, C> {
75868        self._sort_order = Some(new_value.to_string());
75869        self
75870    }
75871    /// Field by which to sort the list.
75872    ///
75873    /// Sets the *sort field* query property to the given value.
75874    pub fn sort_field(mut self, new_value: &str) -> SubaccountListCall<'a, C> {
75875        self._sort_field = Some(new_value.to_string());
75876        self
75877    }
75878    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "subaccount*2015" will return objects with names like "subaccount June 2015", "subaccount April 2015", or simply "subaccount 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "subaccount" will match objects with name "my subaccount", "subaccount 2015", or simply "subaccount".
75879    ///
75880    /// Sets the *search string* query property to the given value.
75881    pub fn search_string(mut self, new_value: &str) -> SubaccountListCall<'a, C> {
75882        self._search_string = Some(new_value.to_string());
75883        self
75884    }
75885    /// Value of the nextPageToken from the previous result page.
75886    ///
75887    /// Sets the *page token* query property to the given value.
75888    pub fn page_token(mut self, new_value: &str) -> SubaccountListCall<'a, C> {
75889        self._page_token = Some(new_value.to_string());
75890        self
75891    }
75892    /// Maximum number of results to return.
75893    ///
75894    /// Sets the *max results* query property to the given value.
75895    pub fn max_results(mut self, new_value: i32) -> SubaccountListCall<'a, C> {
75896        self._max_results = Some(new_value);
75897        self
75898    }
75899    /// Select only subaccounts with these IDs.
75900    ///
75901    /// Append the given value to the *ids* query property.
75902    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
75903    pub fn add_ids(mut self, new_value: i64) -> SubaccountListCall<'a, C> {
75904        self._ids.push(new_value);
75905        self
75906    }
75907    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
75908    /// while executing the actual API request.
75909    ///
75910    /// ````text
75911    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
75912    /// ````
75913    ///
75914    /// Sets the *delegate* property to the given value.
75915    pub fn delegate(
75916        mut self,
75917        new_value: &'a mut dyn common::Delegate,
75918    ) -> SubaccountListCall<'a, C> {
75919        self._delegate = Some(new_value);
75920        self
75921    }
75922
75923    /// Set any additional parameter of the query string used in the request.
75924    /// It should be used to set parameters which are not yet available through their own
75925    /// setters.
75926    ///
75927    /// Please note that this method must not be used to set any of the known parameters
75928    /// which have their own setter method. If done anyway, the request will fail.
75929    ///
75930    /// # Additional Parameters
75931    ///
75932    /// * *alt* (query-string) - Data format for the response.
75933    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
75934    /// * *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.
75935    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
75936    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
75937    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
75938    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
75939    pub fn param<T>(mut self, name: T, value: T) -> SubaccountListCall<'a, C>
75940    where
75941        T: AsRef<str>,
75942    {
75943        self._additional_params
75944            .insert(name.as_ref().to_string(), value.as_ref().to_string());
75945        self
75946    }
75947
75948    /// Identifies the authorization scope for the method you are building.
75949    ///
75950    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
75951    /// [`Scope::Dfatrafficking`].
75952    ///
75953    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
75954    /// tokens for more than one scope.
75955    ///
75956    /// Usually there is more than one suitable scope to authorize an operation, some of which may
75957    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
75958    /// sufficient, a read-write scope will do as well.
75959    pub fn add_scope<St>(mut self, scope: St) -> SubaccountListCall<'a, C>
75960    where
75961        St: AsRef<str>,
75962    {
75963        self._scopes.insert(String::from(scope.as_ref()));
75964        self
75965    }
75966    /// Identifies the authorization scope(s) for the method you are building.
75967    ///
75968    /// See [`Self::add_scope()`] for details.
75969    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubaccountListCall<'a, C>
75970    where
75971        I: IntoIterator<Item = St>,
75972        St: AsRef<str>,
75973    {
75974        self._scopes
75975            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
75976        self
75977    }
75978
75979    /// Removes all scopes, and no default scope will be used either.
75980    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
75981    /// for details).
75982    pub fn clear_scopes(mut self) -> SubaccountListCall<'a, C> {
75983        self._scopes.clear();
75984        self
75985    }
75986}
75987
75988/// Updates an existing subaccount. This method supports patch semantics.
75989///
75990/// A builder for the *patch* method supported by a *subaccount* resource.
75991/// It is not used directly, but through a [`SubaccountMethods`] instance.
75992///
75993/// # Example
75994///
75995/// Instantiate a resource method builder
75996///
75997/// ```test_harness,no_run
75998/// # extern crate hyper;
75999/// # extern crate hyper_rustls;
76000/// # extern crate google_dfareporting3d2 as dfareporting3d2;
76001/// use dfareporting3d2::api::Subaccount;
76002/// # async fn dox() {
76003/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
76004///
76005/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
76006/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
76007/// #     secret,
76008/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76009/// # ).build().await.unwrap();
76010///
76011/// # let client = hyper_util::client::legacy::Client::builder(
76012/// #     hyper_util::rt::TokioExecutor::new()
76013/// # )
76014/// # .build(
76015/// #     hyper_rustls::HttpsConnectorBuilder::new()
76016/// #         .with_native_roots()
76017/// #         .unwrap()
76018/// #         .https_or_http()
76019/// #         .enable_http1()
76020/// #         .build()
76021/// # );
76022/// # let mut hub = Dfareporting::new(client, auth);
76023/// // As the method needs a request, you would usually fill it with the desired information
76024/// // into the respective structure. Some of the parts shown here might not be applicable !
76025/// // Values shown here are possibly random and not representative !
76026/// let mut req = Subaccount::default();
76027///
76028/// // You can configure optional parameters by calling the respective setters at will, and
76029/// // execute the final call using `doit()`.
76030/// // Values shown here are possibly random and not representative !
76031/// let result = hub.subaccounts().patch(req, -27, -35)
76032///              .doit().await;
76033/// # }
76034/// ```
76035pub struct SubaccountPatchCall<'a, C>
76036where
76037    C: 'a,
76038{
76039    hub: &'a Dfareporting<C>,
76040    _request: Subaccount,
76041    _profile_id: i64,
76042    _id: i64,
76043    _delegate: Option<&'a mut dyn common::Delegate>,
76044    _additional_params: HashMap<String, String>,
76045    _scopes: BTreeSet<String>,
76046}
76047
76048impl<'a, C> common::CallBuilder for SubaccountPatchCall<'a, C> {}
76049
76050impl<'a, C> SubaccountPatchCall<'a, C>
76051where
76052    C: common::Connector,
76053{
76054    /// Perform the operation you have build so far.
76055    pub async fn doit(mut self) -> common::Result<(common::Response, Subaccount)> {
76056        use std::borrow::Cow;
76057        use std::io::{Read, Seek};
76058
76059        use common::{url::Params, ToParts};
76060        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
76061
76062        let mut dd = common::DefaultDelegate;
76063        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
76064        dlg.begin(common::MethodInfo {
76065            id: "dfareporting.subaccounts.patch",
76066            http_method: hyper::Method::PATCH,
76067        });
76068
76069        for &field in ["alt", "profileId", "id"].iter() {
76070            if self._additional_params.contains_key(field) {
76071                dlg.finished(false);
76072                return Err(common::Error::FieldClash(field));
76073            }
76074        }
76075
76076        let mut params = Params::with_capacity(5 + self._additional_params.len());
76077        params.push("profileId", self._profile_id.to_string());
76078        params.push("id", self._id.to_string());
76079
76080        params.extend(self._additional_params.iter());
76081
76082        params.push("alt", "json");
76083        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts";
76084        if self._scopes.is_empty() {
76085            self._scopes
76086                .insert(Scope::Dfatrafficking.as_ref().to_string());
76087        }
76088
76089        #[allow(clippy::single_element_loop)]
76090        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
76091            url = params.uri_replacement(url, param_name, find_this, false);
76092        }
76093        {
76094            let to_remove = ["profileId"];
76095            params.remove_params(&to_remove);
76096        }
76097
76098        let url = params.parse_with_url(&url);
76099
76100        let mut json_mime_type = mime::APPLICATION_JSON;
76101        let mut request_value_reader = {
76102            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
76103            common::remove_json_null_values(&mut value);
76104            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
76105            serde_json::to_writer(&mut dst, &value).unwrap();
76106            dst
76107        };
76108        let request_size = request_value_reader
76109            .seek(std::io::SeekFrom::End(0))
76110            .unwrap();
76111        request_value_reader
76112            .seek(std::io::SeekFrom::Start(0))
76113            .unwrap();
76114
76115        loop {
76116            let token = match self
76117                .hub
76118                .auth
76119                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
76120                .await
76121            {
76122                Ok(token) => token,
76123                Err(e) => match dlg.token(e) {
76124                    Ok(token) => token,
76125                    Err(e) => {
76126                        dlg.finished(false);
76127                        return Err(common::Error::MissingToken(e));
76128                    }
76129                },
76130            };
76131            request_value_reader
76132                .seek(std::io::SeekFrom::Start(0))
76133                .unwrap();
76134            let mut req_result = {
76135                let client = &self.hub.client;
76136                dlg.pre_request();
76137                let mut req_builder = hyper::Request::builder()
76138                    .method(hyper::Method::PATCH)
76139                    .uri(url.as_str())
76140                    .header(USER_AGENT, self.hub._user_agent.clone());
76141
76142                if let Some(token) = token.as_ref() {
76143                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
76144                }
76145
76146                let request = req_builder
76147                    .header(CONTENT_TYPE, json_mime_type.to_string())
76148                    .header(CONTENT_LENGTH, request_size as u64)
76149                    .body(common::to_body(
76150                        request_value_reader.get_ref().clone().into(),
76151                    ));
76152
76153                client.request(request.unwrap()).await
76154            };
76155
76156            match req_result {
76157                Err(err) => {
76158                    if let common::Retry::After(d) = dlg.http_error(&err) {
76159                        sleep(d).await;
76160                        continue;
76161                    }
76162                    dlg.finished(false);
76163                    return Err(common::Error::HttpError(err));
76164                }
76165                Ok(res) => {
76166                    let (mut parts, body) = res.into_parts();
76167                    let mut body = common::Body::new(body);
76168                    if !parts.status.is_success() {
76169                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76170                        let error = serde_json::from_str(&common::to_string(&bytes));
76171                        let response = common::to_response(parts, bytes.into());
76172
76173                        if let common::Retry::After(d) =
76174                            dlg.http_failure(&response, error.as_ref().ok())
76175                        {
76176                            sleep(d).await;
76177                            continue;
76178                        }
76179
76180                        dlg.finished(false);
76181
76182                        return Err(match error {
76183                            Ok(value) => common::Error::BadRequest(value),
76184                            _ => common::Error::Failure(response),
76185                        });
76186                    }
76187                    let response = {
76188                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76189                        let encoded = common::to_string(&bytes);
76190                        match serde_json::from_str(&encoded) {
76191                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
76192                            Err(error) => {
76193                                dlg.response_json_decode_error(&encoded, &error);
76194                                return Err(common::Error::JsonDecodeError(
76195                                    encoded.to_string(),
76196                                    error,
76197                                ));
76198                            }
76199                        }
76200                    };
76201
76202                    dlg.finished(true);
76203                    return Ok(response);
76204                }
76205            }
76206        }
76207    }
76208
76209    ///
76210    /// Sets the *request* property to the given value.
76211    ///
76212    /// Even though the property as already been set when instantiating this call,
76213    /// we provide this method for API completeness.
76214    pub fn request(mut self, new_value: Subaccount) -> SubaccountPatchCall<'a, C> {
76215        self._request = new_value;
76216        self
76217    }
76218    /// User profile ID associated with this request.
76219    ///
76220    /// Sets the *profile id* path property to the given value.
76221    ///
76222    /// Even though the property as already been set when instantiating this call,
76223    /// we provide this method for API completeness.
76224    pub fn profile_id(mut self, new_value: i64) -> SubaccountPatchCall<'a, C> {
76225        self._profile_id = new_value;
76226        self
76227    }
76228    /// Subaccount ID.
76229    ///
76230    /// Sets the *id* query property to the given value.
76231    ///
76232    /// Even though the property as already been set when instantiating this call,
76233    /// we provide this method for API completeness.
76234    pub fn id(mut self, new_value: i64) -> SubaccountPatchCall<'a, C> {
76235        self._id = new_value;
76236        self
76237    }
76238    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
76239    /// while executing the actual API request.
76240    ///
76241    /// ````text
76242    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
76243    /// ````
76244    ///
76245    /// Sets the *delegate* property to the given value.
76246    pub fn delegate(
76247        mut self,
76248        new_value: &'a mut dyn common::Delegate,
76249    ) -> SubaccountPatchCall<'a, C> {
76250        self._delegate = Some(new_value);
76251        self
76252    }
76253
76254    /// Set any additional parameter of the query string used in the request.
76255    /// It should be used to set parameters which are not yet available through their own
76256    /// setters.
76257    ///
76258    /// Please note that this method must not be used to set any of the known parameters
76259    /// which have their own setter method. If done anyway, the request will fail.
76260    ///
76261    /// # Additional Parameters
76262    ///
76263    /// * *alt* (query-string) - Data format for the response.
76264    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
76265    /// * *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.
76266    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
76267    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
76268    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
76269    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
76270    pub fn param<T>(mut self, name: T, value: T) -> SubaccountPatchCall<'a, C>
76271    where
76272        T: AsRef<str>,
76273    {
76274        self._additional_params
76275            .insert(name.as_ref().to_string(), value.as_ref().to_string());
76276        self
76277    }
76278
76279    /// Identifies the authorization scope for the method you are building.
76280    ///
76281    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
76282    /// [`Scope::Dfatrafficking`].
76283    ///
76284    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
76285    /// tokens for more than one scope.
76286    ///
76287    /// Usually there is more than one suitable scope to authorize an operation, some of which may
76288    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
76289    /// sufficient, a read-write scope will do as well.
76290    pub fn add_scope<St>(mut self, scope: St) -> SubaccountPatchCall<'a, C>
76291    where
76292        St: AsRef<str>,
76293    {
76294        self._scopes.insert(String::from(scope.as_ref()));
76295        self
76296    }
76297    /// Identifies the authorization scope(s) for the method you are building.
76298    ///
76299    /// See [`Self::add_scope()`] for details.
76300    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubaccountPatchCall<'a, C>
76301    where
76302        I: IntoIterator<Item = St>,
76303        St: AsRef<str>,
76304    {
76305        self._scopes
76306            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
76307        self
76308    }
76309
76310    /// Removes all scopes, and no default scope will be used either.
76311    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
76312    /// for details).
76313    pub fn clear_scopes(mut self) -> SubaccountPatchCall<'a, C> {
76314        self._scopes.clear();
76315        self
76316    }
76317}
76318
76319/// Updates an existing subaccount.
76320///
76321/// A builder for the *update* method supported by a *subaccount* resource.
76322/// It is not used directly, but through a [`SubaccountMethods`] instance.
76323///
76324/// # Example
76325///
76326/// Instantiate a resource method builder
76327///
76328/// ```test_harness,no_run
76329/// # extern crate hyper;
76330/// # extern crate hyper_rustls;
76331/// # extern crate google_dfareporting3d2 as dfareporting3d2;
76332/// use dfareporting3d2::api::Subaccount;
76333/// # async fn dox() {
76334/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
76335///
76336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
76337/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
76338/// #     secret,
76339/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76340/// # ).build().await.unwrap();
76341///
76342/// # let client = hyper_util::client::legacy::Client::builder(
76343/// #     hyper_util::rt::TokioExecutor::new()
76344/// # )
76345/// # .build(
76346/// #     hyper_rustls::HttpsConnectorBuilder::new()
76347/// #         .with_native_roots()
76348/// #         .unwrap()
76349/// #         .https_or_http()
76350/// #         .enable_http1()
76351/// #         .build()
76352/// # );
76353/// # let mut hub = Dfareporting::new(client, auth);
76354/// // As the method needs a request, you would usually fill it with the desired information
76355/// // into the respective structure. Some of the parts shown here might not be applicable !
76356/// // Values shown here are possibly random and not representative !
76357/// let mut req = Subaccount::default();
76358///
76359/// // You can configure optional parameters by calling the respective setters at will, and
76360/// // execute the final call using `doit()`.
76361/// // Values shown here are possibly random and not representative !
76362/// let result = hub.subaccounts().update(req, -23)
76363///              .doit().await;
76364/// # }
76365/// ```
76366pub struct SubaccountUpdateCall<'a, C>
76367where
76368    C: 'a,
76369{
76370    hub: &'a Dfareporting<C>,
76371    _request: Subaccount,
76372    _profile_id: i64,
76373    _delegate: Option<&'a mut dyn common::Delegate>,
76374    _additional_params: HashMap<String, String>,
76375    _scopes: BTreeSet<String>,
76376}
76377
76378impl<'a, C> common::CallBuilder for SubaccountUpdateCall<'a, C> {}
76379
76380impl<'a, C> SubaccountUpdateCall<'a, C>
76381where
76382    C: common::Connector,
76383{
76384    /// Perform the operation you have build so far.
76385    pub async fn doit(mut self) -> common::Result<(common::Response, Subaccount)> {
76386        use std::borrow::Cow;
76387        use std::io::{Read, Seek};
76388
76389        use common::{url::Params, ToParts};
76390        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
76391
76392        let mut dd = common::DefaultDelegate;
76393        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
76394        dlg.begin(common::MethodInfo {
76395            id: "dfareporting.subaccounts.update",
76396            http_method: hyper::Method::PUT,
76397        });
76398
76399        for &field in ["alt", "profileId"].iter() {
76400            if self._additional_params.contains_key(field) {
76401                dlg.finished(false);
76402                return Err(common::Error::FieldClash(field));
76403            }
76404        }
76405
76406        let mut params = Params::with_capacity(4 + self._additional_params.len());
76407        params.push("profileId", self._profile_id.to_string());
76408
76409        params.extend(self._additional_params.iter());
76410
76411        params.push("alt", "json");
76412        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts";
76413        if self._scopes.is_empty() {
76414            self._scopes
76415                .insert(Scope::Dfatrafficking.as_ref().to_string());
76416        }
76417
76418        #[allow(clippy::single_element_loop)]
76419        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
76420            url = params.uri_replacement(url, param_name, find_this, false);
76421        }
76422        {
76423            let to_remove = ["profileId"];
76424            params.remove_params(&to_remove);
76425        }
76426
76427        let url = params.parse_with_url(&url);
76428
76429        let mut json_mime_type = mime::APPLICATION_JSON;
76430        let mut request_value_reader = {
76431            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
76432            common::remove_json_null_values(&mut value);
76433            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
76434            serde_json::to_writer(&mut dst, &value).unwrap();
76435            dst
76436        };
76437        let request_size = request_value_reader
76438            .seek(std::io::SeekFrom::End(0))
76439            .unwrap();
76440        request_value_reader
76441            .seek(std::io::SeekFrom::Start(0))
76442            .unwrap();
76443
76444        loop {
76445            let token = match self
76446                .hub
76447                .auth
76448                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
76449                .await
76450            {
76451                Ok(token) => token,
76452                Err(e) => match dlg.token(e) {
76453                    Ok(token) => token,
76454                    Err(e) => {
76455                        dlg.finished(false);
76456                        return Err(common::Error::MissingToken(e));
76457                    }
76458                },
76459            };
76460            request_value_reader
76461                .seek(std::io::SeekFrom::Start(0))
76462                .unwrap();
76463            let mut req_result = {
76464                let client = &self.hub.client;
76465                dlg.pre_request();
76466                let mut req_builder = hyper::Request::builder()
76467                    .method(hyper::Method::PUT)
76468                    .uri(url.as_str())
76469                    .header(USER_AGENT, self.hub._user_agent.clone());
76470
76471                if let Some(token) = token.as_ref() {
76472                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
76473                }
76474
76475                let request = req_builder
76476                    .header(CONTENT_TYPE, json_mime_type.to_string())
76477                    .header(CONTENT_LENGTH, request_size as u64)
76478                    .body(common::to_body(
76479                        request_value_reader.get_ref().clone().into(),
76480                    ));
76481
76482                client.request(request.unwrap()).await
76483            };
76484
76485            match req_result {
76486                Err(err) => {
76487                    if let common::Retry::After(d) = dlg.http_error(&err) {
76488                        sleep(d).await;
76489                        continue;
76490                    }
76491                    dlg.finished(false);
76492                    return Err(common::Error::HttpError(err));
76493                }
76494                Ok(res) => {
76495                    let (mut parts, body) = res.into_parts();
76496                    let mut body = common::Body::new(body);
76497                    if !parts.status.is_success() {
76498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76499                        let error = serde_json::from_str(&common::to_string(&bytes));
76500                        let response = common::to_response(parts, bytes.into());
76501
76502                        if let common::Retry::After(d) =
76503                            dlg.http_failure(&response, error.as_ref().ok())
76504                        {
76505                            sleep(d).await;
76506                            continue;
76507                        }
76508
76509                        dlg.finished(false);
76510
76511                        return Err(match error {
76512                            Ok(value) => common::Error::BadRequest(value),
76513                            _ => common::Error::Failure(response),
76514                        });
76515                    }
76516                    let response = {
76517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76518                        let encoded = common::to_string(&bytes);
76519                        match serde_json::from_str(&encoded) {
76520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
76521                            Err(error) => {
76522                                dlg.response_json_decode_error(&encoded, &error);
76523                                return Err(common::Error::JsonDecodeError(
76524                                    encoded.to_string(),
76525                                    error,
76526                                ));
76527                            }
76528                        }
76529                    };
76530
76531                    dlg.finished(true);
76532                    return Ok(response);
76533                }
76534            }
76535        }
76536    }
76537
76538    ///
76539    /// Sets the *request* property to the given value.
76540    ///
76541    /// Even though the property as already been set when instantiating this call,
76542    /// we provide this method for API completeness.
76543    pub fn request(mut self, new_value: Subaccount) -> SubaccountUpdateCall<'a, C> {
76544        self._request = new_value;
76545        self
76546    }
76547    /// User profile ID associated with this request.
76548    ///
76549    /// Sets the *profile id* path property to the given value.
76550    ///
76551    /// Even though the property as already been set when instantiating this call,
76552    /// we provide this method for API completeness.
76553    pub fn profile_id(mut self, new_value: i64) -> SubaccountUpdateCall<'a, C> {
76554        self._profile_id = new_value;
76555        self
76556    }
76557    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
76558    /// while executing the actual API request.
76559    ///
76560    /// ````text
76561    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
76562    /// ````
76563    ///
76564    /// Sets the *delegate* property to the given value.
76565    pub fn delegate(
76566        mut self,
76567        new_value: &'a mut dyn common::Delegate,
76568    ) -> SubaccountUpdateCall<'a, C> {
76569        self._delegate = Some(new_value);
76570        self
76571    }
76572
76573    /// Set any additional parameter of the query string used in the request.
76574    /// It should be used to set parameters which are not yet available through their own
76575    /// setters.
76576    ///
76577    /// Please note that this method must not be used to set any of the known parameters
76578    /// which have their own setter method. If done anyway, the request will fail.
76579    ///
76580    /// # Additional Parameters
76581    ///
76582    /// * *alt* (query-string) - Data format for the response.
76583    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
76584    /// * *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.
76585    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
76586    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
76587    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
76588    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
76589    pub fn param<T>(mut self, name: T, value: T) -> SubaccountUpdateCall<'a, C>
76590    where
76591        T: AsRef<str>,
76592    {
76593        self._additional_params
76594            .insert(name.as_ref().to_string(), value.as_ref().to_string());
76595        self
76596    }
76597
76598    /// Identifies the authorization scope for the method you are building.
76599    ///
76600    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
76601    /// [`Scope::Dfatrafficking`].
76602    ///
76603    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
76604    /// tokens for more than one scope.
76605    ///
76606    /// Usually there is more than one suitable scope to authorize an operation, some of which may
76607    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
76608    /// sufficient, a read-write scope will do as well.
76609    pub fn add_scope<St>(mut self, scope: St) -> SubaccountUpdateCall<'a, C>
76610    where
76611        St: AsRef<str>,
76612    {
76613        self._scopes.insert(String::from(scope.as_ref()));
76614        self
76615    }
76616    /// Identifies the authorization scope(s) for the method you are building.
76617    ///
76618    /// See [`Self::add_scope()`] for details.
76619    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubaccountUpdateCall<'a, C>
76620    where
76621        I: IntoIterator<Item = St>,
76622        St: AsRef<str>,
76623    {
76624        self._scopes
76625            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
76626        self
76627    }
76628
76629    /// Removes all scopes, and no default scope will be used either.
76630    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
76631    /// for details).
76632    pub fn clear_scopes(mut self) -> SubaccountUpdateCall<'a, C> {
76633        self._scopes.clear();
76634        self
76635    }
76636}
76637
76638/// Gets one remarketing list by ID.
76639///
76640/// A builder for the *get* method supported by a *targetableRemarketingList* resource.
76641/// It is not used directly, but through a [`TargetableRemarketingListMethods`] instance.
76642///
76643/// # Example
76644///
76645/// Instantiate a resource method builder
76646///
76647/// ```test_harness,no_run
76648/// # extern crate hyper;
76649/// # extern crate hyper_rustls;
76650/// # extern crate google_dfareporting3d2 as dfareporting3d2;
76651/// # async fn dox() {
76652/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
76653///
76654/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
76655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
76656/// #     secret,
76657/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76658/// # ).build().await.unwrap();
76659///
76660/// # let client = hyper_util::client::legacy::Client::builder(
76661/// #     hyper_util::rt::TokioExecutor::new()
76662/// # )
76663/// # .build(
76664/// #     hyper_rustls::HttpsConnectorBuilder::new()
76665/// #         .with_native_roots()
76666/// #         .unwrap()
76667/// #         .https_or_http()
76668/// #         .enable_http1()
76669/// #         .build()
76670/// # );
76671/// # let mut hub = Dfareporting::new(client, auth);
76672/// // You can configure optional parameters by calling the respective setters at will, and
76673/// // execute the final call using `doit()`.
76674/// // Values shown here are possibly random and not representative !
76675/// let result = hub.targetable_remarketing_lists().get(-98, -28)
76676///              .doit().await;
76677/// # }
76678/// ```
76679pub struct TargetableRemarketingListGetCall<'a, C>
76680where
76681    C: 'a,
76682{
76683    hub: &'a Dfareporting<C>,
76684    _profile_id: i64,
76685    _id: i64,
76686    _delegate: Option<&'a mut dyn common::Delegate>,
76687    _additional_params: HashMap<String, String>,
76688    _scopes: BTreeSet<String>,
76689}
76690
76691impl<'a, C> common::CallBuilder for TargetableRemarketingListGetCall<'a, C> {}
76692
76693impl<'a, C> TargetableRemarketingListGetCall<'a, C>
76694where
76695    C: common::Connector,
76696{
76697    /// Perform the operation you have build so far.
76698    pub async fn doit(mut self) -> common::Result<(common::Response, TargetableRemarketingList)> {
76699        use std::borrow::Cow;
76700        use std::io::{Read, Seek};
76701
76702        use common::{url::Params, ToParts};
76703        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
76704
76705        let mut dd = common::DefaultDelegate;
76706        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
76707        dlg.begin(common::MethodInfo {
76708            id: "dfareporting.targetableRemarketingLists.get",
76709            http_method: hyper::Method::GET,
76710        });
76711
76712        for &field in ["alt", "profileId", "id"].iter() {
76713            if self._additional_params.contains_key(field) {
76714                dlg.finished(false);
76715                return Err(common::Error::FieldClash(field));
76716            }
76717        }
76718
76719        let mut params = Params::with_capacity(4 + self._additional_params.len());
76720        params.push("profileId", self._profile_id.to_string());
76721        params.push("id", self._id.to_string());
76722
76723        params.extend(self._additional_params.iter());
76724
76725        params.push("alt", "json");
76726        let mut url =
76727            self.hub._base_url.clone() + "userprofiles/{profileId}/targetableRemarketingLists/{id}";
76728        if self._scopes.is_empty() {
76729            self._scopes
76730                .insert(Scope::Dfatrafficking.as_ref().to_string());
76731        }
76732
76733        #[allow(clippy::single_element_loop)]
76734        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
76735            url = params.uri_replacement(url, param_name, find_this, false);
76736        }
76737        {
76738            let to_remove = ["id", "profileId"];
76739            params.remove_params(&to_remove);
76740        }
76741
76742        let url = params.parse_with_url(&url);
76743
76744        loop {
76745            let token = match self
76746                .hub
76747                .auth
76748                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
76749                .await
76750            {
76751                Ok(token) => token,
76752                Err(e) => match dlg.token(e) {
76753                    Ok(token) => token,
76754                    Err(e) => {
76755                        dlg.finished(false);
76756                        return Err(common::Error::MissingToken(e));
76757                    }
76758                },
76759            };
76760            let mut req_result = {
76761                let client = &self.hub.client;
76762                dlg.pre_request();
76763                let mut req_builder = hyper::Request::builder()
76764                    .method(hyper::Method::GET)
76765                    .uri(url.as_str())
76766                    .header(USER_AGENT, self.hub._user_agent.clone());
76767
76768                if let Some(token) = token.as_ref() {
76769                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
76770                }
76771
76772                let request = req_builder
76773                    .header(CONTENT_LENGTH, 0_u64)
76774                    .body(common::to_body::<String>(None));
76775
76776                client.request(request.unwrap()).await
76777            };
76778
76779            match req_result {
76780                Err(err) => {
76781                    if let common::Retry::After(d) = dlg.http_error(&err) {
76782                        sleep(d).await;
76783                        continue;
76784                    }
76785                    dlg.finished(false);
76786                    return Err(common::Error::HttpError(err));
76787                }
76788                Ok(res) => {
76789                    let (mut parts, body) = res.into_parts();
76790                    let mut body = common::Body::new(body);
76791                    if !parts.status.is_success() {
76792                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76793                        let error = serde_json::from_str(&common::to_string(&bytes));
76794                        let response = common::to_response(parts, bytes.into());
76795
76796                        if let common::Retry::After(d) =
76797                            dlg.http_failure(&response, error.as_ref().ok())
76798                        {
76799                            sleep(d).await;
76800                            continue;
76801                        }
76802
76803                        dlg.finished(false);
76804
76805                        return Err(match error {
76806                            Ok(value) => common::Error::BadRequest(value),
76807                            _ => common::Error::Failure(response),
76808                        });
76809                    }
76810                    let response = {
76811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
76812                        let encoded = common::to_string(&bytes);
76813                        match serde_json::from_str(&encoded) {
76814                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
76815                            Err(error) => {
76816                                dlg.response_json_decode_error(&encoded, &error);
76817                                return Err(common::Error::JsonDecodeError(
76818                                    encoded.to_string(),
76819                                    error,
76820                                ));
76821                            }
76822                        }
76823                    };
76824
76825                    dlg.finished(true);
76826                    return Ok(response);
76827                }
76828            }
76829        }
76830    }
76831
76832    /// User profile ID associated with this request.
76833    ///
76834    /// Sets the *profile id* path property to the given value.
76835    ///
76836    /// Even though the property as already been set when instantiating this call,
76837    /// we provide this method for API completeness.
76838    pub fn profile_id(mut self, new_value: i64) -> TargetableRemarketingListGetCall<'a, C> {
76839        self._profile_id = new_value;
76840        self
76841    }
76842    /// Remarketing list ID.
76843    ///
76844    /// Sets the *id* path property to the given value.
76845    ///
76846    /// Even though the property as already been set when instantiating this call,
76847    /// we provide this method for API completeness.
76848    pub fn id(mut self, new_value: i64) -> TargetableRemarketingListGetCall<'a, C> {
76849        self._id = new_value;
76850        self
76851    }
76852    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
76853    /// while executing the actual API request.
76854    ///
76855    /// ````text
76856    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
76857    /// ````
76858    ///
76859    /// Sets the *delegate* property to the given value.
76860    pub fn delegate(
76861        mut self,
76862        new_value: &'a mut dyn common::Delegate,
76863    ) -> TargetableRemarketingListGetCall<'a, C> {
76864        self._delegate = Some(new_value);
76865        self
76866    }
76867
76868    /// Set any additional parameter of the query string used in the request.
76869    /// It should be used to set parameters which are not yet available through their own
76870    /// setters.
76871    ///
76872    /// Please note that this method must not be used to set any of the known parameters
76873    /// which have their own setter method. If done anyway, the request will fail.
76874    ///
76875    /// # Additional Parameters
76876    ///
76877    /// * *alt* (query-string) - Data format for the response.
76878    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
76879    /// * *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.
76880    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
76881    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
76882    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
76883    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
76884    pub fn param<T>(mut self, name: T, value: T) -> TargetableRemarketingListGetCall<'a, C>
76885    where
76886        T: AsRef<str>,
76887    {
76888        self._additional_params
76889            .insert(name.as_ref().to_string(), value.as_ref().to_string());
76890        self
76891    }
76892
76893    /// Identifies the authorization scope for the method you are building.
76894    ///
76895    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
76896    /// [`Scope::Dfatrafficking`].
76897    ///
76898    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
76899    /// tokens for more than one scope.
76900    ///
76901    /// Usually there is more than one suitable scope to authorize an operation, some of which may
76902    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
76903    /// sufficient, a read-write scope will do as well.
76904    pub fn add_scope<St>(mut self, scope: St) -> TargetableRemarketingListGetCall<'a, C>
76905    where
76906        St: AsRef<str>,
76907    {
76908        self._scopes.insert(String::from(scope.as_ref()));
76909        self
76910    }
76911    /// Identifies the authorization scope(s) for the method you are building.
76912    ///
76913    /// See [`Self::add_scope()`] for details.
76914    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetableRemarketingListGetCall<'a, C>
76915    where
76916        I: IntoIterator<Item = St>,
76917        St: AsRef<str>,
76918    {
76919        self._scopes
76920            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
76921        self
76922    }
76923
76924    /// Removes all scopes, and no default scope will be used either.
76925    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
76926    /// for details).
76927    pub fn clear_scopes(mut self) -> TargetableRemarketingListGetCall<'a, C> {
76928        self._scopes.clear();
76929        self
76930    }
76931}
76932
76933/// Retrieves a list of targetable remarketing lists, possibly filtered. This method supports paging.
76934///
76935/// A builder for the *list* method supported by a *targetableRemarketingList* resource.
76936/// It is not used directly, but through a [`TargetableRemarketingListMethods`] instance.
76937///
76938/// # Example
76939///
76940/// Instantiate a resource method builder
76941///
76942/// ```test_harness,no_run
76943/// # extern crate hyper;
76944/// # extern crate hyper_rustls;
76945/// # extern crate google_dfareporting3d2 as dfareporting3d2;
76946/// # async fn dox() {
76947/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
76948///
76949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
76950/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
76951/// #     secret,
76952/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76953/// # ).build().await.unwrap();
76954///
76955/// # let client = hyper_util::client::legacy::Client::builder(
76956/// #     hyper_util::rt::TokioExecutor::new()
76957/// # )
76958/// # .build(
76959/// #     hyper_rustls::HttpsConnectorBuilder::new()
76960/// #         .with_native_roots()
76961/// #         .unwrap()
76962/// #         .https_or_http()
76963/// #         .enable_http1()
76964/// #         .build()
76965/// # );
76966/// # let mut hub = Dfareporting::new(client, auth);
76967/// // You can configure optional parameters by calling the respective setters at will, and
76968/// // execute the final call using `doit()`.
76969/// // Values shown here are possibly random and not representative !
76970/// let result = hub.targetable_remarketing_lists().list(-13, -61)
76971///              .sort_order("amet.")
76972///              .sort_field("aliquyam")
76973///              .page_token("accusam")
76974///              .name("sanctus")
76975///              .max_results(-70)
76976///              .active(true)
76977///              .doit().await;
76978/// # }
76979/// ```
76980pub struct TargetableRemarketingListListCall<'a, C>
76981where
76982    C: 'a,
76983{
76984    hub: &'a Dfareporting<C>,
76985    _profile_id: i64,
76986    _advertiser_id: i64,
76987    _sort_order: Option<String>,
76988    _sort_field: Option<String>,
76989    _page_token: Option<String>,
76990    _name: Option<String>,
76991    _max_results: Option<i32>,
76992    _active: Option<bool>,
76993    _delegate: Option<&'a mut dyn common::Delegate>,
76994    _additional_params: HashMap<String, String>,
76995    _scopes: BTreeSet<String>,
76996}
76997
76998impl<'a, C> common::CallBuilder for TargetableRemarketingListListCall<'a, C> {}
76999
77000impl<'a, C> TargetableRemarketingListListCall<'a, C>
77001where
77002    C: common::Connector,
77003{
77004    /// Perform the operation you have build so far.
77005    pub async fn doit(
77006        mut self,
77007    ) -> common::Result<(common::Response, TargetableRemarketingListsListResponse)> {
77008        use std::borrow::Cow;
77009        use std::io::{Read, Seek};
77010
77011        use common::{url::Params, ToParts};
77012        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
77013
77014        let mut dd = common::DefaultDelegate;
77015        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
77016        dlg.begin(common::MethodInfo {
77017            id: "dfareporting.targetableRemarketingLists.list",
77018            http_method: hyper::Method::GET,
77019        });
77020
77021        for &field in [
77022            "alt",
77023            "profileId",
77024            "advertiserId",
77025            "sortOrder",
77026            "sortField",
77027            "pageToken",
77028            "name",
77029            "maxResults",
77030            "active",
77031        ]
77032        .iter()
77033        {
77034            if self._additional_params.contains_key(field) {
77035                dlg.finished(false);
77036                return Err(common::Error::FieldClash(field));
77037            }
77038        }
77039
77040        let mut params = Params::with_capacity(10 + self._additional_params.len());
77041        params.push("profileId", self._profile_id.to_string());
77042        params.push("advertiserId", self._advertiser_id.to_string());
77043        if let Some(value) = self._sort_order.as_ref() {
77044            params.push("sortOrder", value);
77045        }
77046        if let Some(value) = self._sort_field.as_ref() {
77047            params.push("sortField", value);
77048        }
77049        if let Some(value) = self._page_token.as_ref() {
77050            params.push("pageToken", value);
77051        }
77052        if let Some(value) = self._name.as_ref() {
77053            params.push("name", value);
77054        }
77055        if let Some(value) = self._max_results.as_ref() {
77056            params.push("maxResults", value.to_string());
77057        }
77058        if let Some(value) = self._active.as_ref() {
77059            params.push("active", value.to_string());
77060        }
77061
77062        params.extend(self._additional_params.iter());
77063
77064        params.push("alt", "json");
77065        let mut url =
77066            self.hub._base_url.clone() + "userprofiles/{profileId}/targetableRemarketingLists";
77067        if self._scopes.is_empty() {
77068            self._scopes
77069                .insert(Scope::Dfatrafficking.as_ref().to_string());
77070        }
77071
77072        #[allow(clippy::single_element_loop)]
77073        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
77074            url = params.uri_replacement(url, param_name, find_this, false);
77075        }
77076        {
77077            let to_remove = ["profileId"];
77078            params.remove_params(&to_remove);
77079        }
77080
77081        let url = params.parse_with_url(&url);
77082
77083        loop {
77084            let token = match self
77085                .hub
77086                .auth
77087                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
77088                .await
77089            {
77090                Ok(token) => token,
77091                Err(e) => match dlg.token(e) {
77092                    Ok(token) => token,
77093                    Err(e) => {
77094                        dlg.finished(false);
77095                        return Err(common::Error::MissingToken(e));
77096                    }
77097                },
77098            };
77099            let mut req_result = {
77100                let client = &self.hub.client;
77101                dlg.pre_request();
77102                let mut req_builder = hyper::Request::builder()
77103                    .method(hyper::Method::GET)
77104                    .uri(url.as_str())
77105                    .header(USER_AGENT, self.hub._user_agent.clone());
77106
77107                if let Some(token) = token.as_ref() {
77108                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
77109                }
77110
77111                let request = req_builder
77112                    .header(CONTENT_LENGTH, 0_u64)
77113                    .body(common::to_body::<String>(None));
77114
77115                client.request(request.unwrap()).await
77116            };
77117
77118            match req_result {
77119                Err(err) => {
77120                    if let common::Retry::After(d) = dlg.http_error(&err) {
77121                        sleep(d).await;
77122                        continue;
77123                    }
77124                    dlg.finished(false);
77125                    return Err(common::Error::HttpError(err));
77126                }
77127                Ok(res) => {
77128                    let (mut parts, body) = res.into_parts();
77129                    let mut body = common::Body::new(body);
77130                    if !parts.status.is_success() {
77131                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77132                        let error = serde_json::from_str(&common::to_string(&bytes));
77133                        let response = common::to_response(parts, bytes.into());
77134
77135                        if let common::Retry::After(d) =
77136                            dlg.http_failure(&response, error.as_ref().ok())
77137                        {
77138                            sleep(d).await;
77139                            continue;
77140                        }
77141
77142                        dlg.finished(false);
77143
77144                        return Err(match error {
77145                            Ok(value) => common::Error::BadRequest(value),
77146                            _ => common::Error::Failure(response),
77147                        });
77148                    }
77149                    let response = {
77150                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77151                        let encoded = common::to_string(&bytes);
77152                        match serde_json::from_str(&encoded) {
77153                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
77154                            Err(error) => {
77155                                dlg.response_json_decode_error(&encoded, &error);
77156                                return Err(common::Error::JsonDecodeError(
77157                                    encoded.to_string(),
77158                                    error,
77159                                ));
77160                            }
77161                        }
77162                    };
77163
77164                    dlg.finished(true);
77165                    return Ok(response);
77166                }
77167            }
77168        }
77169    }
77170
77171    /// User profile ID associated with this request.
77172    ///
77173    /// Sets the *profile id* path property to the given value.
77174    ///
77175    /// Even though the property as already been set when instantiating this call,
77176    /// we provide this method for API completeness.
77177    pub fn profile_id(mut self, new_value: i64) -> TargetableRemarketingListListCall<'a, C> {
77178        self._profile_id = new_value;
77179        self
77180    }
77181    /// Select only targetable remarketing lists targetable by these advertisers.
77182    ///
77183    /// Sets the *advertiser id* query property to the given value.
77184    ///
77185    /// Even though the property as already been set when instantiating this call,
77186    /// we provide this method for API completeness.
77187    pub fn advertiser_id(mut self, new_value: i64) -> TargetableRemarketingListListCall<'a, C> {
77188        self._advertiser_id = new_value;
77189        self
77190    }
77191    /// Order of sorted results.
77192    ///
77193    /// Sets the *sort order* query property to the given value.
77194    pub fn sort_order(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C> {
77195        self._sort_order = Some(new_value.to_string());
77196        self
77197    }
77198    /// Field by which to sort the list.
77199    ///
77200    /// Sets the *sort field* query property to the given value.
77201    pub fn sort_field(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C> {
77202        self._sort_field = Some(new_value.to_string());
77203        self
77204    }
77205    /// Value of the nextPageToken from the previous result page.
77206    ///
77207    /// Sets the *page token* query property to the given value.
77208    pub fn page_token(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C> {
77209        self._page_token = Some(new_value.to_string());
77210        self
77211    }
77212    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "remarketing list*2015" will return objects with names like "remarketing list June 2015", "remarketing list April 2015", or simply "remarketing list 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "remarketing list" will match objects with name "my remarketing list", "remarketing list 2015", or simply "remarketing list".
77213    ///
77214    /// Sets the *name* query property to the given value.
77215    pub fn name(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, C> {
77216        self._name = Some(new_value.to_string());
77217        self
77218    }
77219    /// Maximum number of results to return.
77220    ///
77221    /// Sets the *max results* query property to the given value.
77222    pub fn max_results(mut self, new_value: i32) -> TargetableRemarketingListListCall<'a, C> {
77223        self._max_results = Some(new_value);
77224        self
77225    }
77226    /// Select only active or only inactive targetable remarketing lists.
77227    ///
77228    /// Sets the *active* query property to the given value.
77229    pub fn active(mut self, new_value: bool) -> TargetableRemarketingListListCall<'a, C> {
77230        self._active = Some(new_value);
77231        self
77232    }
77233    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
77234    /// while executing the actual API request.
77235    ///
77236    /// ````text
77237    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
77238    /// ````
77239    ///
77240    /// Sets the *delegate* property to the given value.
77241    pub fn delegate(
77242        mut self,
77243        new_value: &'a mut dyn common::Delegate,
77244    ) -> TargetableRemarketingListListCall<'a, C> {
77245        self._delegate = Some(new_value);
77246        self
77247    }
77248
77249    /// Set any additional parameter of the query string used in the request.
77250    /// It should be used to set parameters which are not yet available through their own
77251    /// setters.
77252    ///
77253    /// Please note that this method must not be used to set any of the known parameters
77254    /// which have their own setter method. If done anyway, the request will fail.
77255    ///
77256    /// # Additional Parameters
77257    ///
77258    /// * *alt* (query-string) - Data format for the response.
77259    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
77260    /// * *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.
77261    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
77262    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
77263    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
77264    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
77265    pub fn param<T>(mut self, name: T, value: T) -> TargetableRemarketingListListCall<'a, C>
77266    where
77267        T: AsRef<str>,
77268    {
77269        self._additional_params
77270            .insert(name.as_ref().to_string(), value.as_ref().to_string());
77271        self
77272    }
77273
77274    /// Identifies the authorization scope for the method you are building.
77275    ///
77276    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
77277    /// [`Scope::Dfatrafficking`].
77278    ///
77279    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
77280    /// tokens for more than one scope.
77281    ///
77282    /// Usually there is more than one suitable scope to authorize an operation, some of which may
77283    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
77284    /// sufficient, a read-write scope will do as well.
77285    pub fn add_scope<St>(mut self, scope: St) -> TargetableRemarketingListListCall<'a, C>
77286    where
77287        St: AsRef<str>,
77288    {
77289        self._scopes.insert(String::from(scope.as_ref()));
77290        self
77291    }
77292    /// Identifies the authorization scope(s) for the method you are building.
77293    ///
77294    /// See [`Self::add_scope()`] for details.
77295    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetableRemarketingListListCall<'a, C>
77296    where
77297        I: IntoIterator<Item = St>,
77298        St: AsRef<str>,
77299    {
77300        self._scopes
77301            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
77302        self
77303    }
77304
77305    /// Removes all scopes, and no default scope will be used either.
77306    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
77307    /// for details).
77308    pub fn clear_scopes(mut self) -> TargetableRemarketingListListCall<'a, C> {
77309        self._scopes.clear();
77310        self
77311    }
77312}
77313
77314/// Gets one targeting template by ID.
77315///
77316/// A builder for the *get* method supported by a *targetingTemplate* resource.
77317/// It is not used directly, but through a [`TargetingTemplateMethods`] instance.
77318///
77319/// # Example
77320///
77321/// Instantiate a resource method builder
77322///
77323/// ```test_harness,no_run
77324/// # extern crate hyper;
77325/// # extern crate hyper_rustls;
77326/// # extern crate google_dfareporting3d2 as dfareporting3d2;
77327/// # async fn dox() {
77328/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
77329///
77330/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
77331/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
77332/// #     secret,
77333/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77334/// # ).build().await.unwrap();
77335///
77336/// # let client = hyper_util::client::legacy::Client::builder(
77337/// #     hyper_util::rt::TokioExecutor::new()
77338/// # )
77339/// # .build(
77340/// #     hyper_rustls::HttpsConnectorBuilder::new()
77341/// #         .with_native_roots()
77342/// #         .unwrap()
77343/// #         .https_or_http()
77344/// #         .enable_http1()
77345/// #         .build()
77346/// # );
77347/// # let mut hub = Dfareporting::new(client, auth);
77348/// // You can configure optional parameters by calling the respective setters at will, and
77349/// // execute the final call using `doit()`.
77350/// // Values shown here are possibly random and not representative !
77351/// let result = hub.targeting_templates().get(-25, -11)
77352///              .doit().await;
77353/// # }
77354/// ```
77355pub struct TargetingTemplateGetCall<'a, C>
77356where
77357    C: 'a,
77358{
77359    hub: &'a Dfareporting<C>,
77360    _profile_id: i64,
77361    _id: i64,
77362    _delegate: Option<&'a mut dyn common::Delegate>,
77363    _additional_params: HashMap<String, String>,
77364    _scopes: BTreeSet<String>,
77365}
77366
77367impl<'a, C> common::CallBuilder for TargetingTemplateGetCall<'a, C> {}
77368
77369impl<'a, C> TargetingTemplateGetCall<'a, C>
77370where
77371    C: common::Connector,
77372{
77373    /// Perform the operation you have build so far.
77374    pub async fn doit(mut self) -> common::Result<(common::Response, TargetingTemplate)> {
77375        use std::borrow::Cow;
77376        use std::io::{Read, Seek};
77377
77378        use common::{url::Params, ToParts};
77379        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
77380
77381        let mut dd = common::DefaultDelegate;
77382        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
77383        dlg.begin(common::MethodInfo {
77384            id: "dfareporting.targetingTemplates.get",
77385            http_method: hyper::Method::GET,
77386        });
77387
77388        for &field in ["alt", "profileId", "id"].iter() {
77389            if self._additional_params.contains_key(field) {
77390                dlg.finished(false);
77391                return Err(common::Error::FieldClash(field));
77392            }
77393        }
77394
77395        let mut params = Params::with_capacity(4 + self._additional_params.len());
77396        params.push("profileId", self._profile_id.to_string());
77397        params.push("id", self._id.to_string());
77398
77399        params.extend(self._additional_params.iter());
77400
77401        params.push("alt", "json");
77402        let mut url =
77403            self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates/{id}";
77404        if self._scopes.is_empty() {
77405            self._scopes
77406                .insert(Scope::Dfatrafficking.as_ref().to_string());
77407        }
77408
77409        #[allow(clippy::single_element_loop)]
77410        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
77411            url = params.uri_replacement(url, param_name, find_this, false);
77412        }
77413        {
77414            let to_remove = ["id", "profileId"];
77415            params.remove_params(&to_remove);
77416        }
77417
77418        let url = params.parse_with_url(&url);
77419
77420        loop {
77421            let token = match self
77422                .hub
77423                .auth
77424                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
77425                .await
77426            {
77427                Ok(token) => token,
77428                Err(e) => match dlg.token(e) {
77429                    Ok(token) => token,
77430                    Err(e) => {
77431                        dlg.finished(false);
77432                        return Err(common::Error::MissingToken(e));
77433                    }
77434                },
77435            };
77436            let mut req_result = {
77437                let client = &self.hub.client;
77438                dlg.pre_request();
77439                let mut req_builder = hyper::Request::builder()
77440                    .method(hyper::Method::GET)
77441                    .uri(url.as_str())
77442                    .header(USER_AGENT, self.hub._user_agent.clone());
77443
77444                if let Some(token) = token.as_ref() {
77445                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
77446                }
77447
77448                let request = req_builder
77449                    .header(CONTENT_LENGTH, 0_u64)
77450                    .body(common::to_body::<String>(None));
77451
77452                client.request(request.unwrap()).await
77453            };
77454
77455            match req_result {
77456                Err(err) => {
77457                    if let common::Retry::After(d) = dlg.http_error(&err) {
77458                        sleep(d).await;
77459                        continue;
77460                    }
77461                    dlg.finished(false);
77462                    return Err(common::Error::HttpError(err));
77463                }
77464                Ok(res) => {
77465                    let (mut parts, body) = res.into_parts();
77466                    let mut body = common::Body::new(body);
77467                    if !parts.status.is_success() {
77468                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77469                        let error = serde_json::from_str(&common::to_string(&bytes));
77470                        let response = common::to_response(parts, bytes.into());
77471
77472                        if let common::Retry::After(d) =
77473                            dlg.http_failure(&response, error.as_ref().ok())
77474                        {
77475                            sleep(d).await;
77476                            continue;
77477                        }
77478
77479                        dlg.finished(false);
77480
77481                        return Err(match error {
77482                            Ok(value) => common::Error::BadRequest(value),
77483                            _ => common::Error::Failure(response),
77484                        });
77485                    }
77486                    let response = {
77487                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77488                        let encoded = common::to_string(&bytes);
77489                        match serde_json::from_str(&encoded) {
77490                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
77491                            Err(error) => {
77492                                dlg.response_json_decode_error(&encoded, &error);
77493                                return Err(common::Error::JsonDecodeError(
77494                                    encoded.to_string(),
77495                                    error,
77496                                ));
77497                            }
77498                        }
77499                    };
77500
77501                    dlg.finished(true);
77502                    return Ok(response);
77503                }
77504            }
77505        }
77506    }
77507
77508    /// User profile ID associated with this request.
77509    ///
77510    /// Sets the *profile id* path property to the given value.
77511    ///
77512    /// Even though the property as already been set when instantiating this call,
77513    /// we provide this method for API completeness.
77514    pub fn profile_id(mut self, new_value: i64) -> TargetingTemplateGetCall<'a, C> {
77515        self._profile_id = new_value;
77516        self
77517    }
77518    /// Targeting template ID.
77519    ///
77520    /// Sets the *id* path property to the given value.
77521    ///
77522    /// Even though the property as already been set when instantiating this call,
77523    /// we provide this method for API completeness.
77524    pub fn id(mut self, new_value: i64) -> TargetingTemplateGetCall<'a, C> {
77525        self._id = new_value;
77526        self
77527    }
77528    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
77529    /// while executing the actual API request.
77530    ///
77531    /// ````text
77532    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
77533    /// ````
77534    ///
77535    /// Sets the *delegate* property to the given value.
77536    pub fn delegate(
77537        mut self,
77538        new_value: &'a mut dyn common::Delegate,
77539    ) -> TargetingTemplateGetCall<'a, C> {
77540        self._delegate = Some(new_value);
77541        self
77542    }
77543
77544    /// Set any additional parameter of the query string used in the request.
77545    /// It should be used to set parameters which are not yet available through their own
77546    /// setters.
77547    ///
77548    /// Please note that this method must not be used to set any of the known parameters
77549    /// which have their own setter method. If done anyway, the request will fail.
77550    ///
77551    /// # Additional Parameters
77552    ///
77553    /// * *alt* (query-string) - Data format for the response.
77554    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
77555    /// * *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.
77556    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
77557    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
77558    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
77559    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
77560    pub fn param<T>(mut self, name: T, value: T) -> TargetingTemplateGetCall<'a, C>
77561    where
77562        T: AsRef<str>,
77563    {
77564        self._additional_params
77565            .insert(name.as_ref().to_string(), value.as_ref().to_string());
77566        self
77567    }
77568
77569    /// Identifies the authorization scope for the method you are building.
77570    ///
77571    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
77572    /// [`Scope::Dfatrafficking`].
77573    ///
77574    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
77575    /// tokens for more than one scope.
77576    ///
77577    /// Usually there is more than one suitable scope to authorize an operation, some of which may
77578    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
77579    /// sufficient, a read-write scope will do as well.
77580    pub fn add_scope<St>(mut self, scope: St) -> TargetingTemplateGetCall<'a, C>
77581    where
77582        St: AsRef<str>,
77583    {
77584        self._scopes.insert(String::from(scope.as_ref()));
77585        self
77586    }
77587    /// Identifies the authorization scope(s) for the method you are building.
77588    ///
77589    /// See [`Self::add_scope()`] for details.
77590    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetingTemplateGetCall<'a, C>
77591    where
77592        I: IntoIterator<Item = St>,
77593        St: AsRef<str>,
77594    {
77595        self._scopes
77596            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
77597        self
77598    }
77599
77600    /// Removes all scopes, and no default scope will be used either.
77601    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
77602    /// for details).
77603    pub fn clear_scopes(mut self) -> TargetingTemplateGetCall<'a, C> {
77604        self._scopes.clear();
77605        self
77606    }
77607}
77608
77609/// Inserts a new targeting template.
77610///
77611/// A builder for the *insert* method supported by a *targetingTemplate* resource.
77612/// It is not used directly, but through a [`TargetingTemplateMethods`] instance.
77613///
77614/// # Example
77615///
77616/// Instantiate a resource method builder
77617///
77618/// ```test_harness,no_run
77619/// # extern crate hyper;
77620/// # extern crate hyper_rustls;
77621/// # extern crate google_dfareporting3d2 as dfareporting3d2;
77622/// use dfareporting3d2::api::TargetingTemplate;
77623/// # async fn dox() {
77624/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
77625///
77626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
77627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
77628/// #     secret,
77629/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77630/// # ).build().await.unwrap();
77631///
77632/// # let client = hyper_util::client::legacy::Client::builder(
77633/// #     hyper_util::rt::TokioExecutor::new()
77634/// # )
77635/// # .build(
77636/// #     hyper_rustls::HttpsConnectorBuilder::new()
77637/// #         .with_native_roots()
77638/// #         .unwrap()
77639/// #         .https_or_http()
77640/// #         .enable_http1()
77641/// #         .build()
77642/// # );
77643/// # let mut hub = Dfareporting::new(client, auth);
77644/// // As the method needs a request, you would usually fill it with the desired information
77645/// // into the respective structure. Some of the parts shown here might not be applicable !
77646/// // Values shown here are possibly random and not representative !
77647/// let mut req = TargetingTemplate::default();
77648///
77649/// // You can configure optional parameters by calling the respective setters at will, and
77650/// // execute the final call using `doit()`.
77651/// // Values shown here are possibly random and not representative !
77652/// let result = hub.targeting_templates().insert(req, -63)
77653///              .doit().await;
77654/// # }
77655/// ```
77656pub struct TargetingTemplateInsertCall<'a, C>
77657where
77658    C: 'a,
77659{
77660    hub: &'a Dfareporting<C>,
77661    _request: TargetingTemplate,
77662    _profile_id: i64,
77663    _delegate: Option<&'a mut dyn common::Delegate>,
77664    _additional_params: HashMap<String, String>,
77665    _scopes: BTreeSet<String>,
77666}
77667
77668impl<'a, C> common::CallBuilder for TargetingTemplateInsertCall<'a, C> {}
77669
77670impl<'a, C> TargetingTemplateInsertCall<'a, C>
77671where
77672    C: common::Connector,
77673{
77674    /// Perform the operation you have build so far.
77675    pub async fn doit(mut self) -> common::Result<(common::Response, TargetingTemplate)> {
77676        use std::borrow::Cow;
77677        use std::io::{Read, Seek};
77678
77679        use common::{url::Params, ToParts};
77680        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
77681
77682        let mut dd = common::DefaultDelegate;
77683        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
77684        dlg.begin(common::MethodInfo {
77685            id: "dfareporting.targetingTemplates.insert",
77686            http_method: hyper::Method::POST,
77687        });
77688
77689        for &field in ["alt", "profileId"].iter() {
77690            if self._additional_params.contains_key(field) {
77691                dlg.finished(false);
77692                return Err(common::Error::FieldClash(field));
77693            }
77694        }
77695
77696        let mut params = Params::with_capacity(4 + self._additional_params.len());
77697        params.push("profileId", self._profile_id.to_string());
77698
77699        params.extend(self._additional_params.iter());
77700
77701        params.push("alt", "json");
77702        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates";
77703        if self._scopes.is_empty() {
77704            self._scopes
77705                .insert(Scope::Dfatrafficking.as_ref().to_string());
77706        }
77707
77708        #[allow(clippy::single_element_loop)]
77709        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
77710            url = params.uri_replacement(url, param_name, find_this, false);
77711        }
77712        {
77713            let to_remove = ["profileId"];
77714            params.remove_params(&to_remove);
77715        }
77716
77717        let url = params.parse_with_url(&url);
77718
77719        let mut json_mime_type = mime::APPLICATION_JSON;
77720        let mut request_value_reader = {
77721            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
77722            common::remove_json_null_values(&mut value);
77723            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
77724            serde_json::to_writer(&mut dst, &value).unwrap();
77725            dst
77726        };
77727        let request_size = request_value_reader
77728            .seek(std::io::SeekFrom::End(0))
77729            .unwrap();
77730        request_value_reader
77731            .seek(std::io::SeekFrom::Start(0))
77732            .unwrap();
77733
77734        loop {
77735            let token = match self
77736                .hub
77737                .auth
77738                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
77739                .await
77740            {
77741                Ok(token) => token,
77742                Err(e) => match dlg.token(e) {
77743                    Ok(token) => token,
77744                    Err(e) => {
77745                        dlg.finished(false);
77746                        return Err(common::Error::MissingToken(e));
77747                    }
77748                },
77749            };
77750            request_value_reader
77751                .seek(std::io::SeekFrom::Start(0))
77752                .unwrap();
77753            let mut req_result = {
77754                let client = &self.hub.client;
77755                dlg.pre_request();
77756                let mut req_builder = hyper::Request::builder()
77757                    .method(hyper::Method::POST)
77758                    .uri(url.as_str())
77759                    .header(USER_AGENT, self.hub._user_agent.clone());
77760
77761                if let Some(token) = token.as_ref() {
77762                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
77763                }
77764
77765                let request = req_builder
77766                    .header(CONTENT_TYPE, json_mime_type.to_string())
77767                    .header(CONTENT_LENGTH, request_size as u64)
77768                    .body(common::to_body(
77769                        request_value_reader.get_ref().clone().into(),
77770                    ));
77771
77772                client.request(request.unwrap()).await
77773            };
77774
77775            match req_result {
77776                Err(err) => {
77777                    if let common::Retry::After(d) = dlg.http_error(&err) {
77778                        sleep(d).await;
77779                        continue;
77780                    }
77781                    dlg.finished(false);
77782                    return Err(common::Error::HttpError(err));
77783                }
77784                Ok(res) => {
77785                    let (mut parts, body) = res.into_parts();
77786                    let mut body = common::Body::new(body);
77787                    if !parts.status.is_success() {
77788                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77789                        let error = serde_json::from_str(&common::to_string(&bytes));
77790                        let response = common::to_response(parts, bytes.into());
77791
77792                        if let common::Retry::After(d) =
77793                            dlg.http_failure(&response, error.as_ref().ok())
77794                        {
77795                            sleep(d).await;
77796                            continue;
77797                        }
77798
77799                        dlg.finished(false);
77800
77801                        return Err(match error {
77802                            Ok(value) => common::Error::BadRequest(value),
77803                            _ => common::Error::Failure(response),
77804                        });
77805                    }
77806                    let response = {
77807                        let bytes = common::to_bytes(body).await.unwrap_or_default();
77808                        let encoded = common::to_string(&bytes);
77809                        match serde_json::from_str(&encoded) {
77810                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
77811                            Err(error) => {
77812                                dlg.response_json_decode_error(&encoded, &error);
77813                                return Err(common::Error::JsonDecodeError(
77814                                    encoded.to_string(),
77815                                    error,
77816                                ));
77817                            }
77818                        }
77819                    };
77820
77821                    dlg.finished(true);
77822                    return Ok(response);
77823                }
77824            }
77825        }
77826    }
77827
77828    ///
77829    /// Sets the *request* property to the given value.
77830    ///
77831    /// Even though the property as already been set when instantiating this call,
77832    /// we provide this method for API completeness.
77833    pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplateInsertCall<'a, C> {
77834        self._request = new_value;
77835        self
77836    }
77837    /// User profile ID associated with this request.
77838    ///
77839    /// Sets the *profile id* path property to the given value.
77840    ///
77841    /// Even though the property as already been set when instantiating this call,
77842    /// we provide this method for API completeness.
77843    pub fn profile_id(mut self, new_value: i64) -> TargetingTemplateInsertCall<'a, C> {
77844        self._profile_id = new_value;
77845        self
77846    }
77847    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
77848    /// while executing the actual API request.
77849    ///
77850    /// ````text
77851    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
77852    /// ````
77853    ///
77854    /// Sets the *delegate* property to the given value.
77855    pub fn delegate(
77856        mut self,
77857        new_value: &'a mut dyn common::Delegate,
77858    ) -> TargetingTemplateInsertCall<'a, C> {
77859        self._delegate = Some(new_value);
77860        self
77861    }
77862
77863    /// Set any additional parameter of the query string used in the request.
77864    /// It should be used to set parameters which are not yet available through their own
77865    /// setters.
77866    ///
77867    /// Please note that this method must not be used to set any of the known parameters
77868    /// which have their own setter method. If done anyway, the request will fail.
77869    ///
77870    /// # Additional Parameters
77871    ///
77872    /// * *alt* (query-string) - Data format for the response.
77873    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
77874    /// * *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.
77875    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
77876    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
77877    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
77878    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
77879    pub fn param<T>(mut self, name: T, value: T) -> TargetingTemplateInsertCall<'a, C>
77880    where
77881        T: AsRef<str>,
77882    {
77883        self._additional_params
77884            .insert(name.as_ref().to_string(), value.as_ref().to_string());
77885        self
77886    }
77887
77888    /// Identifies the authorization scope for the method you are building.
77889    ///
77890    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
77891    /// [`Scope::Dfatrafficking`].
77892    ///
77893    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
77894    /// tokens for more than one scope.
77895    ///
77896    /// Usually there is more than one suitable scope to authorize an operation, some of which may
77897    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
77898    /// sufficient, a read-write scope will do as well.
77899    pub fn add_scope<St>(mut self, scope: St) -> TargetingTemplateInsertCall<'a, C>
77900    where
77901        St: AsRef<str>,
77902    {
77903        self._scopes.insert(String::from(scope.as_ref()));
77904        self
77905    }
77906    /// Identifies the authorization scope(s) for the method you are building.
77907    ///
77908    /// See [`Self::add_scope()`] for details.
77909    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetingTemplateInsertCall<'a, C>
77910    where
77911        I: IntoIterator<Item = St>,
77912        St: AsRef<str>,
77913    {
77914        self._scopes
77915            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
77916        self
77917    }
77918
77919    /// Removes all scopes, and no default scope will be used either.
77920    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
77921    /// for details).
77922    pub fn clear_scopes(mut self) -> TargetingTemplateInsertCall<'a, C> {
77923        self._scopes.clear();
77924        self
77925    }
77926}
77927
77928/// Retrieves a list of targeting templates, optionally filtered. This method supports paging.
77929///
77930/// A builder for the *list* method supported by a *targetingTemplate* resource.
77931/// It is not used directly, but through a [`TargetingTemplateMethods`] instance.
77932///
77933/// # Example
77934///
77935/// Instantiate a resource method builder
77936///
77937/// ```test_harness,no_run
77938/// # extern crate hyper;
77939/// # extern crate hyper_rustls;
77940/// # extern crate google_dfareporting3d2 as dfareporting3d2;
77941/// # async fn dox() {
77942/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
77943///
77944/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
77945/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
77946/// #     secret,
77947/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77948/// # ).build().await.unwrap();
77949///
77950/// # let client = hyper_util::client::legacy::Client::builder(
77951/// #     hyper_util::rt::TokioExecutor::new()
77952/// # )
77953/// # .build(
77954/// #     hyper_rustls::HttpsConnectorBuilder::new()
77955/// #         .with_native_roots()
77956/// #         .unwrap()
77957/// #         .https_or_http()
77958/// #         .enable_http1()
77959/// #         .build()
77960/// # );
77961/// # let mut hub = Dfareporting::new(client, auth);
77962/// // You can configure optional parameters by calling the respective setters at will, and
77963/// // execute the final call using `doit()`.
77964/// // Values shown here are possibly random and not representative !
77965/// let result = hub.targeting_templates().list(-58)
77966///              .sort_order("gubergren")
77967///              .sort_field("accusam")
77968///              .search_string("Lorem")
77969///              .page_token("dolor")
77970///              .max_results(-58)
77971///              .add_ids(-10)
77972///              .advertiser_id(-79)
77973///              .doit().await;
77974/// # }
77975/// ```
77976pub struct TargetingTemplateListCall<'a, C>
77977where
77978    C: 'a,
77979{
77980    hub: &'a Dfareporting<C>,
77981    _profile_id: i64,
77982    _sort_order: Option<String>,
77983    _sort_field: Option<String>,
77984    _search_string: Option<String>,
77985    _page_token: Option<String>,
77986    _max_results: Option<i32>,
77987    _ids: Vec<i64>,
77988    _advertiser_id: Option<i64>,
77989    _delegate: Option<&'a mut dyn common::Delegate>,
77990    _additional_params: HashMap<String, String>,
77991    _scopes: BTreeSet<String>,
77992}
77993
77994impl<'a, C> common::CallBuilder for TargetingTemplateListCall<'a, C> {}
77995
77996impl<'a, C> TargetingTemplateListCall<'a, C>
77997where
77998    C: common::Connector,
77999{
78000    /// Perform the operation you have build so far.
78001    pub async fn doit(
78002        mut self,
78003    ) -> common::Result<(common::Response, TargetingTemplatesListResponse)> {
78004        use std::borrow::Cow;
78005        use std::io::{Read, Seek};
78006
78007        use common::{url::Params, ToParts};
78008        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
78009
78010        let mut dd = common::DefaultDelegate;
78011        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
78012        dlg.begin(common::MethodInfo {
78013            id: "dfareporting.targetingTemplates.list",
78014            http_method: hyper::Method::GET,
78015        });
78016
78017        for &field in [
78018            "alt",
78019            "profileId",
78020            "sortOrder",
78021            "sortField",
78022            "searchString",
78023            "pageToken",
78024            "maxResults",
78025            "ids",
78026            "advertiserId",
78027        ]
78028        .iter()
78029        {
78030            if self._additional_params.contains_key(field) {
78031                dlg.finished(false);
78032                return Err(common::Error::FieldClash(field));
78033            }
78034        }
78035
78036        let mut params = Params::with_capacity(10 + self._additional_params.len());
78037        params.push("profileId", self._profile_id.to_string());
78038        if let Some(value) = self._sort_order.as_ref() {
78039            params.push("sortOrder", value);
78040        }
78041        if let Some(value) = self._sort_field.as_ref() {
78042            params.push("sortField", value);
78043        }
78044        if let Some(value) = self._search_string.as_ref() {
78045            params.push("searchString", value);
78046        }
78047        if let Some(value) = self._page_token.as_ref() {
78048            params.push("pageToken", value);
78049        }
78050        if let Some(value) = self._max_results.as_ref() {
78051            params.push("maxResults", value.to_string());
78052        }
78053        if !self._ids.is_empty() {
78054            for f in self._ids.iter() {
78055                params.push("ids", f.to_string());
78056            }
78057        }
78058        if let Some(value) = self._advertiser_id.as_ref() {
78059            params.push("advertiserId", value.to_string());
78060        }
78061
78062        params.extend(self._additional_params.iter());
78063
78064        params.push("alt", "json");
78065        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates";
78066        if self._scopes.is_empty() {
78067            self._scopes
78068                .insert(Scope::Dfatrafficking.as_ref().to_string());
78069        }
78070
78071        #[allow(clippy::single_element_loop)]
78072        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
78073            url = params.uri_replacement(url, param_name, find_this, false);
78074        }
78075        {
78076            let to_remove = ["profileId"];
78077            params.remove_params(&to_remove);
78078        }
78079
78080        let url = params.parse_with_url(&url);
78081
78082        loop {
78083            let token = match self
78084                .hub
78085                .auth
78086                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
78087                .await
78088            {
78089                Ok(token) => token,
78090                Err(e) => match dlg.token(e) {
78091                    Ok(token) => token,
78092                    Err(e) => {
78093                        dlg.finished(false);
78094                        return Err(common::Error::MissingToken(e));
78095                    }
78096                },
78097            };
78098            let mut req_result = {
78099                let client = &self.hub.client;
78100                dlg.pre_request();
78101                let mut req_builder = hyper::Request::builder()
78102                    .method(hyper::Method::GET)
78103                    .uri(url.as_str())
78104                    .header(USER_AGENT, self.hub._user_agent.clone());
78105
78106                if let Some(token) = token.as_ref() {
78107                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
78108                }
78109
78110                let request = req_builder
78111                    .header(CONTENT_LENGTH, 0_u64)
78112                    .body(common::to_body::<String>(None));
78113
78114                client.request(request.unwrap()).await
78115            };
78116
78117            match req_result {
78118                Err(err) => {
78119                    if let common::Retry::After(d) = dlg.http_error(&err) {
78120                        sleep(d).await;
78121                        continue;
78122                    }
78123                    dlg.finished(false);
78124                    return Err(common::Error::HttpError(err));
78125                }
78126                Ok(res) => {
78127                    let (mut parts, body) = res.into_parts();
78128                    let mut body = common::Body::new(body);
78129                    if !parts.status.is_success() {
78130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78131                        let error = serde_json::from_str(&common::to_string(&bytes));
78132                        let response = common::to_response(parts, bytes.into());
78133
78134                        if let common::Retry::After(d) =
78135                            dlg.http_failure(&response, error.as_ref().ok())
78136                        {
78137                            sleep(d).await;
78138                            continue;
78139                        }
78140
78141                        dlg.finished(false);
78142
78143                        return Err(match error {
78144                            Ok(value) => common::Error::BadRequest(value),
78145                            _ => common::Error::Failure(response),
78146                        });
78147                    }
78148                    let response = {
78149                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78150                        let encoded = common::to_string(&bytes);
78151                        match serde_json::from_str(&encoded) {
78152                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
78153                            Err(error) => {
78154                                dlg.response_json_decode_error(&encoded, &error);
78155                                return Err(common::Error::JsonDecodeError(
78156                                    encoded.to_string(),
78157                                    error,
78158                                ));
78159                            }
78160                        }
78161                    };
78162
78163                    dlg.finished(true);
78164                    return Ok(response);
78165                }
78166            }
78167        }
78168    }
78169
78170    /// User profile ID associated with this request.
78171    ///
78172    /// Sets the *profile id* path property to the given value.
78173    ///
78174    /// Even though the property as already been set when instantiating this call,
78175    /// we provide this method for API completeness.
78176    pub fn profile_id(mut self, new_value: i64) -> TargetingTemplateListCall<'a, C> {
78177        self._profile_id = new_value;
78178        self
78179    }
78180    /// Order of sorted results.
78181    ///
78182    /// Sets the *sort order* query property to the given value.
78183    pub fn sort_order(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C> {
78184        self._sort_order = Some(new_value.to_string());
78185        self
78186    }
78187    /// Field by which to sort the list.
78188    ///
78189    /// Sets the *sort field* query property to the given value.
78190    pub fn sort_field(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C> {
78191        self._sort_field = Some(new_value.to_string());
78192        self
78193    }
78194    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "template*2015" will return objects with names like "template June 2015", "template April 2015", or simply "template 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "template" will match objects with name "my template", "template 2015", or simply "template".
78195    ///
78196    /// Sets the *search string* query property to the given value.
78197    pub fn search_string(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C> {
78198        self._search_string = Some(new_value.to_string());
78199        self
78200    }
78201    /// Value of the nextPageToken from the previous result page.
78202    ///
78203    /// Sets the *page token* query property to the given value.
78204    pub fn page_token(mut self, new_value: &str) -> TargetingTemplateListCall<'a, C> {
78205        self._page_token = Some(new_value.to_string());
78206        self
78207    }
78208    /// Maximum number of results to return.
78209    ///
78210    /// Sets the *max results* query property to the given value.
78211    pub fn max_results(mut self, new_value: i32) -> TargetingTemplateListCall<'a, C> {
78212        self._max_results = Some(new_value);
78213        self
78214    }
78215    /// Select only targeting templates with these IDs.
78216    ///
78217    /// Append the given value to the *ids* query property.
78218    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
78219    pub fn add_ids(mut self, new_value: i64) -> TargetingTemplateListCall<'a, C> {
78220        self._ids.push(new_value);
78221        self
78222    }
78223    /// Select only targeting templates with this advertiser ID.
78224    ///
78225    /// Sets the *advertiser id* query property to the given value.
78226    pub fn advertiser_id(mut self, new_value: i64) -> TargetingTemplateListCall<'a, C> {
78227        self._advertiser_id = Some(new_value);
78228        self
78229    }
78230    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
78231    /// while executing the actual API request.
78232    ///
78233    /// ````text
78234    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
78235    /// ````
78236    ///
78237    /// Sets the *delegate* property to the given value.
78238    pub fn delegate(
78239        mut self,
78240        new_value: &'a mut dyn common::Delegate,
78241    ) -> TargetingTemplateListCall<'a, C> {
78242        self._delegate = Some(new_value);
78243        self
78244    }
78245
78246    /// Set any additional parameter of the query string used in the request.
78247    /// It should be used to set parameters which are not yet available through their own
78248    /// setters.
78249    ///
78250    /// Please note that this method must not be used to set any of the known parameters
78251    /// which have their own setter method. If done anyway, the request will fail.
78252    ///
78253    /// # Additional Parameters
78254    ///
78255    /// * *alt* (query-string) - Data format for the response.
78256    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
78257    /// * *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.
78258    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
78259    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
78260    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
78261    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
78262    pub fn param<T>(mut self, name: T, value: T) -> TargetingTemplateListCall<'a, C>
78263    where
78264        T: AsRef<str>,
78265    {
78266        self._additional_params
78267            .insert(name.as_ref().to_string(), value.as_ref().to_string());
78268        self
78269    }
78270
78271    /// Identifies the authorization scope for the method you are building.
78272    ///
78273    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
78274    /// [`Scope::Dfatrafficking`].
78275    ///
78276    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
78277    /// tokens for more than one scope.
78278    ///
78279    /// Usually there is more than one suitable scope to authorize an operation, some of which may
78280    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
78281    /// sufficient, a read-write scope will do as well.
78282    pub fn add_scope<St>(mut self, scope: St) -> TargetingTemplateListCall<'a, C>
78283    where
78284        St: AsRef<str>,
78285    {
78286        self._scopes.insert(String::from(scope.as_ref()));
78287        self
78288    }
78289    /// Identifies the authorization scope(s) for the method you are building.
78290    ///
78291    /// See [`Self::add_scope()`] for details.
78292    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetingTemplateListCall<'a, C>
78293    where
78294        I: IntoIterator<Item = St>,
78295        St: AsRef<str>,
78296    {
78297        self._scopes
78298            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
78299        self
78300    }
78301
78302    /// Removes all scopes, and no default scope will be used either.
78303    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
78304    /// for details).
78305    pub fn clear_scopes(mut self) -> TargetingTemplateListCall<'a, C> {
78306        self._scopes.clear();
78307        self
78308    }
78309}
78310
78311/// Updates an existing targeting template. This method supports patch semantics.
78312///
78313/// A builder for the *patch* method supported by a *targetingTemplate* resource.
78314/// It is not used directly, but through a [`TargetingTemplateMethods`] instance.
78315///
78316/// # Example
78317///
78318/// Instantiate a resource method builder
78319///
78320/// ```test_harness,no_run
78321/// # extern crate hyper;
78322/// # extern crate hyper_rustls;
78323/// # extern crate google_dfareporting3d2 as dfareporting3d2;
78324/// use dfareporting3d2::api::TargetingTemplate;
78325/// # async fn dox() {
78326/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
78327///
78328/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
78329/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
78330/// #     secret,
78331/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
78332/// # ).build().await.unwrap();
78333///
78334/// # let client = hyper_util::client::legacy::Client::builder(
78335/// #     hyper_util::rt::TokioExecutor::new()
78336/// # )
78337/// # .build(
78338/// #     hyper_rustls::HttpsConnectorBuilder::new()
78339/// #         .with_native_roots()
78340/// #         .unwrap()
78341/// #         .https_or_http()
78342/// #         .enable_http1()
78343/// #         .build()
78344/// # );
78345/// # let mut hub = Dfareporting::new(client, auth);
78346/// // As the method needs a request, you would usually fill it with the desired information
78347/// // into the respective structure. Some of the parts shown here might not be applicable !
78348/// // Values shown here are possibly random and not representative !
78349/// let mut req = TargetingTemplate::default();
78350///
78351/// // You can configure optional parameters by calling the respective setters at will, and
78352/// // execute the final call using `doit()`.
78353/// // Values shown here are possibly random and not representative !
78354/// let result = hub.targeting_templates().patch(req, -97, -33)
78355///              .doit().await;
78356/// # }
78357/// ```
78358pub struct TargetingTemplatePatchCall<'a, C>
78359where
78360    C: 'a,
78361{
78362    hub: &'a Dfareporting<C>,
78363    _request: TargetingTemplate,
78364    _profile_id: i64,
78365    _id: i64,
78366    _delegate: Option<&'a mut dyn common::Delegate>,
78367    _additional_params: HashMap<String, String>,
78368    _scopes: BTreeSet<String>,
78369}
78370
78371impl<'a, C> common::CallBuilder for TargetingTemplatePatchCall<'a, C> {}
78372
78373impl<'a, C> TargetingTemplatePatchCall<'a, C>
78374where
78375    C: common::Connector,
78376{
78377    /// Perform the operation you have build so far.
78378    pub async fn doit(mut self) -> common::Result<(common::Response, TargetingTemplate)> {
78379        use std::borrow::Cow;
78380        use std::io::{Read, Seek};
78381
78382        use common::{url::Params, ToParts};
78383        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
78384
78385        let mut dd = common::DefaultDelegate;
78386        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
78387        dlg.begin(common::MethodInfo {
78388            id: "dfareporting.targetingTemplates.patch",
78389            http_method: hyper::Method::PATCH,
78390        });
78391
78392        for &field in ["alt", "profileId", "id"].iter() {
78393            if self._additional_params.contains_key(field) {
78394                dlg.finished(false);
78395                return Err(common::Error::FieldClash(field));
78396            }
78397        }
78398
78399        let mut params = Params::with_capacity(5 + self._additional_params.len());
78400        params.push("profileId", self._profile_id.to_string());
78401        params.push("id", self._id.to_string());
78402
78403        params.extend(self._additional_params.iter());
78404
78405        params.push("alt", "json");
78406        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates";
78407        if self._scopes.is_empty() {
78408            self._scopes
78409                .insert(Scope::Dfatrafficking.as_ref().to_string());
78410        }
78411
78412        #[allow(clippy::single_element_loop)]
78413        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
78414            url = params.uri_replacement(url, param_name, find_this, false);
78415        }
78416        {
78417            let to_remove = ["profileId"];
78418            params.remove_params(&to_remove);
78419        }
78420
78421        let url = params.parse_with_url(&url);
78422
78423        let mut json_mime_type = mime::APPLICATION_JSON;
78424        let mut request_value_reader = {
78425            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
78426            common::remove_json_null_values(&mut value);
78427            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
78428            serde_json::to_writer(&mut dst, &value).unwrap();
78429            dst
78430        };
78431        let request_size = request_value_reader
78432            .seek(std::io::SeekFrom::End(0))
78433            .unwrap();
78434        request_value_reader
78435            .seek(std::io::SeekFrom::Start(0))
78436            .unwrap();
78437
78438        loop {
78439            let token = match self
78440                .hub
78441                .auth
78442                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
78443                .await
78444            {
78445                Ok(token) => token,
78446                Err(e) => match dlg.token(e) {
78447                    Ok(token) => token,
78448                    Err(e) => {
78449                        dlg.finished(false);
78450                        return Err(common::Error::MissingToken(e));
78451                    }
78452                },
78453            };
78454            request_value_reader
78455                .seek(std::io::SeekFrom::Start(0))
78456                .unwrap();
78457            let mut req_result = {
78458                let client = &self.hub.client;
78459                dlg.pre_request();
78460                let mut req_builder = hyper::Request::builder()
78461                    .method(hyper::Method::PATCH)
78462                    .uri(url.as_str())
78463                    .header(USER_AGENT, self.hub._user_agent.clone());
78464
78465                if let Some(token) = token.as_ref() {
78466                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
78467                }
78468
78469                let request = req_builder
78470                    .header(CONTENT_TYPE, json_mime_type.to_string())
78471                    .header(CONTENT_LENGTH, request_size as u64)
78472                    .body(common::to_body(
78473                        request_value_reader.get_ref().clone().into(),
78474                    ));
78475
78476                client.request(request.unwrap()).await
78477            };
78478
78479            match req_result {
78480                Err(err) => {
78481                    if let common::Retry::After(d) = dlg.http_error(&err) {
78482                        sleep(d).await;
78483                        continue;
78484                    }
78485                    dlg.finished(false);
78486                    return Err(common::Error::HttpError(err));
78487                }
78488                Ok(res) => {
78489                    let (mut parts, body) = res.into_parts();
78490                    let mut body = common::Body::new(body);
78491                    if !parts.status.is_success() {
78492                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78493                        let error = serde_json::from_str(&common::to_string(&bytes));
78494                        let response = common::to_response(parts, bytes.into());
78495
78496                        if let common::Retry::After(d) =
78497                            dlg.http_failure(&response, error.as_ref().ok())
78498                        {
78499                            sleep(d).await;
78500                            continue;
78501                        }
78502
78503                        dlg.finished(false);
78504
78505                        return Err(match error {
78506                            Ok(value) => common::Error::BadRequest(value),
78507                            _ => common::Error::Failure(response),
78508                        });
78509                    }
78510                    let response = {
78511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78512                        let encoded = common::to_string(&bytes);
78513                        match serde_json::from_str(&encoded) {
78514                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
78515                            Err(error) => {
78516                                dlg.response_json_decode_error(&encoded, &error);
78517                                return Err(common::Error::JsonDecodeError(
78518                                    encoded.to_string(),
78519                                    error,
78520                                ));
78521                            }
78522                        }
78523                    };
78524
78525                    dlg.finished(true);
78526                    return Ok(response);
78527                }
78528            }
78529        }
78530    }
78531
78532    ///
78533    /// Sets the *request* property to the given value.
78534    ///
78535    /// Even though the property as already been set when instantiating this call,
78536    /// we provide this method for API completeness.
78537    pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplatePatchCall<'a, C> {
78538        self._request = new_value;
78539        self
78540    }
78541    /// User profile ID associated with this request.
78542    ///
78543    /// Sets the *profile id* path property to the given value.
78544    ///
78545    /// Even though the property as already been set when instantiating this call,
78546    /// we provide this method for API completeness.
78547    pub fn profile_id(mut self, new_value: i64) -> TargetingTemplatePatchCall<'a, C> {
78548        self._profile_id = new_value;
78549        self
78550    }
78551    /// Targeting template ID.
78552    ///
78553    /// Sets the *id* query property to the given value.
78554    ///
78555    /// Even though the property as already been set when instantiating this call,
78556    /// we provide this method for API completeness.
78557    pub fn id(mut self, new_value: i64) -> TargetingTemplatePatchCall<'a, C> {
78558        self._id = new_value;
78559        self
78560    }
78561    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
78562    /// while executing the actual API request.
78563    ///
78564    /// ````text
78565    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
78566    /// ````
78567    ///
78568    /// Sets the *delegate* property to the given value.
78569    pub fn delegate(
78570        mut self,
78571        new_value: &'a mut dyn common::Delegate,
78572    ) -> TargetingTemplatePatchCall<'a, C> {
78573        self._delegate = Some(new_value);
78574        self
78575    }
78576
78577    /// Set any additional parameter of the query string used in the request.
78578    /// It should be used to set parameters which are not yet available through their own
78579    /// setters.
78580    ///
78581    /// Please note that this method must not be used to set any of the known parameters
78582    /// which have their own setter method. If done anyway, the request will fail.
78583    ///
78584    /// # Additional Parameters
78585    ///
78586    /// * *alt* (query-string) - Data format for the response.
78587    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
78588    /// * *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.
78589    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
78590    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
78591    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
78592    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
78593    pub fn param<T>(mut self, name: T, value: T) -> TargetingTemplatePatchCall<'a, C>
78594    where
78595        T: AsRef<str>,
78596    {
78597        self._additional_params
78598            .insert(name.as_ref().to_string(), value.as_ref().to_string());
78599        self
78600    }
78601
78602    /// Identifies the authorization scope for the method you are building.
78603    ///
78604    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
78605    /// [`Scope::Dfatrafficking`].
78606    ///
78607    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
78608    /// tokens for more than one scope.
78609    ///
78610    /// Usually there is more than one suitable scope to authorize an operation, some of which may
78611    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
78612    /// sufficient, a read-write scope will do as well.
78613    pub fn add_scope<St>(mut self, scope: St) -> TargetingTemplatePatchCall<'a, C>
78614    where
78615        St: AsRef<str>,
78616    {
78617        self._scopes.insert(String::from(scope.as_ref()));
78618        self
78619    }
78620    /// Identifies the authorization scope(s) for the method you are building.
78621    ///
78622    /// See [`Self::add_scope()`] for details.
78623    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetingTemplatePatchCall<'a, C>
78624    where
78625        I: IntoIterator<Item = St>,
78626        St: AsRef<str>,
78627    {
78628        self._scopes
78629            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
78630        self
78631    }
78632
78633    /// Removes all scopes, and no default scope will be used either.
78634    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
78635    /// for details).
78636    pub fn clear_scopes(mut self) -> TargetingTemplatePatchCall<'a, C> {
78637        self._scopes.clear();
78638        self
78639    }
78640}
78641
78642/// Updates an existing targeting template.
78643///
78644/// A builder for the *update* method supported by a *targetingTemplate* resource.
78645/// It is not used directly, but through a [`TargetingTemplateMethods`] instance.
78646///
78647/// # Example
78648///
78649/// Instantiate a resource method builder
78650///
78651/// ```test_harness,no_run
78652/// # extern crate hyper;
78653/// # extern crate hyper_rustls;
78654/// # extern crate google_dfareporting3d2 as dfareporting3d2;
78655/// use dfareporting3d2::api::TargetingTemplate;
78656/// # async fn dox() {
78657/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
78658///
78659/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
78660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
78661/// #     secret,
78662/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
78663/// # ).build().await.unwrap();
78664///
78665/// # let client = hyper_util::client::legacy::Client::builder(
78666/// #     hyper_util::rt::TokioExecutor::new()
78667/// # )
78668/// # .build(
78669/// #     hyper_rustls::HttpsConnectorBuilder::new()
78670/// #         .with_native_roots()
78671/// #         .unwrap()
78672/// #         .https_or_http()
78673/// #         .enable_http1()
78674/// #         .build()
78675/// # );
78676/// # let mut hub = Dfareporting::new(client, auth);
78677/// // As the method needs a request, you would usually fill it with the desired information
78678/// // into the respective structure. Some of the parts shown here might not be applicable !
78679/// // Values shown here are possibly random and not representative !
78680/// let mut req = TargetingTemplate::default();
78681///
78682/// // You can configure optional parameters by calling the respective setters at will, and
78683/// // execute the final call using `doit()`.
78684/// // Values shown here are possibly random and not representative !
78685/// let result = hub.targeting_templates().update(req, -23)
78686///              .doit().await;
78687/// # }
78688/// ```
78689pub struct TargetingTemplateUpdateCall<'a, C>
78690where
78691    C: 'a,
78692{
78693    hub: &'a Dfareporting<C>,
78694    _request: TargetingTemplate,
78695    _profile_id: i64,
78696    _delegate: Option<&'a mut dyn common::Delegate>,
78697    _additional_params: HashMap<String, String>,
78698    _scopes: BTreeSet<String>,
78699}
78700
78701impl<'a, C> common::CallBuilder for TargetingTemplateUpdateCall<'a, C> {}
78702
78703impl<'a, C> TargetingTemplateUpdateCall<'a, C>
78704where
78705    C: common::Connector,
78706{
78707    /// Perform the operation you have build so far.
78708    pub async fn doit(mut self) -> common::Result<(common::Response, TargetingTemplate)> {
78709        use std::borrow::Cow;
78710        use std::io::{Read, Seek};
78711
78712        use common::{url::Params, ToParts};
78713        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
78714
78715        let mut dd = common::DefaultDelegate;
78716        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
78717        dlg.begin(common::MethodInfo {
78718            id: "dfareporting.targetingTemplates.update",
78719            http_method: hyper::Method::PUT,
78720        });
78721
78722        for &field in ["alt", "profileId"].iter() {
78723            if self._additional_params.contains_key(field) {
78724                dlg.finished(false);
78725                return Err(common::Error::FieldClash(field));
78726            }
78727        }
78728
78729        let mut params = Params::with_capacity(4 + self._additional_params.len());
78730        params.push("profileId", self._profile_id.to_string());
78731
78732        params.extend(self._additional_params.iter());
78733
78734        params.push("alt", "json");
78735        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates";
78736        if self._scopes.is_empty() {
78737            self._scopes
78738                .insert(Scope::Dfatrafficking.as_ref().to_string());
78739        }
78740
78741        #[allow(clippy::single_element_loop)]
78742        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
78743            url = params.uri_replacement(url, param_name, find_this, false);
78744        }
78745        {
78746            let to_remove = ["profileId"];
78747            params.remove_params(&to_remove);
78748        }
78749
78750        let url = params.parse_with_url(&url);
78751
78752        let mut json_mime_type = mime::APPLICATION_JSON;
78753        let mut request_value_reader = {
78754            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
78755            common::remove_json_null_values(&mut value);
78756            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
78757            serde_json::to_writer(&mut dst, &value).unwrap();
78758            dst
78759        };
78760        let request_size = request_value_reader
78761            .seek(std::io::SeekFrom::End(0))
78762            .unwrap();
78763        request_value_reader
78764            .seek(std::io::SeekFrom::Start(0))
78765            .unwrap();
78766
78767        loop {
78768            let token = match self
78769                .hub
78770                .auth
78771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
78772                .await
78773            {
78774                Ok(token) => token,
78775                Err(e) => match dlg.token(e) {
78776                    Ok(token) => token,
78777                    Err(e) => {
78778                        dlg.finished(false);
78779                        return Err(common::Error::MissingToken(e));
78780                    }
78781                },
78782            };
78783            request_value_reader
78784                .seek(std::io::SeekFrom::Start(0))
78785                .unwrap();
78786            let mut req_result = {
78787                let client = &self.hub.client;
78788                dlg.pre_request();
78789                let mut req_builder = hyper::Request::builder()
78790                    .method(hyper::Method::PUT)
78791                    .uri(url.as_str())
78792                    .header(USER_AGENT, self.hub._user_agent.clone());
78793
78794                if let Some(token) = token.as_ref() {
78795                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
78796                }
78797
78798                let request = req_builder
78799                    .header(CONTENT_TYPE, json_mime_type.to_string())
78800                    .header(CONTENT_LENGTH, request_size as u64)
78801                    .body(common::to_body(
78802                        request_value_reader.get_ref().clone().into(),
78803                    ));
78804
78805                client.request(request.unwrap()).await
78806            };
78807
78808            match req_result {
78809                Err(err) => {
78810                    if let common::Retry::After(d) = dlg.http_error(&err) {
78811                        sleep(d).await;
78812                        continue;
78813                    }
78814                    dlg.finished(false);
78815                    return Err(common::Error::HttpError(err));
78816                }
78817                Ok(res) => {
78818                    let (mut parts, body) = res.into_parts();
78819                    let mut body = common::Body::new(body);
78820                    if !parts.status.is_success() {
78821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78822                        let error = serde_json::from_str(&common::to_string(&bytes));
78823                        let response = common::to_response(parts, bytes.into());
78824
78825                        if let common::Retry::After(d) =
78826                            dlg.http_failure(&response, error.as_ref().ok())
78827                        {
78828                            sleep(d).await;
78829                            continue;
78830                        }
78831
78832                        dlg.finished(false);
78833
78834                        return Err(match error {
78835                            Ok(value) => common::Error::BadRequest(value),
78836                            _ => common::Error::Failure(response),
78837                        });
78838                    }
78839                    let response = {
78840                        let bytes = common::to_bytes(body).await.unwrap_or_default();
78841                        let encoded = common::to_string(&bytes);
78842                        match serde_json::from_str(&encoded) {
78843                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
78844                            Err(error) => {
78845                                dlg.response_json_decode_error(&encoded, &error);
78846                                return Err(common::Error::JsonDecodeError(
78847                                    encoded.to_string(),
78848                                    error,
78849                                ));
78850                            }
78851                        }
78852                    };
78853
78854                    dlg.finished(true);
78855                    return Ok(response);
78856                }
78857            }
78858        }
78859    }
78860
78861    ///
78862    /// Sets the *request* property to the given value.
78863    ///
78864    /// Even though the property as already been set when instantiating this call,
78865    /// we provide this method for API completeness.
78866    pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplateUpdateCall<'a, C> {
78867        self._request = new_value;
78868        self
78869    }
78870    /// User profile ID associated with this request.
78871    ///
78872    /// Sets the *profile id* path property to the given value.
78873    ///
78874    /// Even though the property as already been set when instantiating this call,
78875    /// we provide this method for API completeness.
78876    pub fn profile_id(mut self, new_value: i64) -> TargetingTemplateUpdateCall<'a, C> {
78877        self._profile_id = new_value;
78878        self
78879    }
78880    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
78881    /// while executing the actual API request.
78882    ///
78883    /// ````text
78884    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
78885    /// ````
78886    ///
78887    /// Sets the *delegate* property to the given value.
78888    pub fn delegate(
78889        mut self,
78890        new_value: &'a mut dyn common::Delegate,
78891    ) -> TargetingTemplateUpdateCall<'a, C> {
78892        self._delegate = Some(new_value);
78893        self
78894    }
78895
78896    /// Set any additional parameter of the query string used in the request.
78897    /// It should be used to set parameters which are not yet available through their own
78898    /// setters.
78899    ///
78900    /// Please note that this method must not be used to set any of the known parameters
78901    /// which have their own setter method. If done anyway, the request will fail.
78902    ///
78903    /// # Additional Parameters
78904    ///
78905    /// * *alt* (query-string) - Data format for the response.
78906    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
78907    /// * *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.
78908    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
78909    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
78910    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
78911    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
78912    pub fn param<T>(mut self, name: T, value: T) -> TargetingTemplateUpdateCall<'a, C>
78913    where
78914        T: AsRef<str>,
78915    {
78916        self._additional_params
78917            .insert(name.as_ref().to_string(), value.as_ref().to_string());
78918        self
78919    }
78920
78921    /// Identifies the authorization scope for the method you are building.
78922    ///
78923    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
78924    /// [`Scope::Dfatrafficking`].
78925    ///
78926    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
78927    /// tokens for more than one scope.
78928    ///
78929    /// Usually there is more than one suitable scope to authorize an operation, some of which may
78930    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
78931    /// sufficient, a read-write scope will do as well.
78932    pub fn add_scope<St>(mut self, scope: St) -> TargetingTemplateUpdateCall<'a, C>
78933    where
78934        St: AsRef<str>,
78935    {
78936        self._scopes.insert(String::from(scope.as_ref()));
78937        self
78938    }
78939    /// Identifies the authorization scope(s) for the method you are building.
78940    ///
78941    /// See [`Self::add_scope()`] for details.
78942    pub fn add_scopes<I, St>(mut self, scopes: I) -> TargetingTemplateUpdateCall<'a, C>
78943    where
78944        I: IntoIterator<Item = St>,
78945        St: AsRef<str>,
78946    {
78947        self._scopes
78948            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
78949        self
78950    }
78951
78952    /// Removes all scopes, and no default scope will be used either.
78953    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
78954    /// for details).
78955    pub fn clear_scopes(mut self) -> TargetingTemplateUpdateCall<'a, C> {
78956        self._scopes.clear();
78957        self
78958    }
78959}
78960
78961/// Gets one user profile by ID.
78962///
78963/// A builder for the *get* method supported by a *userProfile* resource.
78964/// It is not used directly, but through a [`UserProfileMethods`] instance.
78965///
78966/// # Example
78967///
78968/// Instantiate a resource method builder
78969///
78970/// ```test_harness,no_run
78971/// # extern crate hyper;
78972/// # extern crate hyper_rustls;
78973/// # extern crate google_dfareporting3d2 as dfareporting3d2;
78974/// # async fn dox() {
78975/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
78976///
78977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
78978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
78979/// #     secret,
78980/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
78981/// # ).build().await.unwrap();
78982///
78983/// # let client = hyper_util::client::legacy::Client::builder(
78984/// #     hyper_util::rt::TokioExecutor::new()
78985/// # )
78986/// # .build(
78987/// #     hyper_rustls::HttpsConnectorBuilder::new()
78988/// #         .with_native_roots()
78989/// #         .unwrap()
78990/// #         .https_or_http()
78991/// #         .enable_http1()
78992/// #         .build()
78993/// # );
78994/// # let mut hub = Dfareporting::new(client, auth);
78995/// // You can configure optional parameters by calling the respective setters at will, and
78996/// // execute the final call using `doit()`.
78997/// // Values shown here are possibly random and not representative !
78998/// let result = hub.user_profiles().get(-51)
78999///              .doit().await;
79000/// # }
79001/// ```
79002pub struct UserProfileGetCall<'a, C>
79003where
79004    C: 'a,
79005{
79006    hub: &'a Dfareporting<C>,
79007    _profile_id: i64,
79008    _delegate: Option<&'a mut dyn common::Delegate>,
79009    _additional_params: HashMap<String, String>,
79010    _scopes: BTreeSet<String>,
79011}
79012
79013impl<'a, C> common::CallBuilder for UserProfileGetCall<'a, C> {}
79014
79015impl<'a, C> UserProfileGetCall<'a, C>
79016where
79017    C: common::Connector,
79018{
79019    /// Perform the operation you have build so far.
79020    pub async fn doit(mut self) -> common::Result<(common::Response, UserProfile)> {
79021        use std::borrow::Cow;
79022        use std::io::{Read, Seek};
79023
79024        use common::{url::Params, ToParts};
79025        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
79026
79027        let mut dd = common::DefaultDelegate;
79028        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
79029        dlg.begin(common::MethodInfo {
79030            id: "dfareporting.userProfiles.get",
79031            http_method: hyper::Method::GET,
79032        });
79033
79034        for &field in ["alt", "profileId"].iter() {
79035            if self._additional_params.contains_key(field) {
79036                dlg.finished(false);
79037                return Err(common::Error::FieldClash(field));
79038            }
79039        }
79040
79041        let mut params = Params::with_capacity(3 + self._additional_params.len());
79042        params.push("profileId", self._profile_id.to_string());
79043
79044        params.extend(self._additional_params.iter());
79045
79046        params.push("alt", "json");
79047        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}";
79048        if self._scopes.is_empty() {
79049            self._scopes.insert(Scope::Full.as_ref().to_string());
79050        }
79051
79052        #[allow(clippy::single_element_loop)]
79053        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
79054            url = params.uri_replacement(url, param_name, find_this, false);
79055        }
79056        {
79057            let to_remove = ["profileId"];
79058            params.remove_params(&to_remove);
79059        }
79060
79061        let url = params.parse_with_url(&url);
79062
79063        loop {
79064            let token = match self
79065                .hub
79066                .auth
79067                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
79068                .await
79069            {
79070                Ok(token) => token,
79071                Err(e) => match dlg.token(e) {
79072                    Ok(token) => token,
79073                    Err(e) => {
79074                        dlg.finished(false);
79075                        return Err(common::Error::MissingToken(e));
79076                    }
79077                },
79078            };
79079            let mut req_result = {
79080                let client = &self.hub.client;
79081                dlg.pre_request();
79082                let mut req_builder = hyper::Request::builder()
79083                    .method(hyper::Method::GET)
79084                    .uri(url.as_str())
79085                    .header(USER_AGENT, self.hub._user_agent.clone());
79086
79087                if let Some(token) = token.as_ref() {
79088                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
79089                }
79090
79091                let request = req_builder
79092                    .header(CONTENT_LENGTH, 0_u64)
79093                    .body(common::to_body::<String>(None));
79094
79095                client.request(request.unwrap()).await
79096            };
79097
79098            match req_result {
79099                Err(err) => {
79100                    if let common::Retry::After(d) = dlg.http_error(&err) {
79101                        sleep(d).await;
79102                        continue;
79103                    }
79104                    dlg.finished(false);
79105                    return Err(common::Error::HttpError(err));
79106                }
79107                Ok(res) => {
79108                    let (mut parts, body) = res.into_parts();
79109                    let mut body = common::Body::new(body);
79110                    if !parts.status.is_success() {
79111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79112                        let error = serde_json::from_str(&common::to_string(&bytes));
79113                        let response = common::to_response(parts, bytes.into());
79114
79115                        if let common::Retry::After(d) =
79116                            dlg.http_failure(&response, error.as_ref().ok())
79117                        {
79118                            sleep(d).await;
79119                            continue;
79120                        }
79121
79122                        dlg.finished(false);
79123
79124                        return Err(match error {
79125                            Ok(value) => common::Error::BadRequest(value),
79126                            _ => common::Error::Failure(response),
79127                        });
79128                    }
79129                    let response = {
79130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79131                        let encoded = common::to_string(&bytes);
79132                        match serde_json::from_str(&encoded) {
79133                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
79134                            Err(error) => {
79135                                dlg.response_json_decode_error(&encoded, &error);
79136                                return Err(common::Error::JsonDecodeError(
79137                                    encoded.to_string(),
79138                                    error,
79139                                ));
79140                            }
79141                        }
79142                    };
79143
79144                    dlg.finished(true);
79145                    return Ok(response);
79146                }
79147            }
79148        }
79149    }
79150
79151    /// The user profile ID.
79152    ///
79153    /// Sets the *profile id* path property to the given value.
79154    ///
79155    /// Even though the property as already been set when instantiating this call,
79156    /// we provide this method for API completeness.
79157    pub fn profile_id(mut self, new_value: i64) -> UserProfileGetCall<'a, C> {
79158        self._profile_id = new_value;
79159        self
79160    }
79161    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
79162    /// while executing the actual API request.
79163    ///
79164    /// ````text
79165    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
79166    /// ````
79167    ///
79168    /// Sets the *delegate* property to the given value.
79169    pub fn delegate(
79170        mut self,
79171        new_value: &'a mut dyn common::Delegate,
79172    ) -> UserProfileGetCall<'a, C> {
79173        self._delegate = Some(new_value);
79174        self
79175    }
79176
79177    /// Set any additional parameter of the query string used in the request.
79178    /// It should be used to set parameters which are not yet available through their own
79179    /// setters.
79180    ///
79181    /// Please note that this method must not be used to set any of the known parameters
79182    /// which have their own setter method. If done anyway, the request will fail.
79183    ///
79184    /// # Additional Parameters
79185    ///
79186    /// * *alt* (query-string) - Data format for the response.
79187    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
79188    /// * *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.
79189    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
79190    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
79191    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
79192    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
79193    pub fn param<T>(mut self, name: T, value: T) -> UserProfileGetCall<'a, C>
79194    where
79195        T: AsRef<str>,
79196    {
79197        self._additional_params
79198            .insert(name.as_ref().to_string(), value.as_ref().to_string());
79199        self
79200    }
79201
79202    /// Identifies the authorization scope for the method you are building.
79203    ///
79204    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
79205    /// [`Scope::Full`].
79206    ///
79207    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
79208    /// tokens for more than one scope.
79209    ///
79210    /// Usually there is more than one suitable scope to authorize an operation, some of which may
79211    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
79212    /// sufficient, a read-write scope will do as well.
79213    pub fn add_scope<St>(mut self, scope: St) -> UserProfileGetCall<'a, C>
79214    where
79215        St: AsRef<str>,
79216    {
79217        self._scopes.insert(String::from(scope.as_ref()));
79218        self
79219    }
79220    /// Identifies the authorization scope(s) for the method you are building.
79221    ///
79222    /// See [`Self::add_scope()`] for details.
79223    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileGetCall<'a, C>
79224    where
79225        I: IntoIterator<Item = St>,
79226        St: AsRef<str>,
79227    {
79228        self._scopes
79229            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
79230        self
79231    }
79232
79233    /// Removes all scopes, and no default scope will be used either.
79234    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
79235    /// for details).
79236    pub fn clear_scopes(mut self) -> UserProfileGetCall<'a, C> {
79237        self._scopes.clear();
79238        self
79239    }
79240}
79241
79242/// Retrieves list of user profiles for a user.
79243///
79244/// A builder for the *list* method supported by a *userProfile* resource.
79245/// It is not used directly, but through a [`UserProfileMethods`] instance.
79246///
79247/// # Example
79248///
79249/// Instantiate a resource method builder
79250///
79251/// ```test_harness,no_run
79252/// # extern crate hyper;
79253/// # extern crate hyper_rustls;
79254/// # extern crate google_dfareporting3d2 as dfareporting3d2;
79255/// # async fn dox() {
79256/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
79257///
79258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
79259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
79260/// #     secret,
79261/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
79262/// # ).build().await.unwrap();
79263///
79264/// # let client = hyper_util::client::legacy::Client::builder(
79265/// #     hyper_util::rt::TokioExecutor::new()
79266/// # )
79267/// # .build(
79268/// #     hyper_rustls::HttpsConnectorBuilder::new()
79269/// #         .with_native_roots()
79270/// #         .unwrap()
79271/// #         .https_or_http()
79272/// #         .enable_http1()
79273/// #         .build()
79274/// # );
79275/// # let mut hub = Dfareporting::new(client, auth);
79276/// // You can configure optional parameters by calling the respective setters at will, and
79277/// // execute the final call using `doit()`.
79278/// // Values shown here are possibly random and not representative !
79279/// let result = hub.user_profiles().list()
79280///              .doit().await;
79281/// # }
79282/// ```
79283pub struct UserProfileListCall<'a, C>
79284where
79285    C: 'a,
79286{
79287    hub: &'a Dfareporting<C>,
79288    _delegate: Option<&'a mut dyn common::Delegate>,
79289    _additional_params: HashMap<String, String>,
79290    _scopes: BTreeSet<String>,
79291}
79292
79293impl<'a, C> common::CallBuilder for UserProfileListCall<'a, C> {}
79294
79295impl<'a, C> UserProfileListCall<'a, C>
79296where
79297    C: common::Connector,
79298{
79299    /// Perform the operation you have build so far.
79300    pub async fn doit(mut self) -> common::Result<(common::Response, UserProfileList)> {
79301        use std::borrow::Cow;
79302        use std::io::{Read, Seek};
79303
79304        use common::{url::Params, ToParts};
79305        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
79306
79307        let mut dd = common::DefaultDelegate;
79308        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
79309        dlg.begin(common::MethodInfo {
79310            id: "dfareporting.userProfiles.list",
79311            http_method: hyper::Method::GET,
79312        });
79313
79314        for &field in ["alt"].iter() {
79315            if self._additional_params.contains_key(field) {
79316                dlg.finished(false);
79317                return Err(common::Error::FieldClash(field));
79318            }
79319        }
79320
79321        let mut params = Params::with_capacity(2 + self._additional_params.len());
79322
79323        params.extend(self._additional_params.iter());
79324
79325        params.push("alt", "json");
79326        let mut url = self.hub._base_url.clone() + "userprofiles";
79327        if self._scopes.is_empty() {
79328            self._scopes.insert(Scope::Full.as_ref().to_string());
79329        }
79330
79331        let url = params.parse_with_url(&url);
79332
79333        loop {
79334            let token = match self
79335                .hub
79336                .auth
79337                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
79338                .await
79339            {
79340                Ok(token) => token,
79341                Err(e) => match dlg.token(e) {
79342                    Ok(token) => token,
79343                    Err(e) => {
79344                        dlg.finished(false);
79345                        return Err(common::Error::MissingToken(e));
79346                    }
79347                },
79348            };
79349            let mut req_result = {
79350                let client = &self.hub.client;
79351                dlg.pre_request();
79352                let mut req_builder = hyper::Request::builder()
79353                    .method(hyper::Method::GET)
79354                    .uri(url.as_str())
79355                    .header(USER_AGENT, self.hub._user_agent.clone());
79356
79357                if let Some(token) = token.as_ref() {
79358                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
79359                }
79360
79361                let request = req_builder
79362                    .header(CONTENT_LENGTH, 0_u64)
79363                    .body(common::to_body::<String>(None));
79364
79365                client.request(request.unwrap()).await
79366            };
79367
79368            match req_result {
79369                Err(err) => {
79370                    if let common::Retry::After(d) = dlg.http_error(&err) {
79371                        sleep(d).await;
79372                        continue;
79373                    }
79374                    dlg.finished(false);
79375                    return Err(common::Error::HttpError(err));
79376                }
79377                Ok(res) => {
79378                    let (mut parts, body) = res.into_parts();
79379                    let mut body = common::Body::new(body);
79380                    if !parts.status.is_success() {
79381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79382                        let error = serde_json::from_str(&common::to_string(&bytes));
79383                        let response = common::to_response(parts, bytes.into());
79384
79385                        if let common::Retry::After(d) =
79386                            dlg.http_failure(&response, error.as_ref().ok())
79387                        {
79388                            sleep(d).await;
79389                            continue;
79390                        }
79391
79392                        dlg.finished(false);
79393
79394                        return Err(match error {
79395                            Ok(value) => common::Error::BadRequest(value),
79396                            _ => common::Error::Failure(response),
79397                        });
79398                    }
79399                    let response = {
79400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79401                        let encoded = common::to_string(&bytes);
79402                        match serde_json::from_str(&encoded) {
79403                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
79404                            Err(error) => {
79405                                dlg.response_json_decode_error(&encoded, &error);
79406                                return Err(common::Error::JsonDecodeError(
79407                                    encoded.to_string(),
79408                                    error,
79409                                ));
79410                            }
79411                        }
79412                    };
79413
79414                    dlg.finished(true);
79415                    return Ok(response);
79416                }
79417            }
79418        }
79419    }
79420
79421    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
79422    /// while executing the actual API request.
79423    ///
79424    /// ````text
79425    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
79426    /// ````
79427    ///
79428    /// Sets the *delegate* property to the given value.
79429    pub fn delegate(
79430        mut self,
79431        new_value: &'a mut dyn common::Delegate,
79432    ) -> UserProfileListCall<'a, C> {
79433        self._delegate = Some(new_value);
79434        self
79435    }
79436
79437    /// Set any additional parameter of the query string used in the request.
79438    /// It should be used to set parameters which are not yet available through their own
79439    /// setters.
79440    ///
79441    /// Please note that this method must not be used to set any of the known parameters
79442    /// which have their own setter method. If done anyway, the request will fail.
79443    ///
79444    /// # Additional Parameters
79445    ///
79446    /// * *alt* (query-string) - Data format for the response.
79447    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
79448    /// * *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.
79449    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
79450    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
79451    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
79452    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
79453    pub fn param<T>(mut self, name: T, value: T) -> UserProfileListCall<'a, C>
79454    where
79455        T: AsRef<str>,
79456    {
79457        self._additional_params
79458            .insert(name.as_ref().to_string(), value.as_ref().to_string());
79459        self
79460    }
79461
79462    /// Identifies the authorization scope for the method you are building.
79463    ///
79464    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
79465    /// [`Scope::Full`].
79466    ///
79467    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
79468    /// tokens for more than one scope.
79469    ///
79470    /// Usually there is more than one suitable scope to authorize an operation, some of which may
79471    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
79472    /// sufficient, a read-write scope will do as well.
79473    pub fn add_scope<St>(mut self, scope: St) -> UserProfileListCall<'a, C>
79474    where
79475        St: AsRef<str>,
79476    {
79477        self._scopes.insert(String::from(scope.as_ref()));
79478        self
79479    }
79480    /// Identifies the authorization scope(s) for the method you are building.
79481    ///
79482    /// See [`Self::add_scope()`] for details.
79483    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserProfileListCall<'a, C>
79484    where
79485        I: IntoIterator<Item = St>,
79486        St: AsRef<str>,
79487    {
79488        self._scopes
79489            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
79490        self
79491    }
79492
79493    /// Removes all scopes, and no default scope will be used either.
79494    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
79495    /// for details).
79496    pub fn clear_scopes(mut self) -> UserProfileListCall<'a, C> {
79497        self._scopes.clear();
79498        self
79499    }
79500}
79501
79502/// Gets one user role permission group by ID.
79503///
79504/// A builder for the *get* method supported by a *userRolePermissionGroup* resource.
79505/// It is not used directly, but through a [`UserRolePermissionGroupMethods`] instance.
79506///
79507/// # Example
79508///
79509/// Instantiate a resource method builder
79510///
79511/// ```test_harness,no_run
79512/// # extern crate hyper;
79513/// # extern crate hyper_rustls;
79514/// # extern crate google_dfareporting3d2 as dfareporting3d2;
79515/// # async fn dox() {
79516/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
79517///
79518/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
79519/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
79520/// #     secret,
79521/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
79522/// # ).build().await.unwrap();
79523///
79524/// # let client = hyper_util::client::legacy::Client::builder(
79525/// #     hyper_util::rt::TokioExecutor::new()
79526/// # )
79527/// # .build(
79528/// #     hyper_rustls::HttpsConnectorBuilder::new()
79529/// #         .with_native_roots()
79530/// #         .unwrap()
79531/// #         .https_or_http()
79532/// #         .enable_http1()
79533/// #         .build()
79534/// # );
79535/// # let mut hub = Dfareporting::new(client, auth);
79536/// // You can configure optional parameters by calling the respective setters at will, and
79537/// // execute the final call using `doit()`.
79538/// // Values shown here are possibly random and not representative !
79539/// let result = hub.user_role_permission_groups().get(-89, -46)
79540///              .doit().await;
79541/// # }
79542/// ```
79543pub struct UserRolePermissionGroupGetCall<'a, C>
79544where
79545    C: 'a,
79546{
79547    hub: &'a Dfareporting<C>,
79548    _profile_id: i64,
79549    _id: i64,
79550    _delegate: Option<&'a mut dyn common::Delegate>,
79551    _additional_params: HashMap<String, String>,
79552    _scopes: BTreeSet<String>,
79553}
79554
79555impl<'a, C> common::CallBuilder for UserRolePermissionGroupGetCall<'a, C> {}
79556
79557impl<'a, C> UserRolePermissionGroupGetCall<'a, C>
79558where
79559    C: common::Connector,
79560{
79561    /// Perform the operation you have build so far.
79562    pub async fn doit(mut self) -> common::Result<(common::Response, UserRolePermissionGroup)> {
79563        use std::borrow::Cow;
79564        use std::io::{Read, Seek};
79565
79566        use common::{url::Params, ToParts};
79567        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
79568
79569        let mut dd = common::DefaultDelegate;
79570        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
79571        dlg.begin(common::MethodInfo {
79572            id: "dfareporting.userRolePermissionGroups.get",
79573            http_method: hyper::Method::GET,
79574        });
79575
79576        for &field in ["alt", "profileId", "id"].iter() {
79577            if self._additional_params.contains_key(field) {
79578                dlg.finished(false);
79579                return Err(common::Error::FieldClash(field));
79580            }
79581        }
79582
79583        let mut params = Params::with_capacity(4 + self._additional_params.len());
79584        params.push("profileId", self._profile_id.to_string());
79585        params.push("id", self._id.to_string());
79586
79587        params.extend(self._additional_params.iter());
79588
79589        params.push("alt", "json");
79590        let mut url =
79591            self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissionGroups/{id}";
79592        if self._scopes.is_empty() {
79593            self._scopes
79594                .insert(Scope::Dfatrafficking.as_ref().to_string());
79595        }
79596
79597        #[allow(clippy::single_element_loop)]
79598        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
79599            url = params.uri_replacement(url, param_name, find_this, false);
79600        }
79601        {
79602            let to_remove = ["id", "profileId"];
79603            params.remove_params(&to_remove);
79604        }
79605
79606        let url = params.parse_with_url(&url);
79607
79608        loop {
79609            let token = match self
79610                .hub
79611                .auth
79612                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
79613                .await
79614            {
79615                Ok(token) => token,
79616                Err(e) => match dlg.token(e) {
79617                    Ok(token) => token,
79618                    Err(e) => {
79619                        dlg.finished(false);
79620                        return Err(common::Error::MissingToken(e));
79621                    }
79622                },
79623            };
79624            let mut req_result = {
79625                let client = &self.hub.client;
79626                dlg.pre_request();
79627                let mut req_builder = hyper::Request::builder()
79628                    .method(hyper::Method::GET)
79629                    .uri(url.as_str())
79630                    .header(USER_AGENT, self.hub._user_agent.clone());
79631
79632                if let Some(token) = token.as_ref() {
79633                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
79634                }
79635
79636                let request = req_builder
79637                    .header(CONTENT_LENGTH, 0_u64)
79638                    .body(common::to_body::<String>(None));
79639
79640                client.request(request.unwrap()).await
79641            };
79642
79643            match req_result {
79644                Err(err) => {
79645                    if let common::Retry::After(d) = dlg.http_error(&err) {
79646                        sleep(d).await;
79647                        continue;
79648                    }
79649                    dlg.finished(false);
79650                    return Err(common::Error::HttpError(err));
79651                }
79652                Ok(res) => {
79653                    let (mut parts, body) = res.into_parts();
79654                    let mut body = common::Body::new(body);
79655                    if !parts.status.is_success() {
79656                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79657                        let error = serde_json::from_str(&common::to_string(&bytes));
79658                        let response = common::to_response(parts, bytes.into());
79659
79660                        if let common::Retry::After(d) =
79661                            dlg.http_failure(&response, error.as_ref().ok())
79662                        {
79663                            sleep(d).await;
79664                            continue;
79665                        }
79666
79667                        dlg.finished(false);
79668
79669                        return Err(match error {
79670                            Ok(value) => common::Error::BadRequest(value),
79671                            _ => common::Error::Failure(response),
79672                        });
79673                    }
79674                    let response = {
79675                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79676                        let encoded = common::to_string(&bytes);
79677                        match serde_json::from_str(&encoded) {
79678                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
79679                            Err(error) => {
79680                                dlg.response_json_decode_error(&encoded, &error);
79681                                return Err(common::Error::JsonDecodeError(
79682                                    encoded.to_string(),
79683                                    error,
79684                                ));
79685                            }
79686                        }
79687                    };
79688
79689                    dlg.finished(true);
79690                    return Ok(response);
79691                }
79692            }
79693        }
79694    }
79695
79696    /// User profile ID associated with this request.
79697    ///
79698    /// Sets the *profile id* path property to the given value.
79699    ///
79700    /// Even though the property as already been set when instantiating this call,
79701    /// we provide this method for API completeness.
79702    pub fn profile_id(mut self, new_value: i64) -> UserRolePermissionGroupGetCall<'a, C> {
79703        self._profile_id = new_value;
79704        self
79705    }
79706    /// User role permission group ID.
79707    ///
79708    /// Sets the *id* path property to the given value.
79709    ///
79710    /// Even though the property as already been set when instantiating this call,
79711    /// we provide this method for API completeness.
79712    pub fn id(mut self, new_value: i64) -> UserRolePermissionGroupGetCall<'a, C> {
79713        self._id = new_value;
79714        self
79715    }
79716    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
79717    /// while executing the actual API request.
79718    ///
79719    /// ````text
79720    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
79721    /// ````
79722    ///
79723    /// Sets the *delegate* property to the given value.
79724    pub fn delegate(
79725        mut self,
79726        new_value: &'a mut dyn common::Delegate,
79727    ) -> UserRolePermissionGroupGetCall<'a, C> {
79728        self._delegate = Some(new_value);
79729        self
79730    }
79731
79732    /// Set any additional parameter of the query string used in the request.
79733    /// It should be used to set parameters which are not yet available through their own
79734    /// setters.
79735    ///
79736    /// Please note that this method must not be used to set any of the known parameters
79737    /// which have their own setter method. If done anyway, the request will fail.
79738    ///
79739    /// # Additional Parameters
79740    ///
79741    /// * *alt* (query-string) - Data format for the response.
79742    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
79743    /// * *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.
79744    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
79745    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
79746    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
79747    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
79748    pub fn param<T>(mut self, name: T, value: T) -> UserRolePermissionGroupGetCall<'a, C>
79749    where
79750        T: AsRef<str>,
79751    {
79752        self._additional_params
79753            .insert(name.as_ref().to_string(), value.as_ref().to_string());
79754        self
79755    }
79756
79757    /// Identifies the authorization scope for the method you are building.
79758    ///
79759    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
79760    /// [`Scope::Dfatrafficking`].
79761    ///
79762    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
79763    /// tokens for more than one scope.
79764    ///
79765    /// Usually there is more than one suitable scope to authorize an operation, some of which may
79766    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
79767    /// sufficient, a read-write scope will do as well.
79768    pub fn add_scope<St>(mut self, scope: St) -> UserRolePermissionGroupGetCall<'a, C>
79769    where
79770        St: AsRef<str>,
79771    {
79772        self._scopes.insert(String::from(scope.as_ref()));
79773        self
79774    }
79775    /// Identifies the authorization scope(s) for the method you are building.
79776    ///
79777    /// See [`Self::add_scope()`] for details.
79778    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRolePermissionGroupGetCall<'a, C>
79779    where
79780        I: IntoIterator<Item = St>,
79781        St: AsRef<str>,
79782    {
79783        self._scopes
79784            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
79785        self
79786    }
79787
79788    /// Removes all scopes, and no default scope will be used either.
79789    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
79790    /// for details).
79791    pub fn clear_scopes(mut self) -> UserRolePermissionGroupGetCall<'a, C> {
79792        self._scopes.clear();
79793        self
79794    }
79795}
79796
79797/// Gets a list of all supported user role permission groups.
79798///
79799/// A builder for the *list* method supported by a *userRolePermissionGroup* resource.
79800/// It is not used directly, but through a [`UserRolePermissionGroupMethods`] instance.
79801///
79802/// # Example
79803///
79804/// Instantiate a resource method builder
79805///
79806/// ```test_harness,no_run
79807/// # extern crate hyper;
79808/// # extern crate hyper_rustls;
79809/// # extern crate google_dfareporting3d2 as dfareporting3d2;
79810/// # async fn dox() {
79811/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
79812///
79813/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
79814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
79815/// #     secret,
79816/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
79817/// # ).build().await.unwrap();
79818///
79819/// # let client = hyper_util::client::legacy::Client::builder(
79820/// #     hyper_util::rt::TokioExecutor::new()
79821/// # )
79822/// # .build(
79823/// #     hyper_rustls::HttpsConnectorBuilder::new()
79824/// #         .with_native_roots()
79825/// #         .unwrap()
79826/// #         .https_or_http()
79827/// #         .enable_http1()
79828/// #         .build()
79829/// # );
79830/// # let mut hub = Dfareporting::new(client, auth);
79831/// // You can configure optional parameters by calling the respective setters at will, and
79832/// // execute the final call using `doit()`.
79833/// // Values shown here are possibly random and not representative !
79834/// let result = hub.user_role_permission_groups().list(-47)
79835///              .doit().await;
79836/// # }
79837/// ```
79838pub struct UserRolePermissionGroupListCall<'a, C>
79839where
79840    C: 'a,
79841{
79842    hub: &'a Dfareporting<C>,
79843    _profile_id: i64,
79844    _delegate: Option<&'a mut dyn common::Delegate>,
79845    _additional_params: HashMap<String, String>,
79846    _scopes: BTreeSet<String>,
79847}
79848
79849impl<'a, C> common::CallBuilder for UserRolePermissionGroupListCall<'a, C> {}
79850
79851impl<'a, C> UserRolePermissionGroupListCall<'a, C>
79852where
79853    C: common::Connector,
79854{
79855    /// Perform the operation you have build so far.
79856    pub async fn doit(
79857        mut self,
79858    ) -> common::Result<(common::Response, UserRolePermissionGroupsListResponse)> {
79859        use std::borrow::Cow;
79860        use std::io::{Read, Seek};
79861
79862        use common::{url::Params, ToParts};
79863        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
79864
79865        let mut dd = common::DefaultDelegate;
79866        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
79867        dlg.begin(common::MethodInfo {
79868            id: "dfareporting.userRolePermissionGroups.list",
79869            http_method: hyper::Method::GET,
79870        });
79871
79872        for &field in ["alt", "profileId"].iter() {
79873            if self._additional_params.contains_key(field) {
79874                dlg.finished(false);
79875                return Err(common::Error::FieldClash(field));
79876            }
79877        }
79878
79879        let mut params = Params::with_capacity(3 + self._additional_params.len());
79880        params.push("profileId", self._profile_id.to_string());
79881
79882        params.extend(self._additional_params.iter());
79883
79884        params.push("alt", "json");
79885        let mut url =
79886            self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissionGroups";
79887        if self._scopes.is_empty() {
79888            self._scopes
79889                .insert(Scope::Dfatrafficking.as_ref().to_string());
79890        }
79891
79892        #[allow(clippy::single_element_loop)]
79893        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
79894            url = params.uri_replacement(url, param_name, find_this, false);
79895        }
79896        {
79897            let to_remove = ["profileId"];
79898            params.remove_params(&to_remove);
79899        }
79900
79901        let url = params.parse_with_url(&url);
79902
79903        loop {
79904            let token = match self
79905                .hub
79906                .auth
79907                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
79908                .await
79909            {
79910                Ok(token) => token,
79911                Err(e) => match dlg.token(e) {
79912                    Ok(token) => token,
79913                    Err(e) => {
79914                        dlg.finished(false);
79915                        return Err(common::Error::MissingToken(e));
79916                    }
79917                },
79918            };
79919            let mut req_result = {
79920                let client = &self.hub.client;
79921                dlg.pre_request();
79922                let mut req_builder = hyper::Request::builder()
79923                    .method(hyper::Method::GET)
79924                    .uri(url.as_str())
79925                    .header(USER_AGENT, self.hub._user_agent.clone());
79926
79927                if let Some(token) = token.as_ref() {
79928                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
79929                }
79930
79931                let request = req_builder
79932                    .header(CONTENT_LENGTH, 0_u64)
79933                    .body(common::to_body::<String>(None));
79934
79935                client.request(request.unwrap()).await
79936            };
79937
79938            match req_result {
79939                Err(err) => {
79940                    if let common::Retry::After(d) = dlg.http_error(&err) {
79941                        sleep(d).await;
79942                        continue;
79943                    }
79944                    dlg.finished(false);
79945                    return Err(common::Error::HttpError(err));
79946                }
79947                Ok(res) => {
79948                    let (mut parts, body) = res.into_parts();
79949                    let mut body = common::Body::new(body);
79950                    if !parts.status.is_success() {
79951                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79952                        let error = serde_json::from_str(&common::to_string(&bytes));
79953                        let response = common::to_response(parts, bytes.into());
79954
79955                        if let common::Retry::After(d) =
79956                            dlg.http_failure(&response, error.as_ref().ok())
79957                        {
79958                            sleep(d).await;
79959                            continue;
79960                        }
79961
79962                        dlg.finished(false);
79963
79964                        return Err(match error {
79965                            Ok(value) => common::Error::BadRequest(value),
79966                            _ => common::Error::Failure(response),
79967                        });
79968                    }
79969                    let response = {
79970                        let bytes = common::to_bytes(body).await.unwrap_or_default();
79971                        let encoded = common::to_string(&bytes);
79972                        match serde_json::from_str(&encoded) {
79973                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
79974                            Err(error) => {
79975                                dlg.response_json_decode_error(&encoded, &error);
79976                                return Err(common::Error::JsonDecodeError(
79977                                    encoded.to_string(),
79978                                    error,
79979                                ));
79980                            }
79981                        }
79982                    };
79983
79984                    dlg.finished(true);
79985                    return Ok(response);
79986                }
79987            }
79988        }
79989    }
79990
79991    /// User profile ID associated with this request.
79992    ///
79993    /// Sets the *profile id* path property to the given value.
79994    ///
79995    /// Even though the property as already been set when instantiating this call,
79996    /// we provide this method for API completeness.
79997    pub fn profile_id(mut self, new_value: i64) -> UserRolePermissionGroupListCall<'a, C> {
79998        self._profile_id = new_value;
79999        self
80000    }
80001    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
80002    /// while executing the actual API request.
80003    ///
80004    /// ````text
80005    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
80006    /// ````
80007    ///
80008    /// Sets the *delegate* property to the given value.
80009    pub fn delegate(
80010        mut self,
80011        new_value: &'a mut dyn common::Delegate,
80012    ) -> UserRolePermissionGroupListCall<'a, C> {
80013        self._delegate = Some(new_value);
80014        self
80015    }
80016
80017    /// Set any additional parameter of the query string used in the request.
80018    /// It should be used to set parameters which are not yet available through their own
80019    /// setters.
80020    ///
80021    /// Please note that this method must not be used to set any of the known parameters
80022    /// which have their own setter method. If done anyway, the request will fail.
80023    ///
80024    /// # Additional Parameters
80025    ///
80026    /// * *alt* (query-string) - Data format for the response.
80027    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
80028    /// * *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.
80029    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
80030    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
80031    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
80032    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
80033    pub fn param<T>(mut self, name: T, value: T) -> UserRolePermissionGroupListCall<'a, C>
80034    where
80035        T: AsRef<str>,
80036    {
80037        self._additional_params
80038            .insert(name.as_ref().to_string(), value.as_ref().to_string());
80039        self
80040    }
80041
80042    /// Identifies the authorization scope for the method you are building.
80043    ///
80044    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
80045    /// [`Scope::Dfatrafficking`].
80046    ///
80047    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
80048    /// tokens for more than one scope.
80049    ///
80050    /// Usually there is more than one suitable scope to authorize an operation, some of which may
80051    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
80052    /// sufficient, a read-write scope will do as well.
80053    pub fn add_scope<St>(mut self, scope: St) -> UserRolePermissionGroupListCall<'a, C>
80054    where
80055        St: AsRef<str>,
80056    {
80057        self._scopes.insert(String::from(scope.as_ref()));
80058        self
80059    }
80060    /// Identifies the authorization scope(s) for the method you are building.
80061    ///
80062    /// See [`Self::add_scope()`] for details.
80063    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRolePermissionGroupListCall<'a, C>
80064    where
80065        I: IntoIterator<Item = St>,
80066        St: AsRef<str>,
80067    {
80068        self._scopes
80069            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
80070        self
80071    }
80072
80073    /// Removes all scopes, and no default scope will be used either.
80074    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
80075    /// for details).
80076    pub fn clear_scopes(mut self) -> UserRolePermissionGroupListCall<'a, C> {
80077        self._scopes.clear();
80078        self
80079    }
80080}
80081
80082/// Gets one user role permission by ID.
80083///
80084/// A builder for the *get* method supported by a *userRolePermission* resource.
80085/// It is not used directly, but through a [`UserRolePermissionMethods`] instance.
80086///
80087/// # Example
80088///
80089/// Instantiate a resource method builder
80090///
80091/// ```test_harness,no_run
80092/// # extern crate hyper;
80093/// # extern crate hyper_rustls;
80094/// # extern crate google_dfareporting3d2 as dfareporting3d2;
80095/// # async fn dox() {
80096/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
80097///
80098/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
80099/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
80100/// #     secret,
80101/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
80102/// # ).build().await.unwrap();
80103///
80104/// # let client = hyper_util::client::legacy::Client::builder(
80105/// #     hyper_util::rt::TokioExecutor::new()
80106/// # )
80107/// # .build(
80108/// #     hyper_rustls::HttpsConnectorBuilder::new()
80109/// #         .with_native_roots()
80110/// #         .unwrap()
80111/// #         .https_or_http()
80112/// #         .enable_http1()
80113/// #         .build()
80114/// # );
80115/// # let mut hub = Dfareporting::new(client, auth);
80116/// // You can configure optional parameters by calling the respective setters at will, and
80117/// // execute the final call using `doit()`.
80118/// // Values shown here are possibly random and not representative !
80119/// let result = hub.user_role_permissions().get(-50, -72)
80120///              .doit().await;
80121/// # }
80122/// ```
80123pub struct UserRolePermissionGetCall<'a, C>
80124where
80125    C: 'a,
80126{
80127    hub: &'a Dfareporting<C>,
80128    _profile_id: i64,
80129    _id: i64,
80130    _delegate: Option<&'a mut dyn common::Delegate>,
80131    _additional_params: HashMap<String, String>,
80132    _scopes: BTreeSet<String>,
80133}
80134
80135impl<'a, C> common::CallBuilder for UserRolePermissionGetCall<'a, C> {}
80136
80137impl<'a, C> UserRolePermissionGetCall<'a, C>
80138where
80139    C: common::Connector,
80140{
80141    /// Perform the operation you have build so far.
80142    pub async fn doit(mut self) -> common::Result<(common::Response, UserRolePermission)> {
80143        use std::borrow::Cow;
80144        use std::io::{Read, Seek};
80145
80146        use common::{url::Params, ToParts};
80147        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
80148
80149        let mut dd = common::DefaultDelegate;
80150        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
80151        dlg.begin(common::MethodInfo {
80152            id: "dfareporting.userRolePermissions.get",
80153            http_method: hyper::Method::GET,
80154        });
80155
80156        for &field in ["alt", "profileId", "id"].iter() {
80157            if self._additional_params.contains_key(field) {
80158                dlg.finished(false);
80159                return Err(common::Error::FieldClash(field));
80160            }
80161        }
80162
80163        let mut params = Params::with_capacity(4 + self._additional_params.len());
80164        params.push("profileId", self._profile_id.to_string());
80165        params.push("id", self._id.to_string());
80166
80167        params.extend(self._additional_params.iter());
80168
80169        params.push("alt", "json");
80170        let mut url =
80171            self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissions/{id}";
80172        if self._scopes.is_empty() {
80173            self._scopes
80174                .insert(Scope::Dfatrafficking.as_ref().to_string());
80175        }
80176
80177        #[allow(clippy::single_element_loop)]
80178        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
80179            url = params.uri_replacement(url, param_name, find_this, false);
80180        }
80181        {
80182            let to_remove = ["id", "profileId"];
80183            params.remove_params(&to_remove);
80184        }
80185
80186        let url = params.parse_with_url(&url);
80187
80188        loop {
80189            let token = match self
80190                .hub
80191                .auth
80192                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
80193                .await
80194            {
80195                Ok(token) => token,
80196                Err(e) => match dlg.token(e) {
80197                    Ok(token) => token,
80198                    Err(e) => {
80199                        dlg.finished(false);
80200                        return Err(common::Error::MissingToken(e));
80201                    }
80202                },
80203            };
80204            let mut req_result = {
80205                let client = &self.hub.client;
80206                dlg.pre_request();
80207                let mut req_builder = hyper::Request::builder()
80208                    .method(hyper::Method::GET)
80209                    .uri(url.as_str())
80210                    .header(USER_AGENT, self.hub._user_agent.clone());
80211
80212                if let Some(token) = token.as_ref() {
80213                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
80214                }
80215
80216                let request = req_builder
80217                    .header(CONTENT_LENGTH, 0_u64)
80218                    .body(common::to_body::<String>(None));
80219
80220                client.request(request.unwrap()).await
80221            };
80222
80223            match req_result {
80224                Err(err) => {
80225                    if let common::Retry::After(d) = dlg.http_error(&err) {
80226                        sleep(d).await;
80227                        continue;
80228                    }
80229                    dlg.finished(false);
80230                    return Err(common::Error::HttpError(err));
80231                }
80232                Ok(res) => {
80233                    let (mut parts, body) = res.into_parts();
80234                    let mut body = common::Body::new(body);
80235                    if !parts.status.is_success() {
80236                        let bytes = common::to_bytes(body).await.unwrap_or_default();
80237                        let error = serde_json::from_str(&common::to_string(&bytes));
80238                        let response = common::to_response(parts, bytes.into());
80239
80240                        if let common::Retry::After(d) =
80241                            dlg.http_failure(&response, error.as_ref().ok())
80242                        {
80243                            sleep(d).await;
80244                            continue;
80245                        }
80246
80247                        dlg.finished(false);
80248
80249                        return Err(match error {
80250                            Ok(value) => common::Error::BadRequest(value),
80251                            _ => common::Error::Failure(response),
80252                        });
80253                    }
80254                    let response = {
80255                        let bytes = common::to_bytes(body).await.unwrap_or_default();
80256                        let encoded = common::to_string(&bytes);
80257                        match serde_json::from_str(&encoded) {
80258                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
80259                            Err(error) => {
80260                                dlg.response_json_decode_error(&encoded, &error);
80261                                return Err(common::Error::JsonDecodeError(
80262                                    encoded.to_string(),
80263                                    error,
80264                                ));
80265                            }
80266                        }
80267                    };
80268
80269                    dlg.finished(true);
80270                    return Ok(response);
80271                }
80272            }
80273        }
80274    }
80275
80276    /// User profile ID associated with this request.
80277    ///
80278    /// Sets the *profile id* path property to the given value.
80279    ///
80280    /// Even though the property as already been set when instantiating this call,
80281    /// we provide this method for API completeness.
80282    pub fn profile_id(mut self, new_value: i64) -> UserRolePermissionGetCall<'a, C> {
80283        self._profile_id = new_value;
80284        self
80285    }
80286    /// User role permission ID.
80287    ///
80288    /// Sets the *id* path property to the given value.
80289    ///
80290    /// Even though the property as already been set when instantiating this call,
80291    /// we provide this method for API completeness.
80292    pub fn id(mut self, new_value: i64) -> UserRolePermissionGetCall<'a, C> {
80293        self._id = new_value;
80294        self
80295    }
80296    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
80297    /// while executing the actual API request.
80298    ///
80299    /// ````text
80300    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
80301    /// ````
80302    ///
80303    /// Sets the *delegate* property to the given value.
80304    pub fn delegate(
80305        mut self,
80306        new_value: &'a mut dyn common::Delegate,
80307    ) -> UserRolePermissionGetCall<'a, C> {
80308        self._delegate = Some(new_value);
80309        self
80310    }
80311
80312    /// Set any additional parameter of the query string used in the request.
80313    /// It should be used to set parameters which are not yet available through their own
80314    /// setters.
80315    ///
80316    /// Please note that this method must not be used to set any of the known parameters
80317    /// which have their own setter method. If done anyway, the request will fail.
80318    ///
80319    /// # Additional Parameters
80320    ///
80321    /// * *alt* (query-string) - Data format for the response.
80322    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
80323    /// * *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.
80324    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
80325    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
80326    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
80327    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
80328    pub fn param<T>(mut self, name: T, value: T) -> UserRolePermissionGetCall<'a, C>
80329    where
80330        T: AsRef<str>,
80331    {
80332        self._additional_params
80333            .insert(name.as_ref().to_string(), value.as_ref().to_string());
80334        self
80335    }
80336
80337    /// Identifies the authorization scope for the method you are building.
80338    ///
80339    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
80340    /// [`Scope::Dfatrafficking`].
80341    ///
80342    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
80343    /// tokens for more than one scope.
80344    ///
80345    /// Usually there is more than one suitable scope to authorize an operation, some of which may
80346    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
80347    /// sufficient, a read-write scope will do as well.
80348    pub fn add_scope<St>(mut self, scope: St) -> UserRolePermissionGetCall<'a, C>
80349    where
80350        St: AsRef<str>,
80351    {
80352        self._scopes.insert(String::from(scope.as_ref()));
80353        self
80354    }
80355    /// Identifies the authorization scope(s) for the method you are building.
80356    ///
80357    /// See [`Self::add_scope()`] for details.
80358    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRolePermissionGetCall<'a, C>
80359    where
80360        I: IntoIterator<Item = St>,
80361        St: AsRef<str>,
80362    {
80363        self._scopes
80364            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
80365        self
80366    }
80367
80368    /// Removes all scopes, and no default scope will be used either.
80369    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
80370    /// for details).
80371    pub fn clear_scopes(mut self) -> UserRolePermissionGetCall<'a, C> {
80372        self._scopes.clear();
80373        self
80374    }
80375}
80376
80377/// Gets a list of user role permissions, possibly filtered.
80378///
80379/// A builder for the *list* method supported by a *userRolePermission* resource.
80380/// It is not used directly, but through a [`UserRolePermissionMethods`] instance.
80381///
80382/// # Example
80383///
80384/// Instantiate a resource method builder
80385///
80386/// ```test_harness,no_run
80387/// # extern crate hyper;
80388/// # extern crate hyper_rustls;
80389/// # extern crate google_dfareporting3d2 as dfareporting3d2;
80390/// # async fn dox() {
80391/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
80392///
80393/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
80394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
80395/// #     secret,
80396/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
80397/// # ).build().await.unwrap();
80398///
80399/// # let client = hyper_util::client::legacy::Client::builder(
80400/// #     hyper_util::rt::TokioExecutor::new()
80401/// # )
80402/// # .build(
80403/// #     hyper_rustls::HttpsConnectorBuilder::new()
80404/// #         .with_native_roots()
80405/// #         .unwrap()
80406/// #         .https_or_http()
80407/// #         .enable_http1()
80408/// #         .build()
80409/// # );
80410/// # let mut hub = Dfareporting::new(client, auth);
80411/// // You can configure optional parameters by calling the respective setters at will, and
80412/// // execute the final call using `doit()`.
80413/// // Values shown here are possibly random and not representative !
80414/// let result = hub.user_role_permissions().list(-44)
80415///              .add_ids(-4)
80416///              .doit().await;
80417/// # }
80418/// ```
80419pub struct UserRolePermissionListCall<'a, C>
80420where
80421    C: 'a,
80422{
80423    hub: &'a Dfareporting<C>,
80424    _profile_id: i64,
80425    _ids: Vec<i64>,
80426    _delegate: Option<&'a mut dyn common::Delegate>,
80427    _additional_params: HashMap<String, String>,
80428    _scopes: BTreeSet<String>,
80429}
80430
80431impl<'a, C> common::CallBuilder for UserRolePermissionListCall<'a, C> {}
80432
80433impl<'a, C> UserRolePermissionListCall<'a, C>
80434where
80435    C: common::Connector,
80436{
80437    /// Perform the operation you have build so far.
80438    pub async fn doit(
80439        mut self,
80440    ) -> common::Result<(common::Response, UserRolePermissionsListResponse)> {
80441        use std::borrow::Cow;
80442        use std::io::{Read, Seek};
80443
80444        use common::{url::Params, ToParts};
80445        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
80446
80447        let mut dd = common::DefaultDelegate;
80448        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
80449        dlg.begin(common::MethodInfo {
80450            id: "dfareporting.userRolePermissions.list",
80451            http_method: hyper::Method::GET,
80452        });
80453
80454        for &field in ["alt", "profileId", "ids"].iter() {
80455            if self._additional_params.contains_key(field) {
80456                dlg.finished(false);
80457                return Err(common::Error::FieldClash(field));
80458            }
80459        }
80460
80461        let mut params = Params::with_capacity(4 + self._additional_params.len());
80462        params.push("profileId", self._profile_id.to_string());
80463        if !self._ids.is_empty() {
80464            for f in self._ids.iter() {
80465                params.push("ids", f.to_string());
80466            }
80467        }
80468
80469        params.extend(self._additional_params.iter());
80470
80471        params.push("alt", "json");
80472        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissions";
80473        if self._scopes.is_empty() {
80474            self._scopes
80475                .insert(Scope::Dfatrafficking.as_ref().to_string());
80476        }
80477
80478        #[allow(clippy::single_element_loop)]
80479        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
80480            url = params.uri_replacement(url, param_name, find_this, false);
80481        }
80482        {
80483            let to_remove = ["profileId"];
80484            params.remove_params(&to_remove);
80485        }
80486
80487        let url = params.parse_with_url(&url);
80488
80489        loop {
80490            let token = match self
80491                .hub
80492                .auth
80493                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
80494                .await
80495            {
80496                Ok(token) => token,
80497                Err(e) => match dlg.token(e) {
80498                    Ok(token) => token,
80499                    Err(e) => {
80500                        dlg.finished(false);
80501                        return Err(common::Error::MissingToken(e));
80502                    }
80503                },
80504            };
80505            let mut req_result = {
80506                let client = &self.hub.client;
80507                dlg.pre_request();
80508                let mut req_builder = hyper::Request::builder()
80509                    .method(hyper::Method::GET)
80510                    .uri(url.as_str())
80511                    .header(USER_AGENT, self.hub._user_agent.clone());
80512
80513                if let Some(token) = token.as_ref() {
80514                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
80515                }
80516
80517                let request = req_builder
80518                    .header(CONTENT_LENGTH, 0_u64)
80519                    .body(common::to_body::<String>(None));
80520
80521                client.request(request.unwrap()).await
80522            };
80523
80524            match req_result {
80525                Err(err) => {
80526                    if let common::Retry::After(d) = dlg.http_error(&err) {
80527                        sleep(d).await;
80528                        continue;
80529                    }
80530                    dlg.finished(false);
80531                    return Err(common::Error::HttpError(err));
80532                }
80533                Ok(res) => {
80534                    let (mut parts, body) = res.into_parts();
80535                    let mut body = common::Body::new(body);
80536                    if !parts.status.is_success() {
80537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
80538                        let error = serde_json::from_str(&common::to_string(&bytes));
80539                        let response = common::to_response(parts, bytes.into());
80540
80541                        if let common::Retry::After(d) =
80542                            dlg.http_failure(&response, error.as_ref().ok())
80543                        {
80544                            sleep(d).await;
80545                            continue;
80546                        }
80547
80548                        dlg.finished(false);
80549
80550                        return Err(match error {
80551                            Ok(value) => common::Error::BadRequest(value),
80552                            _ => common::Error::Failure(response),
80553                        });
80554                    }
80555                    let response = {
80556                        let bytes = common::to_bytes(body).await.unwrap_or_default();
80557                        let encoded = common::to_string(&bytes);
80558                        match serde_json::from_str(&encoded) {
80559                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
80560                            Err(error) => {
80561                                dlg.response_json_decode_error(&encoded, &error);
80562                                return Err(common::Error::JsonDecodeError(
80563                                    encoded.to_string(),
80564                                    error,
80565                                ));
80566                            }
80567                        }
80568                    };
80569
80570                    dlg.finished(true);
80571                    return Ok(response);
80572                }
80573            }
80574        }
80575    }
80576
80577    /// User profile ID associated with this request.
80578    ///
80579    /// Sets the *profile id* path property to the given value.
80580    ///
80581    /// Even though the property as already been set when instantiating this call,
80582    /// we provide this method for API completeness.
80583    pub fn profile_id(mut self, new_value: i64) -> UserRolePermissionListCall<'a, C> {
80584        self._profile_id = new_value;
80585        self
80586    }
80587    /// Select only user role permissions with these IDs.
80588    ///
80589    /// Append the given value to the *ids* query property.
80590    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
80591    pub fn add_ids(mut self, new_value: i64) -> UserRolePermissionListCall<'a, C> {
80592        self._ids.push(new_value);
80593        self
80594    }
80595    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
80596    /// while executing the actual API request.
80597    ///
80598    /// ````text
80599    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
80600    /// ````
80601    ///
80602    /// Sets the *delegate* property to the given value.
80603    pub fn delegate(
80604        mut self,
80605        new_value: &'a mut dyn common::Delegate,
80606    ) -> UserRolePermissionListCall<'a, C> {
80607        self._delegate = Some(new_value);
80608        self
80609    }
80610
80611    /// Set any additional parameter of the query string used in the request.
80612    /// It should be used to set parameters which are not yet available through their own
80613    /// setters.
80614    ///
80615    /// Please note that this method must not be used to set any of the known parameters
80616    /// which have their own setter method. If done anyway, the request will fail.
80617    ///
80618    /// # Additional Parameters
80619    ///
80620    /// * *alt* (query-string) - Data format for the response.
80621    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
80622    /// * *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.
80623    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
80624    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
80625    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
80626    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
80627    pub fn param<T>(mut self, name: T, value: T) -> UserRolePermissionListCall<'a, C>
80628    where
80629        T: AsRef<str>,
80630    {
80631        self._additional_params
80632            .insert(name.as_ref().to_string(), value.as_ref().to_string());
80633        self
80634    }
80635
80636    /// Identifies the authorization scope for the method you are building.
80637    ///
80638    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
80639    /// [`Scope::Dfatrafficking`].
80640    ///
80641    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
80642    /// tokens for more than one scope.
80643    ///
80644    /// Usually there is more than one suitable scope to authorize an operation, some of which may
80645    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
80646    /// sufficient, a read-write scope will do as well.
80647    pub fn add_scope<St>(mut self, scope: St) -> UserRolePermissionListCall<'a, C>
80648    where
80649        St: AsRef<str>,
80650    {
80651        self._scopes.insert(String::from(scope.as_ref()));
80652        self
80653    }
80654    /// Identifies the authorization scope(s) for the method you are building.
80655    ///
80656    /// See [`Self::add_scope()`] for details.
80657    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRolePermissionListCall<'a, C>
80658    where
80659        I: IntoIterator<Item = St>,
80660        St: AsRef<str>,
80661    {
80662        self._scopes
80663            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
80664        self
80665    }
80666
80667    /// Removes all scopes, and no default scope will be used either.
80668    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
80669    /// for details).
80670    pub fn clear_scopes(mut self) -> UserRolePermissionListCall<'a, C> {
80671        self._scopes.clear();
80672        self
80673    }
80674}
80675
80676/// Deletes an existing user role.
80677///
80678/// A builder for the *delete* method supported by a *userRole* resource.
80679/// It is not used directly, but through a [`UserRoleMethods`] instance.
80680///
80681/// # Example
80682///
80683/// Instantiate a resource method builder
80684///
80685/// ```test_harness,no_run
80686/// # extern crate hyper;
80687/// # extern crate hyper_rustls;
80688/// # extern crate google_dfareporting3d2 as dfareporting3d2;
80689/// # async fn dox() {
80690/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
80691///
80692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
80693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
80694/// #     secret,
80695/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
80696/// # ).build().await.unwrap();
80697///
80698/// # let client = hyper_util::client::legacy::Client::builder(
80699/// #     hyper_util::rt::TokioExecutor::new()
80700/// # )
80701/// # .build(
80702/// #     hyper_rustls::HttpsConnectorBuilder::new()
80703/// #         .with_native_roots()
80704/// #         .unwrap()
80705/// #         .https_or_http()
80706/// #         .enable_http1()
80707/// #         .build()
80708/// # );
80709/// # let mut hub = Dfareporting::new(client, auth);
80710/// // You can configure optional parameters by calling the respective setters at will, and
80711/// // execute the final call using `doit()`.
80712/// // Values shown here are possibly random and not representative !
80713/// let result = hub.user_roles().delete(-20, -92)
80714///              .doit().await;
80715/// # }
80716/// ```
80717pub struct UserRoleDeleteCall<'a, C>
80718where
80719    C: 'a,
80720{
80721    hub: &'a Dfareporting<C>,
80722    _profile_id: i64,
80723    _id: i64,
80724    _delegate: Option<&'a mut dyn common::Delegate>,
80725    _additional_params: HashMap<String, String>,
80726    _scopes: BTreeSet<String>,
80727}
80728
80729impl<'a, C> common::CallBuilder for UserRoleDeleteCall<'a, C> {}
80730
80731impl<'a, C> UserRoleDeleteCall<'a, C>
80732where
80733    C: common::Connector,
80734{
80735    /// Perform the operation you have build so far.
80736    pub async fn doit(mut self) -> common::Result<common::Response> {
80737        use std::borrow::Cow;
80738        use std::io::{Read, Seek};
80739
80740        use common::{url::Params, ToParts};
80741        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
80742
80743        let mut dd = common::DefaultDelegate;
80744        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
80745        dlg.begin(common::MethodInfo {
80746            id: "dfareporting.userRoles.delete",
80747            http_method: hyper::Method::DELETE,
80748        });
80749
80750        for &field in ["profileId", "id"].iter() {
80751            if self._additional_params.contains_key(field) {
80752                dlg.finished(false);
80753                return Err(common::Error::FieldClash(field));
80754            }
80755        }
80756
80757        let mut params = Params::with_capacity(3 + self._additional_params.len());
80758        params.push("profileId", self._profile_id.to_string());
80759        params.push("id", self._id.to_string());
80760
80761        params.extend(self._additional_params.iter());
80762
80763        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles/{id}";
80764        if self._scopes.is_empty() {
80765            self._scopes
80766                .insert(Scope::Dfatrafficking.as_ref().to_string());
80767        }
80768
80769        #[allow(clippy::single_element_loop)]
80770        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
80771            url = params.uri_replacement(url, param_name, find_this, false);
80772        }
80773        {
80774            let to_remove = ["id", "profileId"];
80775            params.remove_params(&to_remove);
80776        }
80777
80778        let url = params.parse_with_url(&url);
80779
80780        loop {
80781            let token = match self
80782                .hub
80783                .auth
80784                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
80785                .await
80786            {
80787                Ok(token) => token,
80788                Err(e) => match dlg.token(e) {
80789                    Ok(token) => token,
80790                    Err(e) => {
80791                        dlg.finished(false);
80792                        return Err(common::Error::MissingToken(e));
80793                    }
80794                },
80795            };
80796            let mut req_result = {
80797                let client = &self.hub.client;
80798                dlg.pre_request();
80799                let mut req_builder = hyper::Request::builder()
80800                    .method(hyper::Method::DELETE)
80801                    .uri(url.as_str())
80802                    .header(USER_AGENT, self.hub._user_agent.clone());
80803
80804                if let Some(token) = token.as_ref() {
80805                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
80806                }
80807
80808                let request = req_builder
80809                    .header(CONTENT_LENGTH, 0_u64)
80810                    .body(common::to_body::<String>(None));
80811
80812                client.request(request.unwrap()).await
80813            };
80814
80815            match req_result {
80816                Err(err) => {
80817                    if let common::Retry::After(d) = dlg.http_error(&err) {
80818                        sleep(d).await;
80819                        continue;
80820                    }
80821                    dlg.finished(false);
80822                    return Err(common::Error::HttpError(err));
80823                }
80824                Ok(res) => {
80825                    let (mut parts, body) = res.into_parts();
80826                    let mut body = common::Body::new(body);
80827                    if !parts.status.is_success() {
80828                        let bytes = common::to_bytes(body).await.unwrap_or_default();
80829                        let error = serde_json::from_str(&common::to_string(&bytes));
80830                        let response = common::to_response(parts, bytes.into());
80831
80832                        if let common::Retry::After(d) =
80833                            dlg.http_failure(&response, error.as_ref().ok())
80834                        {
80835                            sleep(d).await;
80836                            continue;
80837                        }
80838
80839                        dlg.finished(false);
80840
80841                        return Err(match error {
80842                            Ok(value) => common::Error::BadRequest(value),
80843                            _ => common::Error::Failure(response),
80844                        });
80845                    }
80846                    let response = common::Response::from_parts(parts, body);
80847
80848                    dlg.finished(true);
80849                    return Ok(response);
80850                }
80851            }
80852        }
80853    }
80854
80855    /// User profile ID associated with this request.
80856    ///
80857    /// Sets the *profile id* path property to the given value.
80858    ///
80859    /// Even though the property as already been set when instantiating this call,
80860    /// we provide this method for API completeness.
80861    pub fn profile_id(mut self, new_value: i64) -> UserRoleDeleteCall<'a, C> {
80862        self._profile_id = new_value;
80863        self
80864    }
80865    /// User role ID.
80866    ///
80867    /// Sets the *id* path property to the given value.
80868    ///
80869    /// Even though the property as already been set when instantiating this call,
80870    /// we provide this method for API completeness.
80871    pub fn id(mut self, new_value: i64) -> UserRoleDeleteCall<'a, C> {
80872        self._id = new_value;
80873        self
80874    }
80875    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
80876    /// while executing the actual API request.
80877    ///
80878    /// ````text
80879    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
80880    /// ````
80881    ///
80882    /// Sets the *delegate* property to the given value.
80883    pub fn delegate(
80884        mut self,
80885        new_value: &'a mut dyn common::Delegate,
80886    ) -> UserRoleDeleteCall<'a, C> {
80887        self._delegate = Some(new_value);
80888        self
80889    }
80890
80891    /// Set any additional parameter of the query string used in the request.
80892    /// It should be used to set parameters which are not yet available through their own
80893    /// setters.
80894    ///
80895    /// Please note that this method must not be used to set any of the known parameters
80896    /// which have their own setter method. If done anyway, the request will fail.
80897    ///
80898    /// # Additional Parameters
80899    ///
80900    /// * *alt* (query-string) - Data format for the response.
80901    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
80902    /// * *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.
80903    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
80904    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
80905    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
80906    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
80907    pub fn param<T>(mut self, name: T, value: T) -> UserRoleDeleteCall<'a, C>
80908    where
80909        T: AsRef<str>,
80910    {
80911        self._additional_params
80912            .insert(name.as_ref().to_string(), value.as_ref().to_string());
80913        self
80914    }
80915
80916    /// Identifies the authorization scope for the method you are building.
80917    ///
80918    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
80919    /// [`Scope::Dfatrafficking`].
80920    ///
80921    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
80922    /// tokens for more than one scope.
80923    ///
80924    /// Usually there is more than one suitable scope to authorize an operation, some of which may
80925    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
80926    /// sufficient, a read-write scope will do as well.
80927    pub fn add_scope<St>(mut self, scope: St) -> UserRoleDeleteCall<'a, C>
80928    where
80929        St: AsRef<str>,
80930    {
80931        self._scopes.insert(String::from(scope.as_ref()));
80932        self
80933    }
80934    /// Identifies the authorization scope(s) for the method you are building.
80935    ///
80936    /// See [`Self::add_scope()`] for details.
80937    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRoleDeleteCall<'a, C>
80938    where
80939        I: IntoIterator<Item = St>,
80940        St: AsRef<str>,
80941    {
80942        self._scopes
80943            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
80944        self
80945    }
80946
80947    /// Removes all scopes, and no default scope will be used either.
80948    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
80949    /// for details).
80950    pub fn clear_scopes(mut self) -> UserRoleDeleteCall<'a, C> {
80951        self._scopes.clear();
80952        self
80953    }
80954}
80955
80956/// Gets one user role by ID.
80957///
80958/// A builder for the *get* method supported by a *userRole* resource.
80959/// It is not used directly, but through a [`UserRoleMethods`] instance.
80960///
80961/// # Example
80962///
80963/// Instantiate a resource method builder
80964///
80965/// ```test_harness,no_run
80966/// # extern crate hyper;
80967/// # extern crate hyper_rustls;
80968/// # extern crate google_dfareporting3d2 as dfareporting3d2;
80969/// # async fn dox() {
80970/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
80971///
80972/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
80973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
80974/// #     secret,
80975/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
80976/// # ).build().await.unwrap();
80977///
80978/// # let client = hyper_util::client::legacy::Client::builder(
80979/// #     hyper_util::rt::TokioExecutor::new()
80980/// # )
80981/// # .build(
80982/// #     hyper_rustls::HttpsConnectorBuilder::new()
80983/// #         .with_native_roots()
80984/// #         .unwrap()
80985/// #         .https_or_http()
80986/// #         .enable_http1()
80987/// #         .build()
80988/// # );
80989/// # let mut hub = Dfareporting::new(client, auth);
80990/// // You can configure optional parameters by calling the respective setters at will, and
80991/// // execute the final call using `doit()`.
80992/// // Values shown here are possibly random and not representative !
80993/// let result = hub.user_roles().get(-72, -101)
80994///              .doit().await;
80995/// # }
80996/// ```
80997pub struct UserRoleGetCall<'a, C>
80998where
80999    C: 'a,
81000{
81001    hub: &'a Dfareporting<C>,
81002    _profile_id: i64,
81003    _id: i64,
81004    _delegate: Option<&'a mut dyn common::Delegate>,
81005    _additional_params: HashMap<String, String>,
81006    _scopes: BTreeSet<String>,
81007}
81008
81009impl<'a, C> common::CallBuilder for UserRoleGetCall<'a, C> {}
81010
81011impl<'a, C> UserRoleGetCall<'a, C>
81012where
81013    C: common::Connector,
81014{
81015    /// Perform the operation you have build so far.
81016    pub async fn doit(mut self) -> common::Result<(common::Response, UserRole)> {
81017        use std::borrow::Cow;
81018        use std::io::{Read, Seek};
81019
81020        use common::{url::Params, ToParts};
81021        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
81022
81023        let mut dd = common::DefaultDelegate;
81024        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
81025        dlg.begin(common::MethodInfo {
81026            id: "dfareporting.userRoles.get",
81027            http_method: hyper::Method::GET,
81028        });
81029
81030        for &field in ["alt", "profileId", "id"].iter() {
81031            if self._additional_params.contains_key(field) {
81032                dlg.finished(false);
81033                return Err(common::Error::FieldClash(field));
81034            }
81035        }
81036
81037        let mut params = Params::with_capacity(4 + self._additional_params.len());
81038        params.push("profileId", self._profile_id.to_string());
81039        params.push("id", self._id.to_string());
81040
81041        params.extend(self._additional_params.iter());
81042
81043        params.push("alt", "json");
81044        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles/{id}";
81045        if self._scopes.is_empty() {
81046            self._scopes
81047                .insert(Scope::Dfatrafficking.as_ref().to_string());
81048        }
81049
81050        #[allow(clippy::single_element_loop)]
81051        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
81052            url = params.uri_replacement(url, param_name, find_this, false);
81053        }
81054        {
81055            let to_remove = ["id", "profileId"];
81056            params.remove_params(&to_remove);
81057        }
81058
81059        let url = params.parse_with_url(&url);
81060
81061        loop {
81062            let token = match self
81063                .hub
81064                .auth
81065                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
81066                .await
81067            {
81068                Ok(token) => token,
81069                Err(e) => match dlg.token(e) {
81070                    Ok(token) => token,
81071                    Err(e) => {
81072                        dlg.finished(false);
81073                        return Err(common::Error::MissingToken(e));
81074                    }
81075                },
81076            };
81077            let mut req_result = {
81078                let client = &self.hub.client;
81079                dlg.pre_request();
81080                let mut req_builder = hyper::Request::builder()
81081                    .method(hyper::Method::GET)
81082                    .uri(url.as_str())
81083                    .header(USER_AGENT, self.hub._user_agent.clone());
81084
81085                if let Some(token) = token.as_ref() {
81086                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
81087                }
81088
81089                let request = req_builder
81090                    .header(CONTENT_LENGTH, 0_u64)
81091                    .body(common::to_body::<String>(None));
81092
81093                client.request(request.unwrap()).await
81094            };
81095
81096            match req_result {
81097                Err(err) => {
81098                    if let common::Retry::After(d) = dlg.http_error(&err) {
81099                        sleep(d).await;
81100                        continue;
81101                    }
81102                    dlg.finished(false);
81103                    return Err(common::Error::HttpError(err));
81104                }
81105                Ok(res) => {
81106                    let (mut parts, body) = res.into_parts();
81107                    let mut body = common::Body::new(body);
81108                    if !parts.status.is_success() {
81109                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81110                        let error = serde_json::from_str(&common::to_string(&bytes));
81111                        let response = common::to_response(parts, bytes.into());
81112
81113                        if let common::Retry::After(d) =
81114                            dlg.http_failure(&response, error.as_ref().ok())
81115                        {
81116                            sleep(d).await;
81117                            continue;
81118                        }
81119
81120                        dlg.finished(false);
81121
81122                        return Err(match error {
81123                            Ok(value) => common::Error::BadRequest(value),
81124                            _ => common::Error::Failure(response),
81125                        });
81126                    }
81127                    let response = {
81128                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81129                        let encoded = common::to_string(&bytes);
81130                        match serde_json::from_str(&encoded) {
81131                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
81132                            Err(error) => {
81133                                dlg.response_json_decode_error(&encoded, &error);
81134                                return Err(common::Error::JsonDecodeError(
81135                                    encoded.to_string(),
81136                                    error,
81137                                ));
81138                            }
81139                        }
81140                    };
81141
81142                    dlg.finished(true);
81143                    return Ok(response);
81144                }
81145            }
81146        }
81147    }
81148
81149    /// User profile ID associated with this request.
81150    ///
81151    /// Sets the *profile id* path property to the given value.
81152    ///
81153    /// Even though the property as already been set when instantiating this call,
81154    /// we provide this method for API completeness.
81155    pub fn profile_id(mut self, new_value: i64) -> UserRoleGetCall<'a, C> {
81156        self._profile_id = new_value;
81157        self
81158    }
81159    /// User role ID.
81160    ///
81161    /// Sets the *id* path property to the given value.
81162    ///
81163    /// Even though the property as already been set when instantiating this call,
81164    /// we provide this method for API completeness.
81165    pub fn id(mut self, new_value: i64) -> UserRoleGetCall<'a, C> {
81166        self._id = new_value;
81167        self
81168    }
81169    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
81170    /// while executing the actual API request.
81171    ///
81172    /// ````text
81173    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
81174    /// ````
81175    ///
81176    /// Sets the *delegate* property to the given value.
81177    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserRoleGetCall<'a, C> {
81178        self._delegate = Some(new_value);
81179        self
81180    }
81181
81182    /// Set any additional parameter of the query string used in the request.
81183    /// It should be used to set parameters which are not yet available through their own
81184    /// setters.
81185    ///
81186    /// Please note that this method must not be used to set any of the known parameters
81187    /// which have their own setter method. If done anyway, the request will fail.
81188    ///
81189    /// # Additional Parameters
81190    ///
81191    /// * *alt* (query-string) - Data format for the response.
81192    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
81193    /// * *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.
81194    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
81195    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
81196    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
81197    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
81198    pub fn param<T>(mut self, name: T, value: T) -> UserRoleGetCall<'a, C>
81199    where
81200        T: AsRef<str>,
81201    {
81202        self._additional_params
81203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
81204        self
81205    }
81206
81207    /// Identifies the authorization scope for the method you are building.
81208    ///
81209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
81210    /// [`Scope::Dfatrafficking`].
81211    ///
81212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
81213    /// tokens for more than one scope.
81214    ///
81215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
81216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
81217    /// sufficient, a read-write scope will do as well.
81218    pub fn add_scope<St>(mut self, scope: St) -> UserRoleGetCall<'a, C>
81219    where
81220        St: AsRef<str>,
81221    {
81222        self._scopes.insert(String::from(scope.as_ref()));
81223        self
81224    }
81225    /// Identifies the authorization scope(s) for the method you are building.
81226    ///
81227    /// See [`Self::add_scope()`] for details.
81228    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRoleGetCall<'a, C>
81229    where
81230        I: IntoIterator<Item = St>,
81231        St: AsRef<str>,
81232    {
81233        self._scopes
81234            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
81235        self
81236    }
81237
81238    /// Removes all scopes, and no default scope will be used either.
81239    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
81240    /// for details).
81241    pub fn clear_scopes(mut self) -> UserRoleGetCall<'a, C> {
81242        self._scopes.clear();
81243        self
81244    }
81245}
81246
81247/// Inserts a new user role.
81248///
81249/// A builder for the *insert* method supported by a *userRole* resource.
81250/// It is not used directly, but through a [`UserRoleMethods`] instance.
81251///
81252/// # Example
81253///
81254/// Instantiate a resource method builder
81255///
81256/// ```test_harness,no_run
81257/// # extern crate hyper;
81258/// # extern crate hyper_rustls;
81259/// # extern crate google_dfareporting3d2 as dfareporting3d2;
81260/// use dfareporting3d2::api::UserRole;
81261/// # async fn dox() {
81262/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
81263///
81264/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
81265/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
81266/// #     secret,
81267/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
81268/// # ).build().await.unwrap();
81269///
81270/// # let client = hyper_util::client::legacy::Client::builder(
81271/// #     hyper_util::rt::TokioExecutor::new()
81272/// # )
81273/// # .build(
81274/// #     hyper_rustls::HttpsConnectorBuilder::new()
81275/// #         .with_native_roots()
81276/// #         .unwrap()
81277/// #         .https_or_http()
81278/// #         .enable_http1()
81279/// #         .build()
81280/// # );
81281/// # let mut hub = Dfareporting::new(client, auth);
81282/// // As the method needs a request, you would usually fill it with the desired information
81283/// // into the respective structure. Some of the parts shown here might not be applicable !
81284/// // Values shown here are possibly random and not representative !
81285/// let mut req = UserRole::default();
81286///
81287/// // You can configure optional parameters by calling the respective setters at will, and
81288/// // execute the final call using `doit()`.
81289/// // Values shown here are possibly random and not representative !
81290/// let result = hub.user_roles().insert(req, -11)
81291///              .doit().await;
81292/// # }
81293/// ```
81294pub struct UserRoleInsertCall<'a, C>
81295where
81296    C: 'a,
81297{
81298    hub: &'a Dfareporting<C>,
81299    _request: UserRole,
81300    _profile_id: i64,
81301    _delegate: Option<&'a mut dyn common::Delegate>,
81302    _additional_params: HashMap<String, String>,
81303    _scopes: BTreeSet<String>,
81304}
81305
81306impl<'a, C> common::CallBuilder for UserRoleInsertCall<'a, C> {}
81307
81308impl<'a, C> UserRoleInsertCall<'a, C>
81309where
81310    C: common::Connector,
81311{
81312    /// Perform the operation you have build so far.
81313    pub async fn doit(mut self) -> common::Result<(common::Response, UserRole)> {
81314        use std::borrow::Cow;
81315        use std::io::{Read, Seek};
81316
81317        use common::{url::Params, ToParts};
81318        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
81319
81320        let mut dd = common::DefaultDelegate;
81321        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
81322        dlg.begin(common::MethodInfo {
81323            id: "dfareporting.userRoles.insert",
81324            http_method: hyper::Method::POST,
81325        });
81326
81327        for &field in ["alt", "profileId"].iter() {
81328            if self._additional_params.contains_key(field) {
81329                dlg.finished(false);
81330                return Err(common::Error::FieldClash(field));
81331            }
81332        }
81333
81334        let mut params = Params::with_capacity(4 + self._additional_params.len());
81335        params.push("profileId", self._profile_id.to_string());
81336
81337        params.extend(self._additional_params.iter());
81338
81339        params.push("alt", "json");
81340        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles";
81341        if self._scopes.is_empty() {
81342            self._scopes
81343                .insert(Scope::Dfatrafficking.as_ref().to_string());
81344        }
81345
81346        #[allow(clippy::single_element_loop)]
81347        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
81348            url = params.uri_replacement(url, param_name, find_this, false);
81349        }
81350        {
81351            let to_remove = ["profileId"];
81352            params.remove_params(&to_remove);
81353        }
81354
81355        let url = params.parse_with_url(&url);
81356
81357        let mut json_mime_type = mime::APPLICATION_JSON;
81358        let mut request_value_reader = {
81359            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
81360            common::remove_json_null_values(&mut value);
81361            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
81362            serde_json::to_writer(&mut dst, &value).unwrap();
81363            dst
81364        };
81365        let request_size = request_value_reader
81366            .seek(std::io::SeekFrom::End(0))
81367            .unwrap();
81368        request_value_reader
81369            .seek(std::io::SeekFrom::Start(0))
81370            .unwrap();
81371
81372        loop {
81373            let token = match self
81374                .hub
81375                .auth
81376                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
81377                .await
81378            {
81379                Ok(token) => token,
81380                Err(e) => match dlg.token(e) {
81381                    Ok(token) => token,
81382                    Err(e) => {
81383                        dlg.finished(false);
81384                        return Err(common::Error::MissingToken(e));
81385                    }
81386                },
81387            };
81388            request_value_reader
81389                .seek(std::io::SeekFrom::Start(0))
81390                .unwrap();
81391            let mut req_result = {
81392                let client = &self.hub.client;
81393                dlg.pre_request();
81394                let mut req_builder = hyper::Request::builder()
81395                    .method(hyper::Method::POST)
81396                    .uri(url.as_str())
81397                    .header(USER_AGENT, self.hub._user_agent.clone());
81398
81399                if let Some(token) = token.as_ref() {
81400                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
81401                }
81402
81403                let request = req_builder
81404                    .header(CONTENT_TYPE, json_mime_type.to_string())
81405                    .header(CONTENT_LENGTH, request_size as u64)
81406                    .body(common::to_body(
81407                        request_value_reader.get_ref().clone().into(),
81408                    ));
81409
81410                client.request(request.unwrap()).await
81411            };
81412
81413            match req_result {
81414                Err(err) => {
81415                    if let common::Retry::After(d) = dlg.http_error(&err) {
81416                        sleep(d).await;
81417                        continue;
81418                    }
81419                    dlg.finished(false);
81420                    return Err(common::Error::HttpError(err));
81421                }
81422                Ok(res) => {
81423                    let (mut parts, body) = res.into_parts();
81424                    let mut body = common::Body::new(body);
81425                    if !parts.status.is_success() {
81426                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81427                        let error = serde_json::from_str(&common::to_string(&bytes));
81428                        let response = common::to_response(parts, bytes.into());
81429
81430                        if let common::Retry::After(d) =
81431                            dlg.http_failure(&response, error.as_ref().ok())
81432                        {
81433                            sleep(d).await;
81434                            continue;
81435                        }
81436
81437                        dlg.finished(false);
81438
81439                        return Err(match error {
81440                            Ok(value) => common::Error::BadRequest(value),
81441                            _ => common::Error::Failure(response),
81442                        });
81443                    }
81444                    let response = {
81445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81446                        let encoded = common::to_string(&bytes);
81447                        match serde_json::from_str(&encoded) {
81448                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
81449                            Err(error) => {
81450                                dlg.response_json_decode_error(&encoded, &error);
81451                                return Err(common::Error::JsonDecodeError(
81452                                    encoded.to_string(),
81453                                    error,
81454                                ));
81455                            }
81456                        }
81457                    };
81458
81459                    dlg.finished(true);
81460                    return Ok(response);
81461                }
81462            }
81463        }
81464    }
81465
81466    ///
81467    /// Sets the *request* property to the given value.
81468    ///
81469    /// Even though the property as already been set when instantiating this call,
81470    /// we provide this method for API completeness.
81471    pub fn request(mut self, new_value: UserRole) -> UserRoleInsertCall<'a, C> {
81472        self._request = new_value;
81473        self
81474    }
81475    /// User profile ID associated with this request.
81476    ///
81477    /// Sets the *profile id* path property to the given value.
81478    ///
81479    /// Even though the property as already been set when instantiating this call,
81480    /// we provide this method for API completeness.
81481    pub fn profile_id(mut self, new_value: i64) -> UserRoleInsertCall<'a, C> {
81482        self._profile_id = new_value;
81483        self
81484    }
81485    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
81486    /// while executing the actual API request.
81487    ///
81488    /// ````text
81489    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
81490    /// ````
81491    ///
81492    /// Sets the *delegate* property to the given value.
81493    pub fn delegate(
81494        mut self,
81495        new_value: &'a mut dyn common::Delegate,
81496    ) -> UserRoleInsertCall<'a, C> {
81497        self._delegate = Some(new_value);
81498        self
81499    }
81500
81501    /// Set any additional parameter of the query string used in the request.
81502    /// It should be used to set parameters which are not yet available through their own
81503    /// setters.
81504    ///
81505    /// Please note that this method must not be used to set any of the known parameters
81506    /// which have their own setter method. If done anyway, the request will fail.
81507    ///
81508    /// # Additional Parameters
81509    ///
81510    /// * *alt* (query-string) - Data format for the response.
81511    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
81512    /// * *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.
81513    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
81514    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
81515    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
81516    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
81517    pub fn param<T>(mut self, name: T, value: T) -> UserRoleInsertCall<'a, C>
81518    where
81519        T: AsRef<str>,
81520    {
81521        self._additional_params
81522            .insert(name.as_ref().to_string(), value.as_ref().to_string());
81523        self
81524    }
81525
81526    /// Identifies the authorization scope for the method you are building.
81527    ///
81528    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
81529    /// [`Scope::Dfatrafficking`].
81530    ///
81531    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
81532    /// tokens for more than one scope.
81533    ///
81534    /// Usually there is more than one suitable scope to authorize an operation, some of which may
81535    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
81536    /// sufficient, a read-write scope will do as well.
81537    pub fn add_scope<St>(mut self, scope: St) -> UserRoleInsertCall<'a, C>
81538    where
81539        St: AsRef<str>,
81540    {
81541        self._scopes.insert(String::from(scope.as_ref()));
81542        self
81543    }
81544    /// Identifies the authorization scope(s) for the method you are building.
81545    ///
81546    /// See [`Self::add_scope()`] for details.
81547    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRoleInsertCall<'a, C>
81548    where
81549        I: IntoIterator<Item = St>,
81550        St: AsRef<str>,
81551    {
81552        self._scopes
81553            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
81554        self
81555    }
81556
81557    /// Removes all scopes, and no default scope will be used either.
81558    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
81559    /// for details).
81560    pub fn clear_scopes(mut self) -> UserRoleInsertCall<'a, C> {
81561        self._scopes.clear();
81562        self
81563    }
81564}
81565
81566/// Retrieves a list of user roles, possibly filtered. This method supports paging.
81567///
81568/// A builder for the *list* method supported by a *userRole* resource.
81569/// It is not used directly, but through a [`UserRoleMethods`] instance.
81570///
81571/// # Example
81572///
81573/// Instantiate a resource method builder
81574///
81575/// ```test_harness,no_run
81576/// # extern crate hyper;
81577/// # extern crate hyper_rustls;
81578/// # extern crate google_dfareporting3d2 as dfareporting3d2;
81579/// # async fn dox() {
81580/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
81581///
81582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
81583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
81584/// #     secret,
81585/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
81586/// # ).build().await.unwrap();
81587///
81588/// # let client = hyper_util::client::legacy::Client::builder(
81589/// #     hyper_util::rt::TokioExecutor::new()
81590/// # )
81591/// # .build(
81592/// #     hyper_rustls::HttpsConnectorBuilder::new()
81593/// #         .with_native_roots()
81594/// #         .unwrap()
81595/// #         .https_or_http()
81596/// #         .enable_http1()
81597/// #         .build()
81598/// # );
81599/// # let mut hub = Dfareporting::new(client, auth);
81600/// // You can configure optional parameters by calling the respective setters at will, and
81601/// // execute the final call using `doit()`.
81602/// // Values shown here are possibly random and not representative !
81603/// let result = hub.user_roles().list(-10)
81604///              .subaccount_id(-35)
81605///              .sort_order("voluptua.")
81606///              .sort_field("ipsum")
81607///              .search_string("ea")
81608///              .page_token("ipsum")
81609///              .max_results(-25)
81610///              .add_ids(-26)
81611///              .account_user_role_only(true)
81612///              .doit().await;
81613/// # }
81614/// ```
81615pub struct UserRoleListCall<'a, C>
81616where
81617    C: 'a,
81618{
81619    hub: &'a Dfareporting<C>,
81620    _profile_id: i64,
81621    _subaccount_id: Option<i64>,
81622    _sort_order: Option<String>,
81623    _sort_field: Option<String>,
81624    _search_string: Option<String>,
81625    _page_token: Option<String>,
81626    _max_results: Option<i32>,
81627    _ids: Vec<i64>,
81628    _account_user_role_only: Option<bool>,
81629    _delegate: Option<&'a mut dyn common::Delegate>,
81630    _additional_params: HashMap<String, String>,
81631    _scopes: BTreeSet<String>,
81632}
81633
81634impl<'a, C> common::CallBuilder for UserRoleListCall<'a, C> {}
81635
81636impl<'a, C> UserRoleListCall<'a, C>
81637where
81638    C: common::Connector,
81639{
81640    /// Perform the operation you have build so far.
81641    pub async fn doit(mut self) -> common::Result<(common::Response, UserRolesListResponse)> {
81642        use std::borrow::Cow;
81643        use std::io::{Read, Seek};
81644
81645        use common::{url::Params, ToParts};
81646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
81647
81648        let mut dd = common::DefaultDelegate;
81649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
81650        dlg.begin(common::MethodInfo {
81651            id: "dfareporting.userRoles.list",
81652            http_method: hyper::Method::GET,
81653        });
81654
81655        for &field in [
81656            "alt",
81657            "profileId",
81658            "subaccountId",
81659            "sortOrder",
81660            "sortField",
81661            "searchString",
81662            "pageToken",
81663            "maxResults",
81664            "ids",
81665            "accountUserRoleOnly",
81666        ]
81667        .iter()
81668        {
81669            if self._additional_params.contains_key(field) {
81670                dlg.finished(false);
81671                return Err(common::Error::FieldClash(field));
81672            }
81673        }
81674
81675        let mut params = Params::with_capacity(11 + self._additional_params.len());
81676        params.push("profileId", self._profile_id.to_string());
81677        if let Some(value) = self._subaccount_id.as_ref() {
81678            params.push("subaccountId", value.to_string());
81679        }
81680        if let Some(value) = self._sort_order.as_ref() {
81681            params.push("sortOrder", value);
81682        }
81683        if let Some(value) = self._sort_field.as_ref() {
81684            params.push("sortField", value);
81685        }
81686        if let Some(value) = self._search_string.as_ref() {
81687            params.push("searchString", value);
81688        }
81689        if let Some(value) = self._page_token.as_ref() {
81690            params.push("pageToken", value);
81691        }
81692        if let Some(value) = self._max_results.as_ref() {
81693            params.push("maxResults", value.to_string());
81694        }
81695        if !self._ids.is_empty() {
81696            for f in self._ids.iter() {
81697                params.push("ids", f.to_string());
81698            }
81699        }
81700        if let Some(value) = self._account_user_role_only.as_ref() {
81701            params.push("accountUserRoleOnly", value.to_string());
81702        }
81703
81704        params.extend(self._additional_params.iter());
81705
81706        params.push("alt", "json");
81707        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles";
81708        if self._scopes.is_empty() {
81709            self._scopes
81710                .insert(Scope::Dfatrafficking.as_ref().to_string());
81711        }
81712
81713        #[allow(clippy::single_element_loop)]
81714        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
81715            url = params.uri_replacement(url, param_name, find_this, false);
81716        }
81717        {
81718            let to_remove = ["profileId"];
81719            params.remove_params(&to_remove);
81720        }
81721
81722        let url = params.parse_with_url(&url);
81723
81724        loop {
81725            let token = match self
81726                .hub
81727                .auth
81728                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
81729                .await
81730            {
81731                Ok(token) => token,
81732                Err(e) => match dlg.token(e) {
81733                    Ok(token) => token,
81734                    Err(e) => {
81735                        dlg.finished(false);
81736                        return Err(common::Error::MissingToken(e));
81737                    }
81738                },
81739            };
81740            let mut req_result = {
81741                let client = &self.hub.client;
81742                dlg.pre_request();
81743                let mut req_builder = hyper::Request::builder()
81744                    .method(hyper::Method::GET)
81745                    .uri(url.as_str())
81746                    .header(USER_AGENT, self.hub._user_agent.clone());
81747
81748                if let Some(token) = token.as_ref() {
81749                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
81750                }
81751
81752                let request = req_builder
81753                    .header(CONTENT_LENGTH, 0_u64)
81754                    .body(common::to_body::<String>(None));
81755
81756                client.request(request.unwrap()).await
81757            };
81758
81759            match req_result {
81760                Err(err) => {
81761                    if let common::Retry::After(d) = dlg.http_error(&err) {
81762                        sleep(d).await;
81763                        continue;
81764                    }
81765                    dlg.finished(false);
81766                    return Err(common::Error::HttpError(err));
81767                }
81768                Ok(res) => {
81769                    let (mut parts, body) = res.into_parts();
81770                    let mut body = common::Body::new(body);
81771                    if !parts.status.is_success() {
81772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81773                        let error = serde_json::from_str(&common::to_string(&bytes));
81774                        let response = common::to_response(parts, bytes.into());
81775
81776                        if let common::Retry::After(d) =
81777                            dlg.http_failure(&response, error.as_ref().ok())
81778                        {
81779                            sleep(d).await;
81780                            continue;
81781                        }
81782
81783                        dlg.finished(false);
81784
81785                        return Err(match error {
81786                            Ok(value) => common::Error::BadRequest(value),
81787                            _ => common::Error::Failure(response),
81788                        });
81789                    }
81790                    let response = {
81791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
81792                        let encoded = common::to_string(&bytes);
81793                        match serde_json::from_str(&encoded) {
81794                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
81795                            Err(error) => {
81796                                dlg.response_json_decode_error(&encoded, &error);
81797                                return Err(common::Error::JsonDecodeError(
81798                                    encoded.to_string(),
81799                                    error,
81800                                ));
81801                            }
81802                        }
81803                    };
81804
81805                    dlg.finished(true);
81806                    return Ok(response);
81807                }
81808            }
81809        }
81810    }
81811
81812    /// User profile ID associated with this request.
81813    ///
81814    /// Sets the *profile id* path property to the given value.
81815    ///
81816    /// Even though the property as already been set when instantiating this call,
81817    /// we provide this method for API completeness.
81818    pub fn profile_id(mut self, new_value: i64) -> UserRoleListCall<'a, C> {
81819        self._profile_id = new_value;
81820        self
81821    }
81822    /// Select only user roles that belong to this subaccount.
81823    ///
81824    /// Sets the *subaccount id* query property to the given value.
81825    pub fn subaccount_id(mut self, new_value: i64) -> UserRoleListCall<'a, C> {
81826        self._subaccount_id = Some(new_value);
81827        self
81828    }
81829    /// Order of sorted results.
81830    ///
81831    /// Sets the *sort order* query property to the given value.
81832    pub fn sort_order(mut self, new_value: &str) -> UserRoleListCall<'a, C> {
81833        self._sort_order = Some(new_value.to_string());
81834        self
81835    }
81836    /// Field by which to sort the list.
81837    ///
81838    /// Sets the *sort field* query property to the given value.
81839    pub fn sort_field(mut self, new_value: &str) -> UserRoleListCall<'a, C> {
81840        self._sort_field = Some(new_value.to_string());
81841        self
81842    }
81843    /// Allows searching for objects by name or ID. Wildcards (*) are allowed. For example, "userrole*2015" will return objects with names like "userrole June 2015", "userrole April 2015", or simply "userrole 2015". Most of the searches also add wildcards implicitly at the start and the end of the search string. For example, a search string of "userrole" will match objects with name "my userrole", "userrole 2015", or simply "userrole".
81844    ///
81845    /// Sets the *search string* query property to the given value.
81846    pub fn search_string(mut self, new_value: &str) -> UserRoleListCall<'a, C> {
81847        self._search_string = Some(new_value.to_string());
81848        self
81849    }
81850    /// Value of the nextPageToken from the previous result page.
81851    ///
81852    /// Sets the *page token* query property to the given value.
81853    pub fn page_token(mut self, new_value: &str) -> UserRoleListCall<'a, C> {
81854        self._page_token = Some(new_value.to_string());
81855        self
81856    }
81857    /// Maximum number of results to return.
81858    ///
81859    /// Sets the *max results* query property to the given value.
81860    pub fn max_results(mut self, new_value: i32) -> UserRoleListCall<'a, C> {
81861        self._max_results = Some(new_value);
81862        self
81863    }
81864    /// Select only user roles with the specified IDs.
81865    ///
81866    /// Append the given value to the *ids* query property.
81867    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
81868    pub fn add_ids(mut self, new_value: i64) -> UserRoleListCall<'a, C> {
81869        self._ids.push(new_value);
81870        self
81871    }
81872    /// Select only account level user roles not associated with any specific subaccount.
81873    ///
81874    /// Sets the *account user role only* query property to the given value.
81875    pub fn account_user_role_only(mut self, new_value: bool) -> UserRoleListCall<'a, C> {
81876        self._account_user_role_only = Some(new_value);
81877        self
81878    }
81879    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
81880    /// while executing the actual API request.
81881    ///
81882    /// ````text
81883    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
81884    /// ````
81885    ///
81886    /// Sets the *delegate* property to the given value.
81887    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserRoleListCall<'a, C> {
81888        self._delegate = Some(new_value);
81889        self
81890    }
81891
81892    /// Set any additional parameter of the query string used in the request.
81893    /// It should be used to set parameters which are not yet available through their own
81894    /// setters.
81895    ///
81896    /// Please note that this method must not be used to set any of the known parameters
81897    /// which have their own setter method. If done anyway, the request will fail.
81898    ///
81899    /// # Additional Parameters
81900    ///
81901    /// * *alt* (query-string) - Data format for the response.
81902    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
81903    /// * *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.
81904    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
81905    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
81906    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
81907    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
81908    pub fn param<T>(mut self, name: T, value: T) -> UserRoleListCall<'a, C>
81909    where
81910        T: AsRef<str>,
81911    {
81912        self._additional_params
81913            .insert(name.as_ref().to_string(), value.as_ref().to_string());
81914        self
81915    }
81916
81917    /// Identifies the authorization scope for the method you are building.
81918    ///
81919    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
81920    /// [`Scope::Dfatrafficking`].
81921    ///
81922    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
81923    /// tokens for more than one scope.
81924    ///
81925    /// Usually there is more than one suitable scope to authorize an operation, some of which may
81926    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
81927    /// sufficient, a read-write scope will do as well.
81928    pub fn add_scope<St>(mut self, scope: St) -> UserRoleListCall<'a, C>
81929    where
81930        St: AsRef<str>,
81931    {
81932        self._scopes.insert(String::from(scope.as_ref()));
81933        self
81934    }
81935    /// Identifies the authorization scope(s) for the method you are building.
81936    ///
81937    /// See [`Self::add_scope()`] for details.
81938    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRoleListCall<'a, C>
81939    where
81940        I: IntoIterator<Item = St>,
81941        St: AsRef<str>,
81942    {
81943        self._scopes
81944            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
81945        self
81946    }
81947
81948    /// Removes all scopes, and no default scope will be used either.
81949    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
81950    /// for details).
81951    pub fn clear_scopes(mut self) -> UserRoleListCall<'a, C> {
81952        self._scopes.clear();
81953        self
81954    }
81955}
81956
81957/// Updates an existing user role. This method supports patch semantics.
81958///
81959/// A builder for the *patch* method supported by a *userRole* resource.
81960/// It is not used directly, but through a [`UserRoleMethods`] instance.
81961///
81962/// # Example
81963///
81964/// Instantiate a resource method builder
81965///
81966/// ```test_harness,no_run
81967/// # extern crate hyper;
81968/// # extern crate hyper_rustls;
81969/// # extern crate google_dfareporting3d2 as dfareporting3d2;
81970/// use dfareporting3d2::api::UserRole;
81971/// # async fn dox() {
81972/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
81973///
81974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
81975/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
81976/// #     secret,
81977/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
81978/// # ).build().await.unwrap();
81979///
81980/// # let client = hyper_util::client::legacy::Client::builder(
81981/// #     hyper_util::rt::TokioExecutor::new()
81982/// # )
81983/// # .build(
81984/// #     hyper_rustls::HttpsConnectorBuilder::new()
81985/// #         .with_native_roots()
81986/// #         .unwrap()
81987/// #         .https_or_http()
81988/// #         .enable_http1()
81989/// #         .build()
81990/// # );
81991/// # let mut hub = Dfareporting::new(client, auth);
81992/// // As the method needs a request, you would usually fill it with the desired information
81993/// // into the respective structure. Some of the parts shown here might not be applicable !
81994/// // Values shown here are possibly random and not representative !
81995/// let mut req = UserRole::default();
81996///
81997/// // You can configure optional parameters by calling the respective setters at will, and
81998/// // execute the final call using `doit()`.
81999/// // Values shown here are possibly random and not representative !
82000/// let result = hub.user_roles().patch(req, -69, -44)
82001///              .doit().await;
82002/// # }
82003/// ```
82004pub struct UserRolePatchCall<'a, C>
82005where
82006    C: 'a,
82007{
82008    hub: &'a Dfareporting<C>,
82009    _request: UserRole,
82010    _profile_id: i64,
82011    _id: i64,
82012    _delegate: Option<&'a mut dyn common::Delegate>,
82013    _additional_params: HashMap<String, String>,
82014    _scopes: BTreeSet<String>,
82015}
82016
82017impl<'a, C> common::CallBuilder for UserRolePatchCall<'a, C> {}
82018
82019impl<'a, C> UserRolePatchCall<'a, C>
82020where
82021    C: common::Connector,
82022{
82023    /// Perform the operation you have build so far.
82024    pub async fn doit(mut self) -> common::Result<(common::Response, UserRole)> {
82025        use std::borrow::Cow;
82026        use std::io::{Read, Seek};
82027
82028        use common::{url::Params, ToParts};
82029        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
82030
82031        let mut dd = common::DefaultDelegate;
82032        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
82033        dlg.begin(common::MethodInfo {
82034            id: "dfareporting.userRoles.patch",
82035            http_method: hyper::Method::PATCH,
82036        });
82037
82038        for &field in ["alt", "profileId", "id"].iter() {
82039            if self._additional_params.contains_key(field) {
82040                dlg.finished(false);
82041                return Err(common::Error::FieldClash(field));
82042            }
82043        }
82044
82045        let mut params = Params::with_capacity(5 + self._additional_params.len());
82046        params.push("profileId", self._profile_id.to_string());
82047        params.push("id", self._id.to_string());
82048
82049        params.extend(self._additional_params.iter());
82050
82051        params.push("alt", "json");
82052        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles";
82053        if self._scopes.is_empty() {
82054            self._scopes
82055                .insert(Scope::Dfatrafficking.as_ref().to_string());
82056        }
82057
82058        #[allow(clippy::single_element_loop)]
82059        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
82060            url = params.uri_replacement(url, param_name, find_this, false);
82061        }
82062        {
82063            let to_remove = ["profileId"];
82064            params.remove_params(&to_remove);
82065        }
82066
82067        let url = params.parse_with_url(&url);
82068
82069        let mut json_mime_type = mime::APPLICATION_JSON;
82070        let mut request_value_reader = {
82071            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
82072            common::remove_json_null_values(&mut value);
82073            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
82074            serde_json::to_writer(&mut dst, &value).unwrap();
82075            dst
82076        };
82077        let request_size = request_value_reader
82078            .seek(std::io::SeekFrom::End(0))
82079            .unwrap();
82080        request_value_reader
82081            .seek(std::io::SeekFrom::Start(0))
82082            .unwrap();
82083
82084        loop {
82085            let token = match self
82086                .hub
82087                .auth
82088                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
82089                .await
82090            {
82091                Ok(token) => token,
82092                Err(e) => match dlg.token(e) {
82093                    Ok(token) => token,
82094                    Err(e) => {
82095                        dlg.finished(false);
82096                        return Err(common::Error::MissingToken(e));
82097                    }
82098                },
82099            };
82100            request_value_reader
82101                .seek(std::io::SeekFrom::Start(0))
82102                .unwrap();
82103            let mut req_result = {
82104                let client = &self.hub.client;
82105                dlg.pre_request();
82106                let mut req_builder = hyper::Request::builder()
82107                    .method(hyper::Method::PATCH)
82108                    .uri(url.as_str())
82109                    .header(USER_AGENT, self.hub._user_agent.clone());
82110
82111                if let Some(token) = token.as_ref() {
82112                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
82113                }
82114
82115                let request = req_builder
82116                    .header(CONTENT_TYPE, json_mime_type.to_string())
82117                    .header(CONTENT_LENGTH, request_size as u64)
82118                    .body(common::to_body(
82119                        request_value_reader.get_ref().clone().into(),
82120                    ));
82121
82122                client.request(request.unwrap()).await
82123            };
82124
82125            match req_result {
82126                Err(err) => {
82127                    if let common::Retry::After(d) = dlg.http_error(&err) {
82128                        sleep(d).await;
82129                        continue;
82130                    }
82131                    dlg.finished(false);
82132                    return Err(common::Error::HttpError(err));
82133                }
82134                Ok(res) => {
82135                    let (mut parts, body) = res.into_parts();
82136                    let mut body = common::Body::new(body);
82137                    if !parts.status.is_success() {
82138                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82139                        let error = serde_json::from_str(&common::to_string(&bytes));
82140                        let response = common::to_response(parts, bytes.into());
82141
82142                        if let common::Retry::After(d) =
82143                            dlg.http_failure(&response, error.as_ref().ok())
82144                        {
82145                            sleep(d).await;
82146                            continue;
82147                        }
82148
82149                        dlg.finished(false);
82150
82151                        return Err(match error {
82152                            Ok(value) => common::Error::BadRequest(value),
82153                            _ => common::Error::Failure(response),
82154                        });
82155                    }
82156                    let response = {
82157                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82158                        let encoded = common::to_string(&bytes);
82159                        match serde_json::from_str(&encoded) {
82160                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
82161                            Err(error) => {
82162                                dlg.response_json_decode_error(&encoded, &error);
82163                                return Err(common::Error::JsonDecodeError(
82164                                    encoded.to_string(),
82165                                    error,
82166                                ));
82167                            }
82168                        }
82169                    };
82170
82171                    dlg.finished(true);
82172                    return Ok(response);
82173                }
82174            }
82175        }
82176    }
82177
82178    ///
82179    /// Sets the *request* property to the given value.
82180    ///
82181    /// Even though the property as already been set when instantiating this call,
82182    /// we provide this method for API completeness.
82183    pub fn request(mut self, new_value: UserRole) -> UserRolePatchCall<'a, C> {
82184        self._request = new_value;
82185        self
82186    }
82187    /// User profile ID associated with this request.
82188    ///
82189    /// Sets the *profile id* path property to the given value.
82190    ///
82191    /// Even though the property as already been set when instantiating this call,
82192    /// we provide this method for API completeness.
82193    pub fn profile_id(mut self, new_value: i64) -> UserRolePatchCall<'a, C> {
82194        self._profile_id = new_value;
82195        self
82196    }
82197    /// User role ID.
82198    ///
82199    /// Sets the *id* query property to the given value.
82200    ///
82201    /// Even though the property as already been set when instantiating this call,
82202    /// we provide this method for API completeness.
82203    pub fn id(mut self, new_value: i64) -> UserRolePatchCall<'a, C> {
82204        self._id = new_value;
82205        self
82206    }
82207    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
82208    /// while executing the actual API request.
82209    ///
82210    /// ````text
82211    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
82212    /// ````
82213    ///
82214    /// Sets the *delegate* property to the given value.
82215    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserRolePatchCall<'a, C> {
82216        self._delegate = Some(new_value);
82217        self
82218    }
82219
82220    /// Set any additional parameter of the query string used in the request.
82221    /// It should be used to set parameters which are not yet available through their own
82222    /// setters.
82223    ///
82224    /// Please note that this method must not be used to set any of the known parameters
82225    /// which have their own setter method. If done anyway, the request will fail.
82226    ///
82227    /// # Additional Parameters
82228    ///
82229    /// * *alt* (query-string) - Data format for the response.
82230    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
82231    /// * *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.
82232    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
82233    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
82234    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
82235    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
82236    pub fn param<T>(mut self, name: T, value: T) -> UserRolePatchCall<'a, C>
82237    where
82238        T: AsRef<str>,
82239    {
82240        self._additional_params
82241            .insert(name.as_ref().to_string(), value.as_ref().to_string());
82242        self
82243    }
82244
82245    /// Identifies the authorization scope for the method you are building.
82246    ///
82247    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
82248    /// [`Scope::Dfatrafficking`].
82249    ///
82250    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
82251    /// tokens for more than one scope.
82252    ///
82253    /// Usually there is more than one suitable scope to authorize an operation, some of which may
82254    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
82255    /// sufficient, a read-write scope will do as well.
82256    pub fn add_scope<St>(mut self, scope: St) -> UserRolePatchCall<'a, C>
82257    where
82258        St: AsRef<str>,
82259    {
82260        self._scopes.insert(String::from(scope.as_ref()));
82261        self
82262    }
82263    /// Identifies the authorization scope(s) for the method you are building.
82264    ///
82265    /// See [`Self::add_scope()`] for details.
82266    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRolePatchCall<'a, C>
82267    where
82268        I: IntoIterator<Item = St>,
82269        St: AsRef<str>,
82270    {
82271        self._scopes
82272            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
82273        self
82274    }
82275
82276    /// Removes all scopes, and no default scope will be used either.
82277    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
82278    /// for details).
82279    pub fn clear_scopes(mut self) -> UserRolePatchCall<'a, C> {
82280        self._scopes.clear();
82281        self
82282    }
82283}
82284
82285/// Updates an existing user role.
82286///
82287/// A builder for the *update* method supported by a *userRole* resource.
82288/// It is not used directly, but through a [`UserRoleMethods`] instance.
82289///
82290/// # Example
82291///
82292/// Instantiate a resource method builder
82293///
82294/// ```test_harness,no_run
82295/// # extern crate hyper;
82296/// # extern crate hyper_rustls;
82297/// # extern crate google_dfareporting3d2 as dfareporting3d2;
82298/// use dfareporting3d2::api::UserRole;
82299/// # async fn dox() {
82300/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
82301///
82302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
82303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
82304/// #     secret,
82305/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
82306/// # ).build().await.unwrap();
82307///
82308/// # let client = hyper_util::client::legacy::Client::builder(
82309/// #     hyper_util::rt::TokioExecutor::new()
82310/// # )
82311/// # .build(
82312/// #     hyper_rustls::HttpsConnectorBuilder::new()
82313/// #         .with_native_roots()
82314/// #         .unwrap()
82315/// #         .https_or_http()
82316/// #         .enable_http1()
82317/// #         .build()
82318/// # );
82319/// # let mut hub = Dfareporting::new(client, auth);
82320/// // As the method needs a request, you would usually fill it with the desired information
82321/// // into the respective structure. Some of the parts shown here might not be applicable !
82322/// // Values shown here are possibly random and not representative !
82323/// let mut req = UserRole::default();
82324///
82325/// // You can configure optional parameters by calling the respective setters at will, and
82326/// // execute the final call using `doit()`.
82327/// // Values shown here are possibly random and not representative !
82328/// let result = hub.user_roles().update(req, -79)
82329///              .doit().await;
82330/// # }
82331/// ```
82332pub struct UserRoleUpdateCall<'a, C>
82333where
82334    C: 'a,
82335{
82336    hub: &'a Dfareporting<C>,
82337    _request: UserRole,
82338    _profile_id: i64,
82339    _delegate: Option<&'a mut dyn common::Delegate>,
82340    _additional_params: HashMap<String, String>,
82341    _scopes: BTreeSet<String>,
82342}
82343
82344impl<'a, C> common::CallBuilder for UserRoleUpdateCall<'a, C> {}
82345
82346impl<'a, C> UserRoleUpdateCall<'a, C>
82347where
82348    C: common::Connector,
82349{
82350    /// Perform the operation you have build so far.
82351    pub async fn doit(mut self) -> common::Result<(common::Response, UserRole)> {
82352        use std::borrow::Cow;
82353        use std::io::{Read, Seek};
82354
82355        use common::{url::Params, ToParts};
82356        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
82357
82358        let mut dd = common::DefaultDelegate;
82359        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
82360        dlg.begin(common::MethodInfo {
82361            id: "dfareporting.userRoles.update",
82362            http_method: hyper::Method::PUT,
82363        });
82364
82365        for &field in ["alt", "profileId"].iter() {
82366            if self._additional_params.contains_key(field) {
82367                dlg.finished(false);
82368                return Err(common::Error::FieldClash(field));
82369            }
82370        }
82371
82372        let mut params = Params::with_capacity(4 + self._additional_params.len());
82373        params.push("profileId", self._profile_id.to_string());
82374
82375        params.extend(self._additional_params.iter());
82376
82377        params.push("alt", "json");
82378        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles";
82379        if self._scopes.is_empty() {
82380            self._scopes
82381                .insert(Scope::Dfatrafficking.as_ref().to_string());
82382        }
82383
82384        #[allow(clippy::single_element_loop)]
82385        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
82386            url = params.uri_replacement(url, param_name, find_this, false);
82387        }
82388        {
82389            let to_remove = ["profileId"];
82390            params.remove_params(&to_remove);
82391        }
82392
82393        let url = params.parse_with_url(&url);
82394
82395        let mut json_mime_type = mime::APPLICATION_JSON;
82396        let mut request_value_reader = {
82397            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
82398            common::remove_json_null_values(&mut value);
82399            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
82400            serde_json::to_writer(&mut dst, &value).unwrap();
82401            dst
82402        };
82403        let request_size = request_value_reader
82404            .seek(std::io::SeekFrom::End(0))
82405            .unwrap();
82406        request_value_reader
82407            .seek(std::io::SeekFrom::Start(0))
82408            .unwrap();
82409
82410        loop {
82411            let token = match self
82412                .hub
82413                .auth
82414                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
82415                .await
82416            {
82417                Ok(token) => token,
82418                Err(e) => match dlg.token(e) {
82419                    Ok(token) => token,
82420                    Err(e) => {
82421                        dlg.finished(false);
82422                        return Err(common::Error::MissingToken(e));
82423                    }
82424                },
82425            };
82426            request_value_reader
82427                .seek(std::io::SeekFrom::Start(0))
82428                .unwrap();
82429            let mut req_result = {
82430                let client = &self.hub.client;
82431                dlg.pre_request();
82432                let mut req_builder = hyper::Request::builder()
82433                    .method(hyper::Method::PUT)
82434                    .uri(url.as_str())
82435                    .header(USER_AGENT, self.hub._user_agent.clone());
82436
82437                if let Some(token) = token.as_ref() {
82438                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
82439                }
82440
82441                let request = req_builder
82442                    .header(CONTENT_TYPE, json_mime_type.to_string())
82443                    .header(CONTENT_LENGTH, request_size as u64)
82444                    .body(common::to_body(
82445                        request_value_reader.get_ref().clone().into(),
82446                    ));
82447
82448                client.request(request.unwrap()).await
82449            };
82450
82451            match req_result {
82452                Err(err) => {
82453                    if let common::Retry::After(d) = dlg.http_error(&err) {
82454                        sleep(d).await;
82455                        continue;
82456                    }
82457                    dlg.finished(false);
82458                    return Err(common::Error::HttpError(err));
82459                }
82460                Ok(res) => {
82461                    let (mut parts, body) = res.into_parts();
82462                    let mut body = common::Body::new(body);
82463                    if !parts.status.is_success() {
82464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82465                        let error = serde_json::from_str(&common::to_string(&bytes));
82466                        let response = common::to_response(parts, bytes.into());
82467
82468                        if let common::Retry::After(d) =
82469                            dlg.http_failure(&response, error.as_ref().ok())
82470                        {
82471                            sleep(d).await;
82472                            continue;
82473                        }
82474
82475                        dlg.finished(false);
82476
82477                        return Err(match error {
82478                            Ok(value) => common::Error::BadRequest(value),
82479                            _ => common::Error::Failure(response),
82480                        });
82481                    }
82482                    let response = {
82483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82484                        let encoded = common::to_string(&bytes);
82485                        match serde_json::from_str(&encoded) {
82486                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
82487                            Err(error) => {
82488                                dlg.response_json_decode_error(&encoded, &error);
82489                                return Err(common::Error::JsonDecodeError(
82490                                    encoded.to_string(),
82491                                    error,
82492                                ));
82493                            }
82494                        }
82495                    };
82496
82497                    dlg.finished(true);
82498                    return Ok(response);
82499                }
82500            }
82501        }
82502    }
82503
82504    ///
82505    /// Sets the *request* property to the given value.
82506    ///
82507    /// Even though the property as already been set when instantiating this call,
82508    /// we provide this method for API completeness.
82509    pub fn request(mut self, new_value: UserRole) -> UserRoleUpdateCall<'a, C> {
82510        self._request = new_value;
82511        self
82512    }
82513    /// User profile ID associated with this request.
82514    ///
82515    /// Sets the *profile id* path property to the given value.
82516    ///
82517    /// Even though the property as already been set when instantiating this call,
82518    /// we provide this method for API completeness.
82519    pub fn profile_id(mut self, new_value: i64) -> UserRoleUpdateCall<'a, C> {
82520        self._profile_id = new_value;
82521        self
82522    }
82523    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
82524    /// while executing the actual API request.
82525    ///
82526    /// ````text
82527    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
82528    /// ````
82529    ///
82530    /// Sets the *delegate* property to the given value.
82531    pub fn delegate(
82532        mut self,
82533        new_value: &'a mut dyn common::Delegate,
82534    ) -> UserRoleUpdateCall<'a, C> {
82535        self._delegate = Some(new_value);
82536        self
82537    }
82538
82539    /// Set any additional parameter of the query string used in the request.
82540    /// It should be used to set parameters which are not yet available through their own
82541    /// setters.
82542    ///
82543    /// Please note that this method must not be used to set any of the known parameters
82544    /// which have their own setter method. If done anyway, the request will fail.
82545    ///
82546    /// # Additional Parameters
82547    ///
82548    /// * *alt* (query-string) - Data format for the response.
82549    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
82550    /// * *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.
82551    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
82552    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
82553    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
82554    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
82555    pub fn param<T>(mut self, name: T, value: T) -> UserRoleUpdateCall<'a, C>
82556    where
82557        T: AsRef<str>,
82558    {
82559        self._additional_params
82560            .insert(name.as_ref().to_string(), value.as_ref().to_string());
82561        self
82562    }
82563
82564    /// Identifies the authorization scope for the method you are building.
82565    ///
82566    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
82567    /// [`Scope::Dfatrafficking`].
82568    ///
82569    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
82570    /// tokens for more than one scope.
82571    ///
82572    /// Usually there is more than one suitable scope to authorize an operation, some of which may
82573    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
82574    /// sufficient, a read-write scope will do as well.
82575    pub fn add_scope<St>(mut self, scope: St) -> UserRoleUpdateCall<'a, C>
82576    where
82577        St: AsRef<str>,
82578    {
82579        self._scopes.insert(String::from(scope.as_ref()));
82580        self
82581    }
82582    /// Identifies the authorization scope(s) for the method you are building.
82583    ///
82584    /// See [`Self::add_scope()`] for details.
82585    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRoleUpdateCall<'a, C>
82586    where
82587        I: IntoIterator<Item = St>,
82588        St: AsRef<str>,
82589    {
82590        self._scopes
82591            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
82592        self
82593    }
82594
82595    /// Removes all scopes, and no default scope will be used either.
82596    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
82597    /// for details).
82598    pub fn clear_scopes(mut self) -> UserRoleUpdateCall<'a, C> {
82599        self._scopes.clear();
82600        self
82601    }
82602}
82603
82604/// Gets one video format by ID.
82605///
82606/// A builder for the *get* method supported by a *videoFormat* resource.
82607/// It is not used directly, but through a [`VideoFormatMethods`] instance.
82608///
82609/// # Example
82610///
82611/// Instantiate a resource method builder
82612///
82613/// ```test_harness,no_run
82614/// # extern crate hyper;
82615/// # extern crate hyper_rustls;
82616/// # extern crate google_dfareporting3d2 as dfareporting3d2;
82617/// # async fn dox() {
82618/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
82619///
82620/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
82621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
82622/// #     secret,
82623/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
82624/// # ).build().await.unwrap();
82625///
82626/// # let client = hyper_util::client::legacy::Client::builder(
82627/// #     hyper_util::rt::TokioExecutor::new()
82628/// # )
82629/// # .build(
82630/// #     hyper_rustls::HttpsConnectorBuilder::new()
82631/// #         .with_native_roots()
82632/// #         .unwrap()
82633/// #         .https_or_http()
82634/// #         .enable_http1()
82635/// #         .build()
82636/// # );
82637/// # let mut hub = Dfareporting::new(client, auth);
82638/// // You can configure optional parameters by calling the respective setters at will, and
82639/// // execute the final call using `doit()`.
82640/// // Values shown here are possibly random and not representative !
82641/// let result = hub.video_formats().get(-93, -101)
82642///              .doit().await;
82643/// # }
82644/// ```
82645pub struct VideoFormatGetCall<'a, C>
82646where
82647    C: 'a,
82648{
82649    hub: &'a Dfareporting<C>,
82650    _profile_id: i64,
82651    _id: i32,
82652    _delegate: Option<&'a mut dyn common::Delegate>,
82653    _additional_params: HashMap<String, String>,
82654    _scopes: BTreeSet<String>,
82655}
82656
82657impl<'a, C> common::CallBuilder for VideoFormatGetCall<'a, C> {}
82658
82659impl<'a, C> VideoFormatGetCall<'a, C>
82660where
82661    C: common::Connector,
82662{
82663    /// Perform the operation you have build so far.
82664    pub async fn doit(mut self) -> common::Result<(common::Response, VideoFormat)> {
82665        use std::borrow::Cow;
82666        use std::io::{Read, Seek};
82667
82668        use common::{url::Params, ToParts};
82669        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
82670
82671        let mut dd = common::DefaultDelegate;
82672        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
82673        dlg.begin(common::MethodInfo {
82674            id: "dfareporting.videoFormats.get",
82675            http_method: hyper::Method::GET,
82676        });
82677
82678        for &field in ["alt", "profileId", "id"].iter() {
82679            if self._additional_params.contains_key(field) {
82680                dlg.finished(false);
82681                return Err(common::Error::FieldClash(field));
82682            }
82683        }
82684
82685        let mut params = Params::with_capacity(4 + self._additional_params.len());
82686        params.push("profileId", self._profile_id.to_string());
82687        params.push("id", self._id.to_string());
82688
82689        params.extend(self._additional_params.iter());
82690
82691        params.push("alt", "json");
82692        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/videoFormats/{id}";
82693        if self._scopes.is_empty() {
82694            self._scopes
82695                .insert(Scope::Dfatrafficking.as_ref().to_string());
82696        }
82697
82698        #[allow(clippy::single_element_loop)]
82699        for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() {
82700            url = params.uri_replacement(url, param_name, find_this, false);
82701        }
82702        {
82703            let to_remove = ["id", "profileId"];
82704            params.remove_params(&to_remove);
82705        }
82706
82707        let url = params.parse_with_url(&url);
82708
82709        loop {
82710            let token = match self
82711                .hub
82712                .auth
82713                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
82714                .await
82715            {
82716                Ok(token) => token,
82717                Err(e) => match dlg.token(e) {
82718                    Ok(token) => token,
82719                    Err(e) => {
82720                        dlg.finished(false);
82721                        return Err(common::Error::MissingToken(e));
82722                    }
82723                },
82724            };
82725            let mut req_result = {
82726                let client = &self.hub.client;
82727                dlg.pre_request();
82728                let mut req_builder = hyper::Request::builder()
82729                    .method(hyper::Method::GET)
82730                    .uri(url.as_str())
82731                    .header(USER_AGENT, self.hub._user_agent.clone());
82732
82733                if let Some(token) = token.as_ref() {
82734                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
82735                }
82736
82737                let request = req_builder
82738                    .header(CONTENT_LENGTH, 0_u64)
82739                    .body(common::to_body::<String>(None));
82740
82741                client.request(request.unwrap()).await
82742            };
82743
82744            match req_result {
82745                Err(err) => {
82746                    if let common::Retry::After(d) = dlg.http_error(&err) {
82747                        sleep(d).await;
82748                        continue;
82749                    }
82750                    dlg.finished(false);
82751                    return Err(common::Error::HttpError(err));
82752                }
82753                Ok(res) => {
82754                    let (mut parts, body) = res.into_parts();
82755                    let mut body = common::Body::new(body);
82756                    if !parts.status.is_success() {
82757                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82758                        let error = serde_json::from_str(&common::to_string(&bytes));
82759                        let response = common::to_response(parts, bytes.into());
82760
82761                        if let common::Retry::After(d) =
82762                            dlg.http_failure(&response, error.as_ref().ok())
82763                        {
82764                            sleep(d).await;
82765                            continue;
82766                        }
82767
82768                        dlg.finished(false);
82769
82770                        return Err(match error {
82771                            Ok(value) => common::Error::BadRequest(value),
82772                            _ => common::Error::Failure(response),
82773                        });
82774                    }
82775                    let response = {
82776                        let bytes = common::to_bytes(body).await.unwrap_or_default();
82777                        let encoded = common::to_string(&bytes);
82778                        match serde_json::from_str(&encoded) {
82779                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
82780                            Err(error) => {
82781                                dlg.response_json_decode_error(&encoded, &error);
82782                                return Err(common::Error::JsonDecodeError(
82783                                    encoded.to_string(),
82784                                    error,
82785                                ));
82786                            }
82787                        }
82788                    };
82789
82790                    dlg.finished(true);
82791                    return Ok(response);
82792                }
82793            }
82794        }
82795    }
82796
82797    /// User profile ID associated with this request.
82798    ///
82799    /// Sets the *profile id* path property to the given value.
82800    ///
82801    /// Even though the property as already been set when instantiating this call,
82802    /// we provide this method for API completeness.
82803    pub fn profile_id(mut self, new_value: i64) -> VideoFormatGetCall<'a, C> {
82804        self._profile_id = new_value;
82805        self
82806    }
82807    /// Video format ID.
82808    ///
82809    /// Sets the *id* path property to the given value.
82810    ///
82811    /// Even though the property as already been set when instantiating this call,
82812    /// we provide this method for API completeness.
82813    pub fn id(mut self, new_value: i32) -> VideoFormatGetCall<'a, C> {
82814        self._id = new_value;
82815        self
82816    }
82817    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
82818    /// while executing the actual API request.
82819    ///
82820    /// ````text
82821    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
82822    /// ````
82823    ///
82824    /// Sets the *delegate* property to the given value.
82825    pub fn delegate(
82826        mut self,
82827        new_value: &'a mut dyn common::Delegate,
82828    ) -> VideoFormatGetCall<'a, C> {
82829        self._delegate = Some(new_value);
82830        self
82831    }
82832
82833    /// Set any additional parameter of the query string used in the request.
82834    /// It should be used to set parameters which are not yet available through their own
82835    /// setters.
82836    ///
82837    /// Please note that this method must not be used to set any of the known parameters
82838    /// which have their own setter method. If done anyway, the request will fail.
82839    ///
82840    /// # Additional Parameters
82841    ///
82842    /// * *alt* (query-string) - Data format for the response.
82843    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
82844    /// * *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.
82845    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
82846    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
82847    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
82848    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
82849    pub fn param<T>(mut self, name: T, value: T) -> VideoFormatGetCall<'a, C>
82850    where
82851        T: AsRef<str>,
82852    {
82853        self._additional_params
82854            .insert(name.as_ref().to_string(), value.as_ref().to_string());
82855        self
82856    }
82857
82858    /// Identifies the authorization scope for the method you are building.
82859    ///
82860    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
82861    /// [`Scope::Dfatrafficking`].
82862    ///
82863    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
82864    /// tokens for more than one scope.
82865    ///
82866    /// Usually there is more than one suitable scope to authorize an operation, some of which may
82867    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
82868    /// sufficient, a read-write scope will do as well.
82869    pub fn add_scope<St>(mut self, scope: St) -> VideoFormatGetCall<'a, C>
82870    where
82871        St: AsRef<str>,
82872    {
82873        self._scopes.insert(String::from(scope.as_ref()));
82874        self
82875    }
82876    /// Identifies the authorization scope(s) for the method you are building.
82877    ///
82878    /// See [`Self::add_scope()`] for details.
82879    pub fn add_scopes<I, St>(mut self, scopes: I) -> VideoFormatGetCall<'a, C>
82880    where
82881        I: IntoIterator<Item = St>,
82882        St: AsRef<str>,
82883    {
82884        self._scopes
82885            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
82886        self
82887    }
82888
82889    /// Removes all scopes, and no default scope will be used either.
82890    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
82891    /// for details).
82892    pub fn clear_scopes(mut self) -> VideoFormatGetCall<'a, C> {
82893        self._scopes.clear();
82894        self
82895    }
82896}
82897
82898/// Lists available video formats.
82899///
82900/// A builder for the *list* method supported by a *videoFormat* resource.
82901/// It is not used directly, but through a [`VideoFormatMethods`] instance.
82902///
82903/// # Example
82904///
82905/// Instantiate a resource method builder
82906///
82907/// ```test_harness,no_run
82908/// # extern crate hyper;
82909/// # extern crate hyper_rustls;
82910/// # extern crate google_dfareporting3d2 as dfareporting3d2;
82911/// # async fn dox() {
82912/// # use dfareporting3d2::{Dfareporting, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
82913///
82914/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
82915/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
82916/// #     secret,
82917/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
82918/// # ).build().await.unwrap();
82919///
82920/// # let client = hyper_util::client::legacy::Client::builder(
82921/// #     hyper_util::rt::TokioExecutor::new()
82922/// # )
82923/// # .build(
82924/// #     hyper_rustls::HttpsConnectorBuilder::new()
82925/// #         .with_native_roots()
82926/// #         .unwrap()
82927/// #         .https_or_http()
82928/// #         .enable_http1()
82929/// #         .build()
82930/// # );
82931/// # let mut hub = Dfareporting::new(client, auth);
82932/// // You can configure optional parameters by calling the respective setters at will, and
82933/// // execute the final call using `doit()`.
82934/// // Values shown here are possibly random and not representative !
82935/// let result = hub.video_formats().list(-33)
82936///              .doit().await;
82937/// # }
82938/// ```
82939pub struct VideoFormatListCall<'a, C>
82940where
82941    C: 'a,
82942{
82943    hub: &'a Dfareporting<C>,
82944    _profile_id: i64,
82945    _delegate: Option<&'a mut dyn common::Delegate>,
82946    _additional_params: HashMap<String, String>,
82947    _scopes: BTreeSet<String>,
82948}
82949
82950impl<'a, C> common::CallBuilder for VideoFormatListCall<'a, C> {}
82951
82952impl<'a, C> VideoFormatListCall<'a, C>
82953where
82954    C: common::Connector,
82955{
82956    /// Perform the operation you have build so far.
82957    pub async fn doit(mut self) -> common::Result<(common::Response, VideoFormatsListResponse)> {
82958        use std::borrow::Cow;
82959        use std::io::{Read, Seek};
82960
82961        use common::{url::Params, ToParts};
82962        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
82963
82964        let mut dd = common::DefaultDelegate;
82965        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
82966        dlg.begin(common::MethodInfo {
82967            id: "dfareporting.videoFormats.list",
82968            http_method: hyper::Method::GET,
82969        });
82970
82971        for &field in ["alt", "profileId"].iter() {
82972            if self._additional_params.contains_key(field) {
82973                dlg.finished(false);
82974                return Err(common::Error::FieldClash(field));
82975            }
82976        }
82977
82978        let mut params = Params::with_capacity(3 + self._additional_params.len());
82979        params.push("profileId", self._profile_id.to_string());
82980
82981        params.extend(self._additional_params.iter());
82982
82983        params.push("alt", "json");
82984        let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/videoFormats";
82985        if self._scopes.is_empty() {
82986            self._scopes
82987                .insert(Scope::Dfatrafficking.as_ref().to_string());
82988        }
82989
82990        #[allow(clippy::single_element_loop)]
82991        for &(find_this, param_name) in [("{profileId}", "profileId")].iter() {
82992            url = params.uri_replacement(url, param_name, find_this, false);
82993        }
82994        {
82995            let to_remove = ["profileId"];
82996            params.remove_params(&to_remove);
82997        }
82998
82999        let url = params.parse_with_url(&url);
83000
83001        loop {
83002            let token = match self
83003                .hub
83004                .auth
83005                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
83006                .await
83007            {
83008                Ok(token) => token,
83009                Err(e) => match dlg.token(e) {
83010                    Ok(token) => token,
83011                    Err(e) => {
83012                        dlg.finished(false);
83013                        return Err(common::Error::MissingToken(e));
83014                    }
83015                },
83016            };
83017            let mut req_result = {
83018                let client = &self.hub.client;
83019                dlg.pre_request();
83020                let mut req_builder = hyper::Request::builder()
83021                    .method(hyper::Method::GET)
83022                    .uri(url.as_str())
83023                    .header(USER_AGENT, self.hub._user_agent.clone());
83024
83025                if let Some(token) = token.as_ref() {
83026                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
83027                }
83028
83029                let request = req_builder
83030                    .header(CONTENT_LENGTH, 0_u64)
83031                    .body(common::to_body::<String>(None));
83032
83033                client.request(request.unwrap()).await
83034            };
83035
83036            match req_result {
83037                Err(err) => {
83038                    if let common::Retry::After(d) = dlg.http_error(&err) {
83039                        sleep(d).await;
83040                        continue;
83041                    }
83042                    dlg.finished(false);
83043                    return Err(common::Error::HttpError(err));
83044                }
83045                Ok(res) => {
83046                    let (mut parts, body) = res.into_parts();
83047                    let mut body = common::Body::new(body);
83048                    if !parts.status.is_success() {
83049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
83050                        let error = serde_json::from_str(&common::to_string(&bytes));
83051                        let response = common::to_response(parts, bytes.into());
83052
83053                        if let common::Retry::After(d) =
83054                            dlg.http_failure(&response, error.as_ref().ok())
83055                        {
83056                            sleep(d).await;
83057                            continue;
83058                        }
83059
83060                        dlg.finished(false);
83061
83062                        return Err(match error {
83063                            Ok(value) => common::Error::BadRequest(value),
83064                            _ => common::Error::Failure(response),
83065                        });
83066                    }
83067                    let response = {
83068                        let bytes = common::to_bytes(body).await.unwrap_or_default();
83069                        let encoded = common::to_string(&bytes);
83070                        match serde_json::from_str(&encoded) {
83071                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
83072                            Err(error) => {
83073                                dlg.response_json_decode_error(&encoded, &error);
83074                                return Err(common::Error::JsonDecodeError(
83075                                    encoded.to_string(),
83076                                    error,
83077                                ));
83078                            }
83079                        }
83080                    };
83081
83082                    dlg.finished(true);
83083                    return Ok(response);
83084                }
83085            }
83086        }
83087    }
83088
83089    /// User profile ID associated with this request.
83090    ///
83091    /// Sets the *profile id* path property to the given value.
83092    ///
83093    /// Even though the property as already been set when instantiating this call,
83094    /// we provide this method for API completeness.
83095    pub fn profile_id(mut self, new_value: i64) -> VideoFormatListCall<'a, C> {
83096        self._profile_id = new_value;
83097        self
83098    }
83099    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
83100    /// while executing the actual API request.
83101    ///
83102    /// ````text
83103    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
83104    /// ````
83105    ///
83106    /// Sets the *delegate* property to the given value.
83107    pub fn delegate(
83108        mut self,
83109        new_value: &'a mut dyn common::Delegate,
83110    ) -> VideoFormatListCall<'a, C> {
83111        self._delegate = Some(new_value);
83112        self
83113    }
83114
83115    /// Set any additional parameter of the query string used in the request.
83116    /// It should be used to set parameters which are not yet available through their own
83117    /// setters.
83118    ///
83119    /// Please note that this method must not be used to set any of the known parameters
83120    /// which have their own setter method. If done anyway, the request will fail.
83121    ///
83122    /// # Additional Parameters
83123    ///
83124    /// * *alt* (query-string) - Data format for the response.
83125    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
83126    /// * *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.
83127    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
83128    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
83129    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
83130    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
83131    pub fn param<T>(mut self, name: T, value: T) -> VideoFormatListCall<'a, C>
83132    where
83133        T: AsRef<str>,
83134    {
83135        self._additional_params
83136            .insert(name.as_ref().to_string(), value.as_ref().to_string());
83137        self
83138    }
83139
83140    /// Identifies the authorization scope for the method you are building.
83141    ///
83142    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
83143    /// [`Scope::Dfatrafficking`].
83144    ///
83145    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
83146    /// tokens for more than one scope.
83147    ///
83148    /// Usually there is more than one suitable scope to authorize an operation, some of which may
83149    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
83150    /// sufficient, a read-write scope will do as well.
83151    pub fn add_scope<St>(mut self, scope: St) -> VideoFormatListCall<'a, C>
83152    where
83153        St: AsRef<str>,
83154    {
83155        self._scopes.insert(String::from(scope.as_ref()));
83156        self
83157    }
83158    /// Identifies the authorization scope(s) for the method you are building.
83159    ///
83160    /// See [`Self::add_scope()`] for details.
83161    pub fn add_scopes<I, St>(mut self, scopes: I) -> VideoFormatListCall<'a, C>
83162    where
83163        I: IntoIterator<Item = St>,
83164        St: AsRef<str>,
83165    {
83166        self._scopes
83167            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
83168        self
83169    }
83170
83171    /// Removes all scopes, and no default scope will be used either.
83172    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
83173    /// for details).
83174    pub fn clear_scopes(mut self) -> VideoFormatListCall<'a, C> {
83175        self._scopes.clear();
83176        self
83177    }
83178}