use std::collections::HashMap; use std::cell::RefCell; use std::default::Default; use std::collections::BTreeMap; use std::error::Error as StdError; use serde_json as json; use std::io; use std::fs; use std::mem; use std::thread::sleep; use http::Uri; use hyper::client::connect; use tokio::io::{AsyncRead, AsyncWrite}; use tower_service; use crate::client; // ############## // UTILITIES ### // ############ /// Identifies the an OAuth2 authorization scope. /// A scope is needed when requesting an /// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). #[derive(PartialEq, Eq, Hash)] pub enum Scope { /// Manage DoubleClick Digital Marketing conversions Ddmconversion, /// View and manage DoubleClick for Advertisers reports Full, /// View and manage your DoubleClick Campaign Manager's (DCM) display ad campaigns Dfatrafficking, } impl AsRef for Scope { fn as_ref(&self) -> &str { match *self { Scope::Ddmconversion => "https://www.googleapis.com/auth/ddmconversions", Scope::Full => "https://www.googleapis.com/auth/dfareporting", Scope::Dfatrafficking => "https://www.googleapis.com/auth/dfatrafficking", } } } impl Default for Scope { fn default() -> Scope { Scope::Full } } // ######## // HUB ### // ###### /// Central instance to access all Dfareporting related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::{Result, Error}; /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// // Get an ApplicationSecret instance by some means. It contains the `client_id` and /// // `client_secret`, among other things. /// let secret: oauth2::ApplicationSecret = Default::default(); /// // Instantiate the authenticator. It will choose a suitable authentication flow for you, /// // unless you replace `None` with the desired Flow. /// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about /// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and /// // retrieve them from storage. /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().files_list("profileId", "reportId") /// .sort_order("Lorem") /// .sort_field("gubergren") /// .page_token("eos") /// .max_results(-4) /// .doit().await; /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::Io(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` #[derive(Clone)] pub struct Dfareporting { pub client: hyper::Client, pub auth: oauth2::authenticator::Authenticator, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, S> client::Hub for Dfareporting {} impl<'a, S> Dfareporting { pub fn new(client: hyper::Client, authenticator: oauth2::authenticator::Authenticator) -> Dfareporting { Dfareporting { client, auth: authenticator, _user_agent: "google-api-rust-client/4.0.1".to_string(), _base_url: "https://www.googleapis.com/dfareporting/v3.2/".to_string(), _root_url: "https://www.googleapis.com/".to_string(), } } pub fn account_active_ad_summaries(&'a self) -> AccountActiveAdSummaryMethods<'a, S> { AccountActiveAdSummaryMethods { hub: &self } } pub fn account_permission_groups(&'a self) -> AccountPermissionGroupMethods<'a, S> { AccountPermissionGroupMethods { hub: &self } } pub fn account_permissions(&'a self) -> AccountPermissionMethods<'a, S> { AccountPermissionMethods { hub: &self } } pub fn account_user_profiles(&'a self) -> AccountUserProfileMethods<'a, S> { AccountUserProfileMethods { hub: &self } } pub fn accounts(&'a self) -> AccountMethods<'a, S> { AccountMethods { hub: &self } } pub fn ads(&'a self) -> AdMethods<'a, S> { AdMethods { hub: &self } } pub fn advertiser_groups(&'a self) -> AdvertiserGroupMethods<'a, S> { AdvertiserGroupMethods { hub: &self } } pub fn advertiser_landing_pages(&'a self) -> AdvertiserLandingPageMethods<'a, S> { AdvertiserLandingPageMethods { hub: &self } } pub fn advertisers(&'a self) -> AdvertiserMethods<'a, S> { AdvertiserMethods { hub: &self } } pub fn browsers(&'a self) -> BrowserMethods<'a, S> { BrowserMethods { hub: &self } } pub fn campaign_creative_associations(&'a self) -> CampaignCreativeAssociationMethods<'a, S> { CampaignCreativeAssociationMethods { hub: &self } } pub fn campaigns(&'a self) -> CampaignMethods<'a, S> { CampaignMethods { hub: &self } } pub fn change_logs(&'a self) -> ChangeLogMethods<'a, S> { ChangeLogMethods { hub: &self } } pub fn cities(&'a self) -> CityMethods<'a, S> { CityMethods { hub: &self } } pub fn connection_types(&'a self) -> ConnectionTypeMethods<'a, S> { ConnectionTypeMethods { hub: &self } } pub fn content_categories(&'a self) -> ContentCategoryMethods<'a, S> { ContentCategoryMethods { hub: &self } } pub fn conversions(&'a self) -> ConversionMethods<'a, S> { ConversionMethods { hub: &self } } pub fn countries(&'a self) -> CountryMethods<'a, S> { CountryMethods { hub: &self } } pub fn creative_assets(&'a self) -> CreativeAssetMethods<'a, S> { CreativeAssetMethods { hub: &self } } pub fn creative_field_values(&'a self) -> CreativeFieldValueMethods<'a, S> { CreativeFieldValueMethods { hub: &self } } pub fn creative_fields(&'a self) -> CreativeFieldMethods<'a, S> { CreativeFieldMethods { hub: &self } } pub fn creative_groups(&'a self) -> CreativeGroupMethods<'a, S> { CreativeGroupMethods { hub: &self } } pub fn creatives(&'a self) -> CreativeMethods<'a, S> { CreativeMethods { hub: &self } } pub fn dimension_values(&'a self) -> DimensionValueMethods<'a, S> { DimensionValueMethods { hub: &self } } pub fn directory_site_contacts(&'a self) -> DirectorySiteContactMethods<'a, S> { DirectorySiteContactMethods { hub: &self } } pub fn directory_sites(&'a self) -> DirectorySiteMethods<'a, S> { DirectorySiteMethods { hub: &self } } pub fn dynamic_targeting_keys(&'a self) -> DynamicTargetingKeyMethods<'a, S> { DynamicTargetingKeyMethods { hub: &self } } pub fn event_tags(&'a self) -> EventTagMethods<'a, S> { EventTagMethods { hub: &self } } pub fn files(&'a self) -> FileMethods<'a, S> { FileMethods { hub: &self } } pub fn floodlight_activities(&'a self) -> FloodlightActivityMethods<'a, S> { FloodlightActivityMethods { hub: &self } } pub fn floodlight_activity_groups(&'a self) -> FloodlightActivityGroupMethods<'a, S> { FloodlightActivityGroupMethods { hub: &self } } pub fn floodlight_configurations(&'a self) -> FloodlightConfigurationMethods<'a, S> { FloodlightConfigurationMethods { hub: &self } } pub fn inventory_items(&'a self) -> InventoryItemMethods<'a, S> { InventoryItemMethods { hub: &self } } pub fn languages(&'a self) -> LanguageMethods<'a, S> { LanguageMethods { hub: &self } } pub fn metros(&'a self) -> MetroMethods<'a, S> { MetroMethods { hub: &self } } pub fn mobile_apps(&'a self) -> MobileAppMethods<'a, S> { MobileAppMethods { hub: &self } } pub fn mobile_carriers(&'a self) -> MobileCarrierMethods<'a, S> { MobileCarrierMethods { hub: &self } } pub fn operating_system_versions(&'a self) -> OperatingSystemVersionMethods<'a, S> { OperatingSystemVersionMethods { hub: &self } } pub fn operating_systems(&'a self) -> OperatingSystemMethods<'a, S> { OperatingSystemMethods { hub: &self } } pub fn order_documents(&'a self) -> OrderDocumentMethods<'a, S> { OrderDocumentMethods { hub: &self } } pub fn orders(&'a self) -> OrderMethods<'a, S> { OrderMethods { hub: &self } } pub fn placement_groups(&'a self) -> PlacementGroupMethods<'a, S> { PlacementGroupMethods { hub: &self } } pub fn placement_strategies(&'a self) -> PlacementStrategyMethods<'a, S> { PlacementStrategyMethods { hub: &self } } pub fn placements(&'a self) -> PlacementMethods<'a, S> { PlacementMethods { hub: &self } } pub fn platform_types(&'a self) -> PlatformTypeMethods<'a, S> { PlatformTypeMethods { hub: &self } } pub fn postal_codes(&'a self) -> PostalCodeMethods<'a, S> { PostalCodeMethods { hub: &self } } pub fn projects(&'a self) -> ProjectMethods<'a, S> { ProjectMethods { hub: &self } } pub fn regions(&'a self) -> RegionMethods<'a, S> { RegionMethods { hub: &self } } pub fn remarketing_list_shares(&'a self) -> RemarketingListShareMethods<'a, S> { RemarketingListShareMethods { hub: &self } } pub fn remarketing_lists(&'a self) -> RemarketingListMethods<'a, S> { RemarketingListMethods { hub: &self } } pub fn reports(&'a self) -> ReportMethods<'a, S> { ReportMethods { hub: &self } } pub fn sites(&'a self) -> SiteMethods<'a, S> { SiteMethods { hub: &self } } pub fn sizes(&'a self) -> SizeMethods<'a, S> { SizeMethods { hub: &self } } pub fn subaccounts(&'a self) -> SubaccountMethods<'a, S> { SubaccountMethods { hub: &self } } pub fn targetable_remarketing_lists(&'a self) -> TargetableRemarketingListMethods<'a, S> { TargetableRemarketingListMethods { hub: &self } } pub fn targeting_templates(&'a self) -> TargetingTemplateMethods<'a, S> { TargetingTemplateMethods { hub: &self } } pub fn user_profiles(&'a self) -> UserProfileMethods<'a, S> { UserProfileMethods { hub: &self } } pub fn user_role_permission_groups(&'a self) -> UserRolePermissionGroupMethods<'a, S> { UserRolePermissionGroupMethods { hub: &self } } pub fn user_role_permissions(&'a self) -> UserRolePermissionMethods<'a, S> { UserRolePermissionMethods { hub: &self } } pub fn user_roles(&'a self) -> UserRoleMethods<'a, S> { UserRoleMethods { hub: &self } } pub fn video_formats(&'a self) -> VideoFormatMethods<'a, S> { VideoFormatMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/4.0.1`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://www.googleapis.com/dfareporting/v3.2/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://www.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Contains properties of a Campaign Manager account. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get accounts](AccountGetCall) (response) /// * [list accounts](AccountListCall) (none) /// * [patch accounts](AccountPatchCall) (request|response) /// * [update accounts](AccountUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Account { /// Account permissions assigned to this account. #[serde(rename="accountPermissionIds")] pub account_permission_ids: Option>, /// Profile for this account. This is a read-only field that can be left blank. #[serde(rename="accountProfile")] pub account_profile: Option, /// Whether this account is active. pub active: Option, /// Maximum number of active ads allowed for this account. #[serde(rename="activeAdsLimitTier")] pub active_ads_limit_tier: Option, /// Whether to serve creatives with Active View tags. If disabled, viewability data will not be available for any impressions. #[serde(rename="activeViewOptOut")] pub active_view_opt_out: Option, /// User role permissions available to the user roles of this account. #[serde(rename="availablePermissionIds")] pub available_permission_ids: Option>, /// ID of the country associated with this account. #[serde(rename="countryId")] pub country_id: Option, /// ID of currency associated with this account. This is a required field. /// Acceptable values are: /// - "1" for USD /// - "2" for GBP /// - "3" for ESP /// - "4" for SEK /// - "5" for CAD /// - "6" for JPY /// - "7" for DEM /// - "8" for AUD /// - "9" for FRF /// - "10" for ITL /// - "11" for DKK /// - "12" for NOK /// - "13" for FIM /// - "14" for ZAR /// - "15" for IEP /// - "16" for NLG /// - "17" for EUR /// - "18" for KRW /// - "19" for TWD /// - "20" for SGD /// - "21" for CNY /// - "22" for HKD /// - "23" for NZD /// - "24" for MYR /// - "25" for BRL /// - "26" for PTE /// - "27" for MXP /// - "28" for CLP /// - "29" for TRY /// - "30" for ARS /// - "31" for PEN /// - "32" for ILS /// - "33" for CHF /// - "34" for VEF /// - "35" for COP /// - "36" for GTQ /// - "37" for PLN /// - "39" for INR /// - "40" for THB /// - "41" for IDR /// - "42" for CZK /// - "43" for RON /// - "44" for HUF /// - "45" for RUB /// - "46" for AED /// - "47" for BGN /// - "48" for HRK /// - "49" for MXN /// - "50" for NGN #[serde(rename="currencyId")] pub currency_id: Option, /// Default placement dimensions for this account. #[serde(rename="defaultCreativeSizeId")] pub default_creative_size_id: Option, /// Description of this account. pub description: Option, /// ID of this account. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#account". pub kind: Option, /// Locale of this account. /// Acceptable values are: /// - "cs" (Czech) /// - "de" (German) /// - "en" (English) /// - "en-GB" (English United Kingdom) /// - "es" (Spanish) /// - "fr" (French) /// - "it" (Italian) /// - "ja" (Japanese) /// - "ko" (Korean) /// - "pl" (Polish) /// - "pt-BR" (Portuguese Brazil) /// - "ru" (Russian) /// - "sv" (Swedish) /// - "tr" (Turkish) /// - "zh-CN" (Chinese Simplified) /// - "zh-TW" (Chinese Traditional) pub locale: Option, /// Maximum image size allowed for this account, in kilobytes. Value must be greater than or equal to 1. #[serde(rename="maximumImageSize")] pub maximum_image_size: Option, /// Name of this account. This is a required field, and must be less than 128 characters long and be globally unique. pub name: Option, /// Whether campaigns created in this account will be enabled for Nielsen OCR reach ratings by default. #[serde(rename="nielsenOcrEnabled")] pub nielsen_ocr_enabled: Option, /// Reporting configuration of this account. #[serde(rename="reportsConfiguration")] pub reports_configuration: Option, /// Share Path to Conversion reports with Twitter. #[serde(rename="shareReportsWithTwitter")] pub share_reports_with_twitter: Option, /// File size limit in kilobytes of Rich Media teaser creatives. Acceptable values are 1 to 10240, inclusive. #[serde(rename="teaserSizeLimit")] pub teaser_size_limit: Option, } impl client::RequestValue for Account {} impl client::Resource for Account {} impl client::ResponseResult for Account {} /// Gets a summary of active ads in an account. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get account active ad summaries](AccountActiveAdSummaryGetCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountActiveAdSummary { /// ID of the account. #[serde(rename="accountId")] pub account_id: Option, /// Ads that have been activated for the account #[serde(rename="activeAds")] pub active_ads: Option, /// Maximum number of active ads allowed for the account. #[serde(rename="activeAdsLimitTier")] pub active_ads_limit_tier: Option, /// Ads that can be activated for the account. #[serde(rename="availableAds")] pub available_ads: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountActiveAdSummary". pub kind: Option, } impl client::ResponseResult for AccountActiveAdSummary {} /// AccountPermissions contains information about a particular account permission. Some features of Campaign Manager require an account permission to be present in the account. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get account permissions](AccountPermissionGetCall) (response) /// * [list account permissions](AccountPermissionListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermission { /// Account profiles associated with this account permission. /// /// Possible values are: /// - "ACCOUNT_PROFILE_BASIC" /// - "ACCOUNT_PROFILE_STANDARD" #[serde(rename="accountProfiles")] pub account_profiles: Option>, /// ID of this account permission. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermission". pub kind: Option, /// Administrative level required to enable this account permission. pub level: Option, /// Name of this account permission. pub name: Option, /// Permission group of this account permission. #[serde(rename="permissionGroupId")] pub permission_group_id: Option, } impl client::Resource for AccountPermission {} impl client::ResponseResult for AccountPermission {} /// AccountPermissionGroups contains a mapping of permission group IDs to names. A permission group is a grouping of account permissions. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get account permission groups](AccountPermissionGroupGetCall) (response) /// * [list account permission groups](AccountPermissionGroupListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissionGroup { /// ID of this account permission group. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroup". pub kind: Option, /// Name of this account permission group. pub name: Option, } impl client::Resource for AccountPermissionGroup {} impl client::ResponseResult for AccountPermissionGroup {} /// Account Permission Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list account permission groups](AccountPermissionGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissionGroupsListResponse { /// Account permission group collection. #[serde(rename="accountPermissionGroups")] pub account_permission_groups: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionGroupsListResponse". pub kind: Option, } impl client::ResponseResult for AccountPermissionGroupsListResponse {} /// Account Permission List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list account permissions](AccountPermissionListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountPermissionsListResponse { /// Account permission collection. #[serde(rename="accountPermissions")] pub account_permissions: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountPermissionsListResponse". pub kind: Option, } impl client::ResponseResult for AccountPermissionsListResponse {} /// AccountUserProfiles contains properties of a Campaign Manager user profile. This resource is specifically for managing user profiles, whereas UserProfiles is for accessing the API. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get account user profiles](AccountUserProfileGetCall) (response) /// * [insert account user profiles](AccountUserProfileInsertCall) (request|response) /// * [list account user profiles](AccountUserProfileListCall) (none) /// * [patch account user profiles](AccountUserProfilePatchCall) (request|response) /// * [update account user profiles](AccountUserProfileUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountUserProfile { /// Account ID of the user profile. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Whether this user profile is active. This defaults to false, and must be set true on insert for the user profile to be usable. pub active: Option, /// Filter that describes which advertisers are visible to the user profile. #[serde(rename="advertiserFilter")] pub advertiser_filter: Option, /// Filter that describes which campaigns are visible to the user profile. #[serde(rename="campaignFilter")] pub campaign_filter: Option, /// Comments for this user profile. pub comments: Option, /// 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. pub email: Option, /// ID of the user profile. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfile". pub kind: Option, /// Locale of the user profile. This is a required field. /// Acceptable values are: /// - "cs" (Czech) /// - "de" (German) /// - "en" (English) /// - "en-GB" (English United Kingdom) /// - "es" (Spanish) /// - "fr" (French) /// - "it" (Italian) /// - "ja" (Japanese) /// - "ko" (Korean) /// - "pl" (Polish) /// - "pt-BR" (Portuguese Brazil) /// - "ru" (Russian) /// - "sv" (Swedish) /// - "tr" (Turkish) /// - "zh-CN" (Chinese Simplified) /// - "zh-TW" (Chinese Traditional) pub locale: Option, /// 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: "&;"#%,". pub name: Option, /// Filter that describes which sites are visible to the user profile. #[serde(rename="siteFilter")] pub site_filter: Option, /// Subaccount ID of the user profile. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Trafficker type of this user profile. This is a read-only field. #[serde(rename="traffickerType")] pub trafficker_type: Option, /// User type of the user profile. This is a read-only field that can be left blank. #[serde(rename="userAccessType")] pub user_access_type: Option, /// Filter that describes which user roles are visible to the user profile. #[serde(rename="userRoleFilter")] pub user_role_filter: Option, /// User role ID of the user profile. This is a required field. #[serde(rename="userRoleId")] pub user_role_id: Option, } impl client::RequestValue for AccountUserProfile {} impl client::Resource for AccountUserProfile {} impl client::ResponseResult for AccountUserProfile {} /// Account User Profile List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list account user profiles](AccountUserProfileListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountUserProfilesListResponse { /// Account user profile collection. #[serde(rename="accountUserProfiles")] pub account_user_profiles: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountUserProfilesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AccountUserProfilesListResponse {} /// Account List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list accounts](AccountListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AccountsListResponse { /// Account collection. pub accounts: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#accountsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AccountsListResponse {} /// Represents an activity group. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Activities { /// List of activity filters. The dimension values need to be all either of type "dfa:activity" or "dfa:activityGroup". pub filters: Option>, /// The kind of resource this is, in this case dfareporting#activities. pub kind: Option, /// List of names of floodlight activity metrics. #[serde(rename="metricNames")] pub metric_names: Option>, } impl client::Part for Activities {} /// Contains properties of a Campaign Manager ad. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get ads](AdGetCall) (response) /// * [insert ads](AdInsertCall) (request|response) /// * [list ads](AdListCall) (none) /// * [patch ads](AdPatchCall) (request|response) /// * [update ads](AdUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Ad { /// Account ID of this ad. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Whether this ad is active. When true, archived must be false. pub active: Option, /// Advertiser ID of this ad. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Whether this ad is archived. When true, active must be false. pub archived: Option, /// Audience segment ID that is being targeted for this ad. Applicable when type is AD_SERVING_STANDARD_AD. #[serde(rename="audienceSegmentId")] pub audience_segment_id: Option, /// Campaign ID of this ad. This is a required field on insertion. #[serde(rename="campaignId")] pub campaign_id: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. #[serde(rename="campaignIdDimensionValue")] pub campaign_id_dimension_value: Option, /// Click-through URL for this ad. This is a required field on insertion. Applicable when type is AD_SERVING_CLICK_TRACKER. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// 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. #[serde(rename="clickThroughUrlSuffixProperties")] pub click_through_url_suffix_properties: Option, /// Comments for this ad. pub comments: Option, /// 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. pub compatibility: Option, /// Information about the creation of this ad. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// 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. #[serde(rename="creativeGroupAssignments")] pub creative_group_assignments: Option>, /// 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. #[serde(rename="creativeRotation")] pub creative_rotation: Option, /// 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. #[serde(rename="dayPartTargeting")] pub day_part_targeting: Option, /// Default click-through event tag properties for this ad. #[serde(rename="defaultClickThroughEventTagProperties")] pub default_click_through_event_tag_properties: Option, /// 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. #[serde(rename="deliverySchedule")] pub delivery_schedule: Option, /// 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. #[serde(rename="dynamicClickTracker")] pub dynamic_click_tracker: Option, /// Date and time that this ad should stop serving. Must be later than the start time. This is a required field on insertion. #[serde(rename="endTime")] pub end_time: Option, /// Event tag overrides for this ad. #[serde(rename="eventTagOverrides")] pub event_tag_overrides: Option>, /// 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. #[serde(rename="geoTargeting")] pub geo_targeting: Option, /// ID of this ad. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this ad. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// 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. #[serde(rename="keyValueTargetingExpression")] pub key_value_targeting_expression: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ad". pub kind: Option, /// 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. #[serde(rename="languageTargeting")] pub language_targeting: Option, /// Information about the most recent modification of this ad. This is a read-only field. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Name of this ad. This is a required field and must be less than 256 characters long. pub name: Option, /// Placement assignments for this ad. #[serde(rename="placementAssignments")] pub placement_assignments: Option>, /// 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. #[serde(rename="remarketingListExpression")] pub remarketing_list_expression: Option, /// Size of this ad. Applicable when type is AD_SERVING_DEFAULT_AD. pub size: Option, /// Whether this ad is ssl compliant. This is a read-only field that is auto-generated when the ad is inserted or updated. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Whether this ad requires ssl. This is a read-only field that is auto-generated when the ad is inserted or updated. #[serde(rename="sslRequired")] pub ssl_required: Option, /// 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. #[serde(rename="startTime")] pub start_time: Option, /// Subaccount ID of this ad. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// 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. #[serde(rename="targetingTemplateId")] pub targeting_template_id: Option, /// 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. #[serde(rename="technologyTargeting")] pub technology_targeting: Option, /// 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). #[serde(rename="type")] pub type_: Option, } impl client::RequestValue for Ad {} impl client::Resource for Ad {} impl client::ResponseResult for Ad {} /// Campaign ad blocking settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdBlockingConfiguration { /// Click-through URL used by brand-neutral ads. This is a required field when overrideClickThroughUrl is set to true. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// 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. #[serde(rename="creativeBundleId")] pub creative_bundle_id: Option, /// 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. pub enabled: Option, /// 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. #[serde(rename="overrideClickThroughUrl")] pub override_click_through_url: Option, } impl client::Part for AdBlockingConfiguration {} /// Ad Slot /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdSlot { /// Comment for this ad slot. pub comment: Option, /// 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. pub compatibility: Option, /// Height of this ad slot. pub height: Option, /// ID of the placement from an external platform that is linked to this ad slot. #[serde(rename="linkedPlacementId")] pub linked_placement_id: Option, /// Name of this ad slot. pub name: Option, /// Payment source type of this ad slot. #[serde(rename="paymentSourceType")] pub payment_source_type: Option, /// Primary ad slot of a roadblock inventory item. pub primary: Option, /// Width of this ad slot. pub width: Option, } impl client::Part for AdSlot {} /// Ad List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list ads](AdListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdsListResponse { /// Ad collection. pub ads: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#adsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AdsListResponse {} /// Contains properties of a Campaign Manager advertiser. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get advertisers](AdvertiserGetCall) (response) /// * [insert advertisers](AdvertiserInsertCall) (request|response) /// * [list advertisers](AdvertiserListCall) (none) /// * [patch advertisers](AdvertiserPatchCall) (request|response) /// * [update advertisers](AdvertiserUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Advertiser { /// Account ID of this advertiser.This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="advertiserGroupId")] pub advertiser_group_id: Option, /// Suffix added to click-through URL of ad creative associations under this advertiser. Must be less than 129 characters long. #[serde(rename="clickThroughUrlSuffix")] pub click_through_url_suffix: Option, /// ID of the click-through event tag to apply by default to the landing pages of this advertiser's campaigns. #[serde(rename="defaultClickThroughEventTagId")] pub default_click_through_event_tag_id: Option, /// Default email address used in sender field for tag emails. #[serde(rename="defaultEmail")] pub default_email: Option, /// 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: /// - This advertiser's original floodlight configuration is not already associated with floodlight activities or floodlight activity groups. /// - This advertiser's original floodlight configuration is not already shared with another advertiser. #[serde(rename="floodlightConfigurationId")] pub floodlight_configuration_id: Option, /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. #[serde(rename="floodlightConfigurationIdDimensionValue")] pub floodlight_configuration_id_dimension_value: Option, /// ID of this advertiser. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this advertiser. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiser". pub kind: Option, /// 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. pub name: Option, /// 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. #[serde(rename="originalFloodlightConfigurationId")] pub original_floodlight_configuration_id: Option, /// Status of this advertiser. pub status: Option, /// Subaccount ID of this advertiser.This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Suspension status of this advertiser. pub suspended: Option, } impl client::RequestValue for Advertiser {} impl client::Resource for Advertiser {} impl client::ResponseResult for Advertiser {} /// Groups advertisers together so that reports can be generated for the entire group at once. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete advertiser groups](AdvertiserGroupDeleteCall) (none) /// * [get advertiser groups](AdvertiserGroupGetCall) (response) /// * [insert advertiser groups](AdvertiserGroupInsertCall) (request|response) /// * [list advertiser groups](AdvertiserGroupListCall) (none) /// * [patch advertiser groups](AdvertiserGroupPatchCall) (request|response) /// * [update advertiser groups](AdvertiserGroupUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdvertiserGroup { /// Account ID of this advertiser group. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// ID of this advertiser group. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroup". pub kind: Option, /// 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. pub name: Option, } impl client::RequestValue for AdvertiserGroup {} impl client::Resource for AdvertiserGroup {} impl client::ResponseResult for AdvertiserGroup {} /// Advertiser Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list advertiser groups](AdvertiserGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdvertiserGroupsListResponse { /// Advertiser group collection. #[serde(rename="advertiserGroups")] pub advertiser_groups: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserGroupsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AdvertiserGroupsListResponse {} /// Landing Page List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list advertiser landing pages](AdvertiserLandingPageListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdvertiserLandingPagesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertiserLandingPagesListResponse". pub kind: Option, /// Landing page collection #[serde(rename="landingPages")] pub landing_pages: Option>, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AdvertiserLandingPagesListResponse {} /// Advertiser List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list advertisers](AdvertiserListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AdvertisersListResponse { /// Advertiser collection. pub advertisers: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#advertisersListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for AdvertisersListResponse {} /// Audience Segment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AudienceSegment { /// 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. pub allocation: Option, /// ID of this audience segment. This is a read-only, auto-generated field. pub id: Option, /// Name of this audience segment. This is a required field and must be less than 65 characters long. pub name: Option, } impl client::Part for AudienceSegment {} /// Audience Segment Group. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct AudienceSegmentGroup { /// Audience segments assigned to this group. The number of segments must be between 2 and 100. #[serde(rename="audienceSegments")] pub audience_segments: Option>, /// ID of this audience segment group. This is a read-only, auto-generated field. pub id: Option, /// Name of this audience segment group. This is a required field and must be less than 65 characters long. pub name: Option, } impl client::Part for AudienceSegmentGroup {} /// Contains information about a browser that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list browsers](BrowserListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Browser { /// ID referring to this grouping of browser and version numbers. This is the ID used for targeting. #[serde(rename="browserVersionId")] pub browser_version_id: Option, /// DART ID of this browser. This is the ID used when generating reports. #[serde(rename="dartId")] pub dart_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browser". pub kind: Option, /// 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. #[serde(rename="majorVersion")] pub major_version: Option, /// 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. #[serde(rename="minorVersion")] pub minor_version: Option, /// Name of this browser. pub name: Option, } impl client::Resource for Browser {} /// Browser List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list browsers](BrowserListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct BrowsersListResponse { /// Browser collection. pub browsers: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#browsersListResponse". pub kind: Option, } impl client::ResponseResult for BrowsersListResponse {} /// Contains properties of a Campaign Manager campaign. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get campaigns](CampaignGetCall) (response) /// * [insert campaigns](CampaignInsertCall) (request|response) /// * [list campaigns](CampaignListCall) (none) /// * [patch campaigns](CampaignPatchCall) (request|response) /// * [update campaigns](CampaignUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Campaign { /// Account ID of this campaign. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Ad blocking settings for this campaign. #[serde(rename="adBlockingConfiguration")] pub ad_blocking_configuration: Option, /// Additional creative optimization configurations for the campaign. #[serde(rename="additionalCreativeOptimizationConfigurations")] pub additional_creative_optimization_configurations: Option>, /// Advertiser group ID of the associated advertiser. #[serde(rename="advertiserGroupId")] pub advertiser_group_id: Option, /// Advertiser ID of this campaign. This is a required field. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the advertiser ID of this campaign. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Whether this campaign has been archived. pub archived: Option, /// Audience segment groups assigned to this campaign. Cannot have more than 300 segment groups. #[serde(rename="audienceSegmentGroups")] pub audience_segment_groups: Option>, /// Billing invoice code included in the Campaign Manager client billing invoices associated with the campaign. #[serde(rename="billingInvoiceCode")] pub billing_invoice_code: Option, /// Click-through URL suffix override properties for this campaign. #[serde(rename="clickThroughUrlSuffixProperties")] pub click_through_url_suffix_properties: Option, /// Arbitrary comments about this campaign. Must be less than 256 characters long. pub comment: Option, /// Information about the creation of this campaign. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// List of creative group IDs that are assigned to the campaign. #[serde(rename="creativeGroupIds")] pub creative_group_ids: Option>, /// Creative optimization configuration for the campaign. #[serde(rename="creativeOptimizationConfiguration")] pub creative_optimization_configuration: Option, /// Click-through event tag ID override properties for this campaign. #[serde(rename="defaultClickThroughEventTagProperties")] pub default_click_through_event_tag_properties: Option, /// The default landing page ID for this campaign. #[serde(rename="defaultLandingPageId")] pub default_landing_page_id: Option, /// 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. #[serde(rename="endDate")] pub end_date: Option, /// Overrides that can be used to activate or deactivate advertiser event tags. #[serde(rename="eventTagOverrides")] pub event_tag_overrides: Option>, /// External ID for this campaign. #[serde(rename="externalId")] pub external_id: Option, /// ID of this campaign. This is a read-only auto-generated field. pub id: Option, /// Dimension value for the ID of this campaign. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaign". pub kind: Option, /// Information about the most recent modification of this campaign. This is a read-only field. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Lookback window settings for the campaign. #[serde(rename="lookbackConfiguration")] pub lookback_configuration: Option, /// 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. pub name: Option, /// Whether Nielsen reports are enabled for this campaign. #[serde(rename="nielsenOcrEnabled")] pub nielsen_ocr_enabled: Option, /// 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. #[serde(rename="startDate")] pub start_date: Option, /// Subaccount ID of this campaign. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Campaign trafficker contact emails. #[serde(rename="traffickerEmails")] pub trafficker_emails: Option>, } impl client::RequestValue for Campaign {} impl client::Resource for Campaign {} impl client::ResponseResult for Campaign {} /// Identifies a creative which has been associated with a given campaign. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [insert campaign creative associations](CampaignCreativeAssociationInsertCall) (request|response) /// * [list campaign creative associations](CampaignCreativeAssociationListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CampaignCreativeAssociation { /// ID of the creative associated with the campaign. This is a required field. #[serde(rename="creativeId")] pub creative_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociation". pub kind: Option, } impl client::RequestValue for CampaignCreativeAssociation {} impl client::Resource for CampaignCreativeAssociation {} impl client::ResponseResult for CampaignCreativeAssociation {} /// Campaign Creative Association List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list campaign creative associations](CampaignCreativeAssociationListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CampaignCreativeAssociationsListResponse { /// Campaign creative association collection #[serde(rename="campaignCreativeAssociations")] pub campaign_creative_associations: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignCreativeAssociationsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CampaignCreativeAssociationsListResponse {} /// Campaign List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list campaigns](CampaignListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CampaignsListResponse { /// Campaign collection. pub campaigns: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#campaignsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CampaignsListResponse {} /// Describes a change that a user has made to a resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get change logs](ChangeLogGetCall) (response) /// * [list change logs](ChangeLogListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChangeLog { /// Account ID of the modified object. #[serde(rename="accountId")] pub account_id: Option, /// Action which caused the change. pub action: Option, /// Time when the object was modified. #[serde(rename="changeTime")] pub change_time: Option, /// Field name of the object which changed. #[serde(rename="fieldName")] pub field_name: Option, /// ID of this change log. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLog". pub kind: Option, /// New value of the object field. #[serde(rename="newValue")] pub new_value: Option, /// ID of the object of this change log. The object could be a campaign, placement, ad, or other type. #[serde(rename="objectId")] pub object_id: Option, /// Object type of the change log. #[serde(rename="objectType")] pub object_type: Option, /// Old value of the object field. #[serde(rename="oldValue")] pub old_value: Option, /// Subaccount ID of the modified object. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// 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. #[serde(rename="transactionId")] pub transaction_id: Option, /// ID of the user who modified the object. #[serde(rename="userProfileId")] pub user_profile_id: Option, /// User profile name of the user who modified the object. #[serde(rename="userProfileName")] pub user_profile_name: Option, } impl client::Resource for ChangeLog {} impl client::ResponseResult for ChangeLog {} /// Change Log List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list change logs](ChangeLogListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ChangeLogsListResponse { /// Change log collection. #[serde(rename="changeLogs")] pub change_logs: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#changeLogsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ChangeLogsListResponse {} /// City List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list cities](CityListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CitiesListResponse { /// City collection. pub cities: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#citiesListResponse". pub kind: Option, } impl client::ResponseResult for CitiesListResponse {} /// Contains information about a city that can be targeted by ads. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct City { /// Country code of the country to which this city belongs. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of the country to which this city belongs. #[serde(rename="countryDartId")] pub country_dart_id: Option, /// DART ID of this city. This is the ID used for targeting and generating reports. #[serde(rename="dartId")] pub dart_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#city". pub kind: Option, /// Metro region code of the metro region (DMA) to which this city belongs. #[serde(rename="metroCode")] pub metro_code: Option, /// ID of the metro region (DMA) to which this city belongs. #[serde(rename="metroDmaId")] pub metro_dma_id: Option, /// Name of this city. pub name: Option, /// Region code of the region to which this city belongs. #[serde(rename="regionCode")] pub region_code: Option, /// DART ID of the region to which this city belongs. #[serde(rename="regionDartId")] pub region_dart_id: Option, } impl client::Part for City {} /// Creative Click Tag. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickTag { /// Parameter value for the specified click tag. This field contains a click-through url. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// 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. #[serde(rename="eventName")] pub event_name: Option, /// 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. pub name: Option, } impl client::Part for ClickTag {} /// Click-through URL /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickThroughUrl { /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows: /// - If defaultLandingPage is enabled then the campaign's default landing page URL is assigned to this field. /// - If defaultLandingPage is not enabled and a landingPageId is specified then that landing page's URL is assigned to this field. /// - If neither of the above cases apply, then the customClickThroughUrl is assigned to this field. #[serde(rename="computedClickThroughUrl")] pub computed_click_through_url: Option, /// Custom click-through URL. Applicable if the defaultLandingPage field is set to false and the landingPageId field is left unset. #[serde(rename="customClickThroughUrl")] pub custom_click_through_url: Option, /// Whether the campaign default landing page is used. #[serde(rename="defaultLandingPage")] pub default_landing_page: Option, /// ID of the landing page for the click-through URL. Applicable if the defaultLandingPage field is set to false. #[serde(rename="landingPageId")] pub landing_page_id: Option, } impl client::Part for ClickThroughUrl {} /// Click Through URL Suffix settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ClickThroughUrlSuffixProperties { /// Click-through URL suffix to apply to all ads in this entity's scope. Must be less than 128 characters long. #[serde(rename="clickThroughUrlSuffix")] pub click_through_url_suffix: Option, /// Whether this entity should override the inherited click-through URL suffix with its own defined value. #[serde(rename="overrideInheritedSuffix")] pub override_inherited_suffix: Option, } impl client::Part for ClickThroughUrlSuffixProperties {} /// Companion Click-through override. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CompanionClickThroughOverride { /// Click-through URL of this companion click-through override. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// ID of the creative for this companion click-through override. #[serde(rename="creativeId")] pub creative_id: Option, } impl client::Part for CompanionClickThroughOverride {} /// Companion Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CompanionSetting { /// Whether companions are disabled for this placement. #[serde(rename="companionsDisabled")] pub companions_disabled: Option, /// Whitelist of companion sizes to be served to this placement. Set this list to null or empty to serve all companion sizes. #[serde(rename="enabledSizes")] pub enabled_sizes: Option>, /// Whether to serve only static images as companions. #[serde(rename="imageOnly")] pub image_only: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#companionSetting". pub kind: Option, } impl client::Part for CompanionSetting {} /// Represents a response to the queryCompatibleFields method. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [compatible fields query reports](ReportCompatibleFieldQueryCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CompatibleFields { /// Contains items that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". #[serde(rename="crossDimensionReachReportCompatibleFields")] pub cross_dimension_reach_report_compatible_fields: Option, /// Contains items that are compatible to be selected for a report of type "FLOODLIGHT". #[serde(rename="floodlightReportCompatibleFields")] pub floodlight_report_compatible_fields: Option, /// The kind of resource this is, in this case dfareporting#compatibleFields. pub kind: Option, /// Contains items that are compatible to be selected for a report of type "PATH_TO_CONVERSION". #[serde(rename="pathToConversionReportCompatibleFields")] pub path_to_conversion_report_compatible_fields: Option, /// Contains items that are compatible to be selected for a report of type "REACH". #[serde(rename="reachReportCompatibleFields")] pub reach_report_compatible_fields: Option, /// Contains items that are compatible to be selected for a report of type "STANDARD". #[serde(rename="reportCompatibleFields")] pub report_compatible_fields: Option, } impl client::ResponseResult for CompatibleFields {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get connection types](ConnectionTypeGetCall) (response) /// * [list connection types](ConnectionTypeListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConnectionType { /// ID of this connection type. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionType". pub kind: Option, /// Name of this connection type. pub name: Option, } impl client::Resource for ConnectionType {} impl client::ResponseResult for ConnectionType {} /// Connection Type List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list connection types](ConnectionTypeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConnectionTypesListResponse { /// Collection of connection types such as broadband and mobile. #[serde(rename="connectionTypes")] pub connection_types: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#connectionTypesListResponse". pub kind: Option, } impl client::ResponseResult for ConnectionTypesListResponse {} /// Content Category List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list content categories](ContentCategoryListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContentCategoriesListResponse { /// Content category collection. #[serde(rename="contentCategories")] pub content_categories: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategoriesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ContentCategoriesListResponse {} /// Organizes placements according to the contents of their associated webpages. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get content categories](ContentCategoryGetCall) (response) /// * [insert content categories](ContentCategoryInsertCall) (request|response) /// * [patch content categories](ContentCategoryPatchCall) (request|response) /// * [update content categories](ContentCategoryUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ContentCategory { /// Account ID of this content category. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// ID of this content category. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#contentCategory". pub kind: Option, /// 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. pub name: Option, } impl client::RequestValue for ContentCategory {} impl client::ResponseResult for ContentCategory {} /// A Conversion represents when a user successfully performs a desired action after seeing an ad. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [batchinsert conversions](ConversionBatchinsertCall) (none) /// * [batchupdate conversions](ConversionBatchupdateCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Conversion { /// Whether this particular request may come from a user under the age of 13, under COPPA compliance. #[serde(rename="childDirectedTreatment")] pub child_directed_treatment: Option, /// Custom floodlight variables. #[serde(rename="customVariables")] pub custom_variables: Option>, /// 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. #[serde(rename="encryptedUserId")] pub encrypted_user_id: Option, /// 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. #[serde(rename="encryptedUserIdCandidates")] pub encrypted_user_id_candidates: Option>, /// Floodlight Activity ID of this conversion. This is a required field. #[serde(rename="floodlightActivityId")] pub floodlight_activity_id: Option, /// Floodlight Configuration ID of this conversion. This is a required field. #[serde(rename="floodlightConfigurationId")] pub floodlight_configuration_id: Option, /// 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. pub gclid: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversion". pub kind: Option, /// Whether Limit Ad Tracking is enabled. When set to true, the conversion will be used for reporting but not targeting. This will prevent remarketing. #[serde(rename="limitAdTracking")] pub limit_ad_tracking: Option, /// 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. #[serde(rename="mobileDeviceId")] pub mobile_device_id: Option, /// Whether the conversion was for a non personalized ad. #[serde(rename="nonPersonalizedAd")] pub non_personalized_ad: Option, /// 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. pub ordinal: Option, /// The quantity of the conversion. pub quantity: Option, /// The timestamp of conversion, in Unix epoch micros. This is a required field. #[serde(rename="timestampMicros")] pub timestamp_micros: Option, /// 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). #[serde(rename="treatmentForUnderage")] pub treatment_for_underage: Option, /// The value of the conversion. pub value: Option, } impl client::Resource for Conversion {} /// The error code and description for a conversion that failed to insert or update. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionError { /// The error code. pub code: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionError". pub kind: Option, /// A description of the error. pub message: Option, } impl client::Part for ConversionError {} /// The original conversion that was inserted or updated and whether there were any errors. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionStatus { /// The original conversion that was inserted or updated. pub conversion: Option, /// A list of errors related to this conversion. pub errors: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionStatus". pub kind: Option, } impl client::Part for ConversionStatus {} /// Insert Conversions Request. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [batchinsert conversions](ConversionBatchinsertCall) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionsBatchInsertRequest { /// The set of conversions to insert. pub conversions: Option>, /// Describes how encryptedUserId or encryptedUserIdCandidates[] is encrypted. This is a required field if encryptedUserId or encryptedUserIdCandidates[] is used. #[serde(rename="encryptionInfo")] pub encryption_info: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertRequest". pub kind: Option, } impl client::RequestValue for ConversionsBatchInsertRequest {} /// Insert Conversions Response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [batchinsert conversions](ConversionBatchinsertCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionsBatchInsertResponse { /// Indicates that some or all conversions failed to insert. #[serde(rename="hasFailures")] pub has_failures: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchInsertResponse". pub kind: Option, /// The insert status of each conversion. Statuses are returned in the same order that conversions are inserted. pub status: Option>, } impl client::ResponseResult for ConversionsBatchInsertResponse {} /// Update Conversions Request. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [batchupdate conversions](ConversionBatchupdateCall) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionsBatchUpdateRequest { /// The set of conversions to update. pub conversions: Option>, /// Describes how encryptedUserId is encrypted. This is a required field if encryptedUserId is used. #[serde(rename="encryptionInfo")] pub encryption_info: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchUpdateRequest". pub kind: Option, } impl client::RequestValue for ConversionsBatchUpdateRequest {} /// Update Conversions Response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [batchupdate conversions](ConversionBatchupdateCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ConversionsBatchUpdateResponse { /// Indicates that some or all conversions failed to update. #[serde(rename="hasFailures")] pub has_failures: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#conversionsBatchUpdateResponse". pub kind: Option, /// The update status of each conversion. Statuses are returned in the same order that conversions are updated. pub status: Option>, } impl client::ResponseResult for ConversionsBatchUpdateResponse {} /// Country List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list countries](CountryListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CountriesListResponse { /// Country collection. pub countries: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#countriesListResponse". pub kind: Option, } impl client::ResponseResult for CountriesListResponse {} /// Contains information about a country that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get countries](CountryGetCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Country { /// Country code. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of this country. This is the ID used for targeting and generating reports. #[serde(rename="dartId")] pub dart_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#country". pub kind: Option, /// Name of this country. pub name: Option, /// Whether ad serving supports secure servers in this country. #[serde(rename="sslEnabled")] pub ssl_enabled: Option, } impl client::ResponseResult for Country {} /// Contains properties of a Creative. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get creatives](CreativeGetCall) (response) /// * [insert creatives](CreativeInsertCall) (request|response) /// * [list creatives](CreativeListCall) (none) /// * [patch creatives](CreativePatchCall) (request|response) /// * [update creatives](CreativeUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Creative { /// 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. #[serde(rename="accountId")] pub account_id: Option, /// Whether the creative is active. Applicable to all creative types. pub active: Option, /// Ad parameters user for VPAID creative. This is a read-only field. Applicable to the following creative types: all VPAID. #[serde(rename="adParameters")] pub ad_parameters: Option, /// 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. #[serde(rename="adTagKeys")] pub ad_tag_keys: Option>, /// 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. #[serde(rename="additionalSizes")] pub additional_sizes: Option>, /// Advertiser ID of this creative. This is a required field. Applicable to all creative types. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// 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. #[serde(rename="allowScriptAccess")] pub allow_script_access: Option, /// Whether the creative is archived. Applicable to all creative types. pub archived: Option, /// 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. #[serde(rename="artworkType")] pub artwork_type: Option, /// Source application where creative was authored. Presently, only DBM authored creatives will have this field set. Applicable to all creative types. #[serde(rename="authoringSource")] pub authoring_source: Option, /// Authoring tool for HTML5 banner creatives. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. #[serde(rename="authoringTool")] pub authoring_tool: Option, /// Whether images are automatically advanced for image gallery creatives. Applicable to the following creative types: DISPLAY_IMAGE_GALLERY. #[serde(rename="autoAdvanceImages")] pub auto_advance_images: Option, /// 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. #[serde(rename="backgroundColor")] pub background_color: Option, /// Click-through URL for backup image. Applicable to ENHANCED_BANNER when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageClickThroughUrl")] pub backup_image_click_through_url: Option, /// 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. #[serde(rename="backupImageFeatures")] pub backup_image_features: Option>, /// Reporting label used for HTML5 banner backup image. Applicable to the following creative types: DISPLAY when the primary asset type is not HTML_IMAGE. #[serde(rename="backupImageReportingLabel")] pub backup_image_reporting_label: Option, /// 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. #[serde(rename="backupImageTargetWindow")] pub backup_image_target_window: Option, /// 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. #[serde(rename="clickTags")] pub click_tags: Option>, /// Industry standard ID assigned to creative for reach and frequency. Applicable to INSTREAM_VIDEO_REDIRECT creatives. #[serde(rename="commercialId")] pub commercial_id: Option, /// 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. #[serde(rename="companionCreatives")] pub companion_creatives: Option>, /// 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. /// /// Acceptable values are: /// - "APP" /// - "APP_INTERSTITIAL" /// - "IN_STREAM_VIDEO" /// - "IN_STREAM_AUDIO" /// - "DISPLAY" /// - "DISPLAY_INTERSTITIAL" pub compatibility: Option>, /// 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. #[serde(rename="convertFlashToHtml5")] pub convert_flash_to_html5: Option, /// 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. #[serde(rename="counterCustomEvents")] pub counter_custom_events: Option>, /// Required if dynamicAssetSelection is true. #[serde(rename="creativeAssetSelection")] pub creative_asset_selection: Option, /// Assets associated with a creative. Applicable to all but the following creative types: INTERNAL_REDIRECT, INTERSTITIAL_INTERNAL_REDIRECT, and REDIRECT #[serde(rename="creativeAssets")] pub creative_assets: Option>, /// Creative field assignments for this creative. Applicable to all creative types. #[serde(rename="creativeFieldAssignments")] pub creative_field_assignments: Option>, /// 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. #[serde(rename="customKeyValues")] pub custom_key_values: Option>, /// 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. #[serde(rename="dynamicAssetSelection")] pub dynamic_asset_selection: Option, /// 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. #[serde(rename="exitCustomEvents")] pub exit_custom_events: Option>, /// 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. #[serde(rename="fsCommand")] pub fs_command: Option, /// 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. #[serde(rename="htmlCode")] pub html_code: Option, /// 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. #[serde(rename="htmlCodeLocked")] pub html_code_locked: Option, /// ID of this creative. This is a read-only, auto-generated field. Applicable to all creative types. pub id: Option, /// Dimension value for the ID of this creative. This is a read-only field. Applicable to all creative types. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creative". pub kind: Option, /// Creative last modification information. This is a read-only field. Applicable to all creative types. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// 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. #[serde(rename="latestTraffickedCreativeId")] pub latest_trafficked_creative_id: Option, /// Description of the audio or video ad. Applicable to the following creative types: all INSTREAM_VIDEO, INSTREAM_AUDIO, and all VPAID. #[serde(rename="mediaDescription")] pub media_description: Option, /// 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. #[serde(rename="mediaDuration")] pub media_duration: Option, /// Name of the creative. This is a required field and must be less than 256 characters long. Applicable to all creative types. pub name: Option, /// Override CSS value for rich media creatives. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="overrideCss")] pub override_css: Option, /// The asset ID of the polite load image asset. Applicable to the creative type: DISPLAY. #[serde(rename="politeLoadAssetId")] pub polite_load_asset_id: Option, /// Amount of time to play the video before counting a view. Applicable to the following creative types: all INSTREAM_VIDEO. #[serde(rename="progressOffset")] pub progress_offset: Option, /// 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 #[serde(rename="redirectUrl")] pub redirect_url: Option, /// ID of current rendering version. This is a read-only field. Applicable to all creative types. #[serde(rename="renderingId")] pub rendering_id: Option, /// Dimension value for the rendering ID of this creative. This is a read-only field. Applicable to all creative types. #[serde(rename="renderingIdDimensionValue")] pub rendering_id_dimension_value: Option, /// 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. #[serde(rename="requiredFlashPluginVersion")] pub required_flash_plugin_version: Option, /// 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. #[serde(rename="requiredFlashVersion")] pub required_flash_version: Option, /// 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. pub size: Option, /// Amount of time to play the video before the skip button appears. Applicable to the following creative types: all INSTREAM_VIDEO. #[serde(rename="skipOffset")] pub skip_offset: Option, /// Whether the user can choose to skip the creative. Applicable to the following creative types: all INSTREAM_VIDEO and all VPAID. pub skippable: Option, /// Whether the creative is SSL-compliant. This is a read-only field. Applicable to all creative types. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Whether creative should be treated as SSL compliant even if the system scan shows it's not. Applicable to all creative types. #[serde(rename="sslOverride")] pub ssl_override: Option, /// 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. #[serde(rename="studioAdvertiserId")] pub studio_advertiser_id: Option, /// 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. #[serde(rename="studioCreativeId")] pub studio_creative_id: Option, /// 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. #[serde(rename="studioTraffickedCreativeId")] pub studio_trafficked_creative_id: Option, /// 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. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Third-party URL used to record backup image impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyBackupImageImpressionsUrl")] pub third_party_backup_image_impressions_url: Option, /// Third-party URL used to record rich media impressions. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="thirdPartyRichMediaImpressionsUrl")] pub third_party_rich_media_impressions_url: Option, /// Third-party URLs for tracking in-stream creative events. Applicable to the following creative types: all INSTREAM_VIDEO, all INSTREAM_AUDIO, and all VPAID. #[serde(rename="thirdPartyUrls")] pub third_party_urls: Option>, /// 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. #[serde(rename="timerCustomEvents")] pub timer_custom_events: Option>, /// Combined size of all creative assets. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA, and all VPAID. #[serde(rename="totalFileSize")] pub total_file_size: Option, /// Type of this creative. This is a required field. Applicable to all creative types. /// /// Note: FLASH_INPAGE, HTML5_BANNER, and IMAGE are only used for existing creatives. New creatives should use DISPLAY as a replacement for these types. #[serde(rename="type")] pub type_: Option, /// A Universal Ad ID as per the VAST 4.0 spec. Applicable to the following creative types: INSTREAM_AUDIO and INSTREAM_VIDEO and VPAID. #[serde(rename="universalAdId")] pub universal_ad_id: Option, /// 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. pub version: Option, } impl client::RequestValue for Creative {} impl client::Resource for Creative {} impl client::ResponseResult for Creative {} /// Creative Asset. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [insert creative assets](CreativeAssetInsertCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAsset { /// 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. #[serde(rename="actionScript3")] pub action_script3: Option, /// 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. pub active: Option, /// 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. #[serde(rename="additionalSizes")] pub additional_sizes: Option>, /// Possible alignments for an asset. This is a read-only field. Applicable to the following creative types: RICH_MEDIA_DISPLAY_MULTI_FLOATING_INTERSTITIAL. pub alignment: Option, /// Artwork type of rich media creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="artworkType")] pub artwork_type: Option, /// 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. #[serde(rename="assetIdentifier")] pub asset_identifier: Option, /// Exit event configured for the backup image. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="backupImageExit")] pub backup_image_exit: Option, /// 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. #[serde(rename="bitRate")] pub bit_rate: Option, /// Rich media child asset type. This is a read-only field. Applicable to the following creative types: all VPAID. #[serde(rename="childAssetType")] pub child_asset_type: Option, /// 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. #[serde(rename="collapsedSize")] pub collapsed_size: Option, /// 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. #[serde(rename="companionCreativeIds")] pub companion_creative_ids: Option>, /// 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. #[serde(rename="customStartTimeValue")] pub custom_start_time_value: Option, /// 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. #[serde(rename="detectedFeatures")] pub detected_features: Option>, /// Type of rich media asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="displayType")] pub display_type: Option, /// 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. pub duration: Option, /// Duration type for which an asset will be displayed. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="durationType")] pub duration_type: Option, /// Detected expanded dimension for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. #[serde(rename="expandedDimension")] pub expanded_dimension: Option, /// 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. #[serde(rename="fileSize")] pub file_size: Option, /// 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. #[serde(rename="flashVersion")] pub flash_version: Option, /// Whether to hide Flash objects flag for an asset. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="hideFlashObjects")] pub hide_flash_objects: Option, /// Whether to hide selection boxes flag for an asset. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="hideSelectionBoxes")] pub hide_selection_boxes: Option, /// Whether the asset is horizontally locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="horizontallyLocked")] pub horizontally_locked: Option, /// 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. pub id: Option, /// Dimension value for the ID of the asset. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// 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. #[serde(rename="mediaDuration")] pub media_duration: Option, /// 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. #[serde(rename="mimeType")] pub mime_type: Option, /// 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. pub offset: Option, /// Orientation of video asset. This is a read-only, auto-generated field. pub orientation: Option, /// Whether the backup asset is original or changed by the user in Campaign Manager. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="originalBackup")] pub original_backup: Option, /// Offset position for an asset. Applicable to the following creative types: all RICH_MEDIA. pub position: Option, /// Offset left unit for an asset. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="positionLeftUnit")] pub position_left_unit: Option, /// 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. #[serde(rename="positionTopUnit")] pub position_top_unit: Option, /// Progressive URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. #[serde(rename="progressiveServingUrl")] pub progressive_serving_url: Option, /// 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. pub pushdown: Option, /// 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. #[serde(rename="pushdownDuration")] pub pushdown_duration: Option, /// 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. /// 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. /// 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. /// ADDITIONAL_IMAGE and ADDITIONAL_FLASH apply to FLASH_INPAGE creatives. /// OTHER refers to assets from sources other than Campaign Manager, such as Studio uploaded assets, applicable to all RICH_MEDIA and all VPAID creatives. /// PARENT_VIDEO refers to videos uploaded by the user in Campaign Manager and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. /// TRANSCODED_VIDEO refers to videos transcoded by Campaign Manager from PARENT_VIDEO assets and is applicable to INSTREAM_VIDEO and VPAID_LINEAR_VIDEO creatives. /// 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. /// 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. /// PARENT_AUDIO refers to audios uploaded by the user in Campaign Manager and is applicable to INSTREAM_AUDIO creatives. /// TRANSCODED_AUDIO refers to audios transcoded by Campaign Manager from PARENT_AUDIO assets and is applicable to INSTREAM_AUDIO creatives. pub role: Option, /// 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. pub size: Option, /// 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. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Initial wait time type before making the asset visible. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="startTimeType")] pub start_time_type: Option, /// Streaming URL for video asset. This is a read-only field. Applicable to the following creative types: INSTREAM_VIDEO and all VPAID. #[serde(rename="streamingServingUrl")] pub streaming_serving_url: Option, /// Whether the asset is transparent. Applicable to the following creative types: all RICH_MEDIA. Additionally, only applicable to HTML5 assets. pub transparency: Option, /// Whether the asset is vertically locked. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA. #[serde(rename="verticallyLocked")] pub vertically_locked: Option, /// 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. #[serde(rename="windowMode")] pub window_mode: Option, /// 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. #[serde(rename="zIndex")] pub z_index: Option, /// File name of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. #[serde(rename="zipFilename")] pub zip_filename: Option, /// Size of zip file. This is a read-only field. Applicable to the following creative types: HTML5_BANNER. #[serde(rename="zipFilesize")] pub zip_filesize: Option, } impl client::Resource for CreativeAsset {} /// Creative Asset ID. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAssetId { /// 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. pub name: Option, /// 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. #[serde(rename="type")] pub type_: Option, } impl client::Part for CreativeAssetId {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [insert creative assets](CreativeAssetInsertCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAssetMetadata { /// ID of the creative asset. This is a required field. #[serde(rename="assetIdentifier")] pub asset_identifier: Option, /// List of detected click tags for assets. This is a read-only auto-generated field. #[serde(rename="clickTags")] pub click_tags: Option>, /// 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. #[serde(rename="detectedFeatures")] pub detected_features: Option>, /// Numeric ID of the asset. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the numeric ID of the asset. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeAssetMetadata". pub kind: Option, /// Rules validated during code generation that generated a warning. This is a read-only, auto-generated field. /// /// Possible values are: /// - "ADMOB_REFERENCED" /// - "ASSET_FORMAT_UNSUPPORTED_DCM" /// - "ASSET_INVALID" /// - "CLICK_TAG_HARD_CODED" /// - "CLICK_TAG_INVALID" /// - "CLICK_TAG_IN_GWD" /// - "CLICK_TAG_MISSING" /// - "CLICK_TAG_MORE_THAN_ONE" /// - "CLICK_TAG_NON_TOP_LEVEL" /// - "COMPONENT_UNSUPPORTED_DCM" /// - "ENABLER_UNSUPPORTED_METHOD_DCM" /// - "EXTERNAL_FILE_REFERENCED" /// - "FILE_DETAIL_EMPTY" /// - "FILE_TYPE_INVALID" /// - "GWD_PROPERTIES_INVALID" /// - "HTML5_FEATURE_UNSUPPORTED" /// - "LINKED_FILE_NOT_FOUND" /// - "MAX_FLASH_VERSION_11" /// - "MRAID_REFERENCED" /// - "NOT_SSL_COMPLIANT" /// - "ORPHANED_ASSET" /// - "PRIMARY_HTML_MISSING" /// - "SVG_INVALID" /// - "ZIP_INVALID" #[serde(rename="warnedValidationRules")] pub warned_validation_rules: Option>, } impl client::RequestValue for CreativeAssetMetadata {} impl client::ResponseResult for CreativeAssetMetadata {} /// Encapsulates the list of rules for asset selection and a default asset in case none of the rules match. Applicable to INSTREAM_VIDEO creatives. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAssetSelection { /// 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. #[serde(rename="defaultAssetId")] pub default_asset_id: Option, /// 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. pub rules: Option>, } impl client::Part for CreativeAssetSelection {} /// Creative Assignment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeAssignment { /// Whether this creative assignment is active. When true, the creative will be included in the ad's rotation. pub active: Option, /// 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. #[serde(rename="applyEventTags")] pub apply_event_tags: Option, /// Click-through URL of the creative assignment. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// Companion creative overrides for this creative assignment. Applicable to video ads. #[serde(rename="companionCreativeOverrides")] pub companion_creative_overrides: Option>, /// Creative group assignments for this creative assignment. Only one assignment per creative group number is allowed for a maximum of two assignments. #[serde(rename="creativeGroupAssignments")] pub creative_group_assignments: Option>, /// ID of the creative to be assigned. This is a required field. #[serde(rename="creativeId")] pub creative_id: Option, /// Dimension value for the ID of the creative. This is a read-only, auto-generated field. #[serde(rename="creativeIdDimensionValue")] pub creative_id_dimension_value: Option, /// Date and time that the assigned creative should stop serving. Must be later than the start time. #[serde(rename="endTime")] pub end_time: Option, /// Rich media exit overrides for this creative assignment. /// Applicable when the creative type is any of the following: /// - DISPLAY /// - RICH_MEDIA_INPAGE /// - RICH_MEDIA_INPAGE_FLOATING /// - RICH_MEDIA_IM_EXPAND /// - RICH_MEDIA_EXPANDING /// - RICH_MEDIA_INTERSTITIAL_FLOAT /// - RICH_MEDIA_MOBILE_IN_APP /// - RICH_MEDIA_MULTI_FLOATING /// - RICH_MEDIA_PEEL_DOWN /// - VPAID_LINEAR /// - VPAID_NON_LINEAR #[serde(rename="richMediaExitOverrides")] pub rich_media_exit_overrides: Option>, /// Sequence number of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_SEQUENTIAL. Acceptable values are 1 to 65535, inclusive. pub sequence: Option, /// 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. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Date and time that the assigned creative should start serving. #[serde(rename="startTime")] pub start_time: Option, /// Weight of the creative assignment, applicable when the rotation type is CREATIVE_ROTATION_TYPE_RANDOM. Value must be greater than or equal to 1. pub weight: Option, } impl client::Part for CreativeAssignment {} /// Click-through URL /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeClickThroughUrl { /// Read-only convenience field representing the actual URL that will be used for this click-through. The URL is computed as follows: /// - If landingPageId is specified then that landing page's URL is assigned to this field. /// - Otherwise, the customClickThroughUrl is assigned to this field. #[serde(rename="computedClickThroughUrl")] pub computed_click_through_url: Option, /// Custom click-through URL. Applicable if the landingPageId field is left unset. #[serde(rename="customClickThroughUrl")] pub custom_click_through_url: Option, /// ID of the landing page for the click-through URL. #[serde(rename="landingPageId")] pub landing_page_id: Option, } impl client::Part for CreativeClickThroughUrl {} /// Creative Custom Event. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeCustomEvent { /// Unique ID of this event used by Reporting and Data Transfer. This is a read-only field. #[serde(rename="advertiserCustomEventId")] pub advertiser_custom_event_id: Option, /// User-entered name for the event. #[serde(rename="advertiserCustomEventName")] pub advertiser_custom_event_name: Option, /// Type of the event. This is a read-only field. #[serde(rename="advertiserCustomEventType")] pub advertiser_custom_event_type: Option, /// 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. #[serde(rename="artworkLabel")] pub artwork_label: Option, /// Artwork type used by the creative.This is a read-only field. #[serde(rename="artworkType")] pub artwork_type: Option, /// Exit click-through URL for the event. This field is used only for exit events. #[serde(rename="exitClickThroughUrl")] pub exit_click_through_url: Option, /// ID of this event. This is a required field and should not be modified after insertion. pub id: Option, /// Properties for rich media popup windows. This field is used only for exit events. #[serde(rename="popupWindowProperties")] pub popup_window_properties: Option, /// Target type used by the event. #[serde(rename="targetType")] pub target_type: Option, /// Video reporting ID, used to differentiate multiple videos in a single creative. This is a read-only field. #[serde(rename="videoReportingId")] pub video_reporting_id: Option, } impl client::Part for CreativeCustomEvent {} /// Contains properties of a creative field. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete creative fields](CreativeFieldDeleteCall) (none) /// * [get creative fields](CreativeFieldGetCall) (response) /// * [insert creative fields](CreativeFieldInsertCall) (request|response) /// * [list creative fields](CreativeFieldListCall) (none) /// * [patch creative fields](CreativeFieldPatchCall) (request|response) /// * [update creative fields](CreativeFieldUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeField { /// Account ID of this creative field. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this creative field. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// ID of this creative field. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeField". pub kind: Option, /// 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. pub name: Option, /// Subaccount ID of this creative field. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for CreativeField {} impl client::Resource for CreativeField {} impl client::ResponseResult for CreativeField {} /// Creative Field Assignment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeFieldAssignment { /// ID of the creative field. #[serde(rename="creativeFieldId")] pub creative_field_id: Option, /// ID of the creative field value. #[serde(rename="creativeFieldValueId")] pub creative_field_value_id: Option, } impl client::Part for CreativeFieldAssignment {} /// Contains properties of a creative field value. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete creative field values](CreativeFieldValueDeleteCall) (none) /// * [get creative field values](CreativeFieldValueGetCall) (response) /// * [insert creative field values](CreativeFieldValueInsertCall) (request|response) /// * [list creative field values](CreativeFieldValueListCall) (none) /// * [patch creative field values](CreativeFieldValuePatchCall) (request|response) /// * [update creative field values](CreativeFieldValueUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeFieldValue { /// ID of this creative field value. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValue". pub kind: Option, /// Value of this creative field value. It needs to be less than 256 characters in length and unique per creative field. pub value: Option, } impl client::RequestValue for CreativeFieldValue {} impl client::Resource for CreativeFieldValue {} impl client::ResponseResult for CreativeFieldValue {} /// Creative Field Value List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list creative field values](CreativeFieldValueListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeFieldValuesListResponse { /// Creative field value collection. #[serde(rename="creativeFieldValues")] pub creative_field_values: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldValuesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CreativeFieldValuesListResponse {} /// Creative Field List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list creative fields](CreativeFieldListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeFieldsListResponse { /// Creative field collection. #[serde(rename="creativeFields")] pub creative_fields: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeFieldsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CreativeFieldsListResponse {} /// Contains properties of a creative group. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get creative groups](CreativeGroupGetCall) (response) /// * [insert creative groups](CreativeGroupInsertCall) (request|response) /// * [list creative groups](CreativeGroupListCall) (none) /// * [patch creative groups](CreativeGroupPatchCall) (request|response) /// * [update creative groups](CreativeGroupUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeGroup { /// Account ID of this creative group. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this creative group. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// 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. #[serde(rename="groupNumber")] pub group_number: Option, /// ID of this creative group. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroup". pub kind: Option, /// 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. pub name: Option, /// Subaccount ID of this creative group. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for CreativeGroup {} impl client::Resource for CreativeGroup {} impl client::ResponseResult for CreativeGroup {} /// Creative Group Assignment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeGroupAssignment { /// ID of the creative group to be assigned. #[serde(rename="creativeGroupId")] pub creative_group_id: Option, /// Creative group number of the creative group assignment. #[serde(rename="creativeGroupNumber")] pub creative_group_number: Option, } impl client::Part for CreativeGroupAssignment {} /// Creative Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list creative groups](CreativeGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeGroupsListResponse { /// Creative group collection. #[serde(rename="creativeGroups")] pub creative_groups: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativeGroupsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CreativeGroupsListResponse {} /// Creative optimization settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeOptimizationConfiguration { /// 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. pub id: Option, /// Name of this creative optimization config. This is a required field and must be less than 129 characters long. pub name: Option, /// List of optimization activities associated with this configuration. #[serde(rename="optimizationActivitys")] pub optimization_activitys: Option>, /// Optimization model for this configuration. #[serde(rename="optimizationModel")] pub optimization_model: Option, } impl client::Part for CreativeOptimizationConfiguration {} /// Creative Rotation. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeRotation { /// Creative assignments in this creative rotation. #[serde(rename="creativeAssignments")] pub creative_assignments: Option>, /// 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. #[serde(rename="creativeOptimizationConfigurationId")] pub creative_optimization_configuration_id: Option, /// Type of creative rotation. Can be used to specify whether to use sequential or random rotation. #[serde(rename="type")] pub type_: Option, /// Strategy for calculating weights. Used with CREATIVE_ROTATION_TYPE_RANDOM. #[serde(rename="weightCalculationStrategy")] pub weight_calculation_strategy: Option, } impl client::Part for CreativeRotation {} /// Creative Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativeSettings { /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. #[serde(rename="iFrameFooter")] pub i_frame_footer: Option, /// Header text for iFrames for this site. Must be less than or equal to 2000 characters long. #[serde(rename="iFrameHeader")] pub i_frame_header: Option, } impl client::Part for CreativeSettings {} /// Creative List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list creatives](CreativeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CreativesListResponse { /// Creative collection. pub creatives: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#creativesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for CreativesListResponse {} /// Represents fields that are compatible to be selected for a report of type "CROSS_DIMENSION_REACH". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CrossDimensionReachReportCompatibleFields { /// Dimensions which are compatible to be selected in the "breakdown" section of the report. pub breakdown: Option>, /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// The kind of resource this is, in this case dfareporting#crossDimensionReachReportCompatibleFields. pub kind: Option, /// Metrics which are compatible to be selected in the "metricNames" section of the report. pub metrics: Option>, /// Metrics which are compatible to be selected in the "overlapMetricNames" section of the report. #[serde(rename="overlapMetrics")] pub overlap_metrics: Option>, } impl client::Part for CrossDimensionReachReportCompatibleFields {} /// A custom floodlight variable. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomFloodlightVariable { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#customFloodlightVariable". pub kind: Option, /// The type of custom floodlight variable to supply a value for. These map to the "u[1-20]=" in the tags. #[serde(rename="type")] pub type_: Option, /// The value of the custom floodlight variable. The length of string must not exceed 50 characters. pub value: Option, } impl client::Part for CustomFloodlightVariable {} /// Represents a Custom Rich Media Events group. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct CustomRichMediaEvents { /// List of custom rich media event IDs. Dimension values must be all of type dfa:richMediaEventTypeIdAndName. #[serde(rename="filteredEventIds")] pub filtered_event_ids: Option>, /// The kind of resource this is, in this case dfareporting#customRichMediaEvents. pub kind: Option, } impl client::Part for CustomRichMediaEvents {} /// Represents a date range. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DateRange { /// The end date of the date range, inclusive. A string of the format: "yyyy-MM-dd". #[serde(rename="endDate")] pub end_date: Option, /// The kind of resource this is, in this case dfareporting#dateRange. pub kind: Option, /// The date range relative to the date of when the report is run. #[serde(rename="relativeDateRange")] pub relative_date_range: Option, /// The start date of the date range, inclusive. A string of the format: "yyyy-MM-dd". #[serde(rename="startDate")] pub start_date: Option, } impl client::Part for DateRange {} /// Day Part Targeting. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DayPartTargeting { /// Days of the week when the ad will serve. /// /// Acceptable values are: /// - "SUNDAY" /// - "MONDAY" /// - "TUESDAY" /// - "WEDNESDAY" /// - "THURSDAY" /// - "FRIDAY" /// - "SATURDAY" #[serde(rename="daysOfWeek")] pub days_of_week: Option>, /// 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. #[serde(rename="hoursOfDay")] pub hours_of_day: Option>, /// Whether or not to use the user's local time. If false, the America/New York time zone applies. #[serde(rename="userLocalTime")] pub user_local_time: Option, } impl client::Part for DayPartTargeting {} /// Contains information about a landing page deep link. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeepLink { /// The URL of the mobile app being linked to. #[serde(rename="appUrl")] pub app_url: Option, /// The fallback URL. This URL will be served to users who do not have the mobile app installed. #[serde(rename="fallbackUrl")] pub fallback_url: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#deepLink". pub kind: Option, /// The mobile app targeted by this deep link. #[serde(rename="mobileApp")] pub mobile_app: Option, /// Ads served to users on these remarketing lists will use this deep link. Applicable when mobileApp.directory is APPLE_APP_STORE. #[serde(rename="remarketingListIds")] pub remarketing_list_ids: Option>, } impl client::Part for DeepLink {} /// 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. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DefaultClickThroughEventTagProperties { /// ID of the click-through event tag to apply to all ads in this entity's scope. #[serde(rename="defaultClickThroughEventTagId")] pub default_click_through_event_tag_id: Option, /// Whether this entity should override the inherited default click-through event tag with its own defined value. #[serde(rename="overrideInheritedEventTag")] pub override_inherited_event_tag: Option, } impl client::Part for DefaultClickThroughEventTagProperties {} /// Delivery Schedule. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeliverySchedule { /// Limit on the number of times an individual user can be served the ad within a specified period of time. #[serde(rename="frequencyCap")] pub frequency_cap: Option, /// 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. #[serde(rename="hardCutoff")] pub hard_cutoff: Option, /// 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. #[serde(rename="impressionRatio")] pub impression_ratio: Option, /// Serving priority of an ad, with respect to other ads. The lower the priority number, the greater the priority with which it is served. pub priority: Option, } impl client::Part for DeliverySchedule {} /// Google Ad Manager Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DfpSettings { /// Ad Manager network code for this directory site. #[serde(rename="dfpNetworkCode")] pub dfp_network_code: Option, /// Ad Manager network name for this directory site. #[serde(rename="dfpNetworkName")] pub dfp_network_name: Option, /// Whether this directory site accepts programmatic placements. #[serde(rename="programmaticPlacementAccepted")] pub programmatic_placement_accepted: Option, /// Whether this directory site accepts publisher-paid tags. #[serde(rename="pubPaidPlacementAccepted")] pub pub_paid_placement_accepted: Option, /// Whether this directory site is available only via Publisher Portal. #[serde(rename="publisherPortalOnly")] pub publisher_portal_only: Option, } impl client::Part for DfpSettings {} /// Represents a dimension. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Dimension { /// The kind of resource this is, in this case dfareporting#dimension. pub kind: Option, /// The dimension name, e.g. dfa:advertiser pub name: Option, } impl client::Part for Dimension {} /// Represents a dimension filter. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DimensionFilter { /// The name of the dimension to filter. #[serde(rename="dimensionName")] pub dimension_name: Option, /// The kind of resource this is, in this case dfareporting#dimensionFilter. pub kind: Option, /// The value of the dimension to filter. pub value: Option, } impl client::Part for DimensionFilter {} /// Represents a DimensionValue resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [query dimension values](DimensionValueQueryCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DimensionValue { /// The name of the dimension. #[serde(rename="dimensionName")] pub dimension_name: Option, /// The eTag of this response for caching purposes. pub etag: Option, /// The ID associated with the value if available. pub id: Option, /// The kind of resource this is, in this case dfareporting#dimensionValue. pub kind: Option, /// 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. #[serde(rename="matchType")] pub match_type: Option, /// The value of the dimension. pub value: Option, } impl client::Resource for DimensionValue {} /// Represents the list of DimensionValue resources. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [query dimension values](DimensionValueQueryCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DimensionValueList { /// The eTag of this response for caching purposes. pub etag: Option, /// The dimension values returned in this response. pub items: Option>, /// The kind of list this is, in this case dfareporting#dimensionValueList. pub kind: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for DimensionValueList {} /// Represents a DimensionValuesRequest. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [query dimension values](DimensionValueQueryCall) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DimensionValueRequest { /// The name of the dimension for which values should be requested. #[serde(rename="dimensionName")] pub dimension_name: Option, /// The end date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". #[serde(rename="endDate")] pub end_date: Option, /// The list of filters by which to filter values. The filters are ANDed. pub filters: Option>, /// The kind of request this is, in this case dfareporting#dimensionValueRequest. pub kind: Option, /// The start date of the date range for which to retrieve dimension values. A string of the format "yyyy-MM-dd". #[serde(rename="startDate")] pub start_date: Option, } impl client::RequestValue for DimensionValueRequest {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get directory sites](DirectorySiteGetCall) (response) /// * [insert directory sites](DirectorySiteInsertCall) (request|response) /// * [list directory sites](DirectorySiteListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySite { /// Whether this directory site is active. pub active: Option, /// Directory site contacts. #[serde(rename="contactAssignments")] pub contact_assignments: Option>, /// Country ID of this directory site. This is a read-only field. #[serde(rename="countryId")] pub country_id: Option, /// Currency ID of this directory site. This is a read-only field. /// Possible values are: /// - "1" for USD /// - "2" for GBP /// - "3" for ESP /// - "4" for SEK /// - "5" for CAD /// - "6" for JPY /// - "7" for DEM /// - "8" for AUD /// - "9" for FRF /// - "10" for ITL /// - "11" for DKK /// - "12" for NOK /// - "13" for FIM /// - "14" for ZAR /// - "15" for IEP /// - "16" for NLG /// - "17" for EUR /// - "18" for KRW /// - "19" for TWD /// - "20" for SGD /// - "21" for CNY /// - "22" for HKD /// - "23" for NZD /// - "24" for MYR /// - "25" for BRL /// - "26" for PTE /// - "27" for MXP /// - "28" for CLP /// - "29" for TRY /// - "30" for ARS /// - "31" for PEN /// - "32" for ILS /// - "33" for CHF /// - "34" for VEF /// - "35" for COP /// - "36" for GTQ /// - "37" for PLN /// - "39" for INR /// - "40" for THB /// - "41" for IDR /// - "42" for CZK /// - "43" for RON /// - "44" for HUF /// - "45" for RUB /// - "46" for AED /// - "47" for BGN /// - "48" for HRK /// - "49" for MXN /// - "50" for NGN #[serde(rename="currencyId")] pub currency_id: Option, /// Description of this directory site. This is a read-only field. pub description: Option, /// ID of this directory site. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this directory site. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Tag types for regular placements. /// /// Acceptable values are: /// - "STANDARD" /// - "IFRAME_JAVASCRIPT_INPAGE" /// - "INTERNAL_REDIRECT_INPAGE" /// - "JAVASCRIPT_INPAGE" #[serde(rename="inpageTagFormats")] pub inpage_tag_formats: Option>, /// Tag types for interstitial placements. /// /// Acceptable values are: /// - "IFRAME_JAVASCRIPT_INTERSTITIAL" /// - "INTERNAL_REDIRECT_INTERSTITIAL" /// - "JAVASCRIPT_INTERSTITIAL" #[serde(rename="interstitialTagFormats")] pub interstitial_tag_formats: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySite". pub kind: Option, /// Name of this directory site. pub name: Option, /// Parent directory site ID. #[serde(rename="parentId")] pub parent_id: Option, /// Directory site settings. pub settings: Option, /// URL of this directory site. pub url: Option, } impl client::RequestValue for DirectorySite {} impl client::Resource for DirectorySite {} impl client::ResponseResult for DirectorySite {} /// Contains properties of a Site Directory contact. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get directory site contacts](DirectorySiteContactGetCall) (response) /// * [list directory site contacts](DirectorySiteContactListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySiteContact { /// Address of this directory site contact. pub address: Option, /// Email address of this directory site contact. pub email: Option, /// First name of this directory site contact. #[serde(rename="firstName")] pub first_name: Option, /// ID of this directory site contact. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContact". pub kind: Option, /// Last name of this directory site contact. #[serde(rename="lastName")] pub last_name: Option, /// Phone number of this directory site contact. pub phone: Option, /// Directory site contact role. pub role: Option, /// Title or designation of this directory site contact. pub title: Option, /// Directory site contact type. #[serde(rename="type")] pub type_: Option, } impl client::Resource for DirectorySiteContact {} impl client::ResponseResult for DirectorySiteContact {} /// Directory Site Contact Assignment /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySiteContactAssignment { /// ID of this directory site contact. This is a read-only, auto-generated field. #[serde(rename="contactId")] pub contact_id: Option, /// 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. pub visibility: Option, } impl client::Part for DirectorySiteContactAssignment {} /// Directory Site Contact List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list directory site contacts](DirectorySiteContactListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySiteContactsListResponse { /// Directory site contact collection #[serde(rename="directorySiteContacts")] pub directory_site_contacts: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySiteContactsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for DirectorySiteContactsListResponse {} /// Directory Site Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySiteSettings { /// Whether this directory site has disabled active view creatives. #[serde(rename="activeViewOptOut")] pub active_view_opt_out: Option, /// Directory site Ad Manager settings. #[serde(rename="dfpSettings")] pub dfp_settings: Option, /// Whether this site accepts in-stream video ads. #[serde(rename="instreamVideoPlacementAccepted")] pub instream_video_placement_accepted: Option, /// Whether this site accepts interstitial ads. #[serde(rename="interstitialPlacementAccepted")] pub interstitial_placement_accepted: Option, /// Whether this directory site has disabled Nielsen OCR reach ratings. #[serde(rename="nielsenOcrOptOut")] pub nielsen_ocr_opt_out: Option, /// Whether this directory site has disabled generation of Verification ins tags. #[serde(rename="verificationTagOptOut")] pub verification_tag_opt_out: Option, /// Whether this directory site has disabled active view for in-stream video creatives. This is a read-only field. #[serde(rename="videoActiveViewOptOut")] pub video_active_view_opt_out: Option, } impl client::Part for DirectorySiteSettings {} /// Directory Site List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list directory sites](DirectorySiteListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DirectorySitesListResponse { /// Directory site collection. #[serde(rename="directorySites")] pub directory_sites: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#directorySitesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for DirectorySitesListResponse {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete dynamic targeting keys](DynamicTargetingKeyDeleteCall) (none) /// * [insert dynamic targeting keys](DynamicTargetingKeyInsertCall) (request|response) /// * [list dynamic targeting keys](DynamicTargetingKeyListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DynamicTargetingKey { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKey". pub kind: Option, /// 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. pub name: Option, /// ID of the object of this dynamic targeting key. This is a required field. #[serde(rename="objectId")] pub object_id: Option, /// Type of the object of this dynamic targeting key. This is a required field. #[serde(rename="objectType")] pub object_type: Option, } impl client::RequestValue for DynamicTargetingKey {} impl client::Resource for DynamicTargetingKey {} impl client::ResponseResult for DynamicTargetingKey {} /// Dynamic Targeting Key List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list dynamic targeting keys](DynamicTargetingKeyListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DynamicTargetingKeysListResponse { /// Dynamic targeting key collection. #[serde(rename="dynamicTargetingKeys")] pub dynamic_targeting_keys: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#dynamicTargetingKeysListResponse". pub kind: Option, } impl client::ResponseResult for DynamicTargetingKeysListResponse {} /// A description of how user IDs are encrypted. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EncryptionInfo { /// The encryption entity ID. This should match the encryption configuration for ad serving or Data Transfer. #[serde(rename="encryptionEntityId")] pub encryption_entity_id: Option, /// The encryption entity type. This should match the encryption configuration for ad serving or Data Transfer. #[serde(rename="encryptionEntityType")] pub encryption_entity_type: Option, /// Describes whether the encrypted cookie was received from ad serving (the %m macro) or from Data Transfer. #[serde(rename="encryptionSource")] pub encryption_source: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#encryptionInfo". pub kind: Option, } impl client::Part for EncryptionInfo {} /// Contains properties of an event tag. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete event tags](EventTagDeleteCall) (none) /// * [get event tags](EventTagGetCall) (response) /// * [insert event tags](EventTagInsertCall) (request|response) /// * [list event tags](EventTagListCall) (none) /// * [patch event tags](EventTagPatchCall) (request|response) /// * [update event tags](EventTagUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventTag { /// Account ID of this event tag. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this event tag. This field or the campaignId field is required on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Campaign ID of this event tag. This field or the advertiserId field is required on insertion. #[serde(rename="campaignId")] pub campaign_id: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. #[serde(rename="campaignIdDimensionValue")] pub campaign_id_dimension_value: Option, /// Whether this event tag should be automatically enabled for all of the advertiser's campaigns and ads. #[serde(rename="enabledByDefault")] pub enabled_by_default: Option, /// 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. #[serde(rename="excludeFromAdxRequests")] pub exclude_from_adx_requests: Option, /// ID of this event tag. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTag". pub kind: Option, /// Name of this event tag. This is a required field and must be less than 256 characters long. pub name: Option, /// Site filter type for this event tag. If no type is specified then the event tag will be applied to all sites. #[serde(rename="siteFilterType")] pub site_filter_type: Option, /// Filter list of site IDs associated with this event tag. The siteFilterType determines whether this is a whitelist or blacklist filter. #[serde(rename="siteIds")] pub site_ids: Option>, /// Whether this tag is SSL-compliant or not. This is a read-only field. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Status of this event tag. Must be ENABLED for this event tag to fire. This is a required field. pub status: Option, /// Subaccount ID of this event tag. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// 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. #[serde(rename="type")] pub type_: Option, /// 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. pub url: Option, /// 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. #[serde(rename="urlEscapeLevels")] pub url_escape_levels: Option, } impl client::RequestValue for EventTag {} impl client::Resource for EventTag {} impl client::ResponseResult for EventTag {} /// Event tag override information. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventTagOverride { /// Whether this override is enabled. pub enabled: Option, /// ID of this event tag override. This is a read-only, auto-generated field. pub id: Option, } impl client::Part for EventTagOverride {} /// Event Tag List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list event tags](EventTagListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct EventTagsListResponse { /// Event tag collection. #[serde(rename="eventTags")] pub event_tags: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#eventTagsListResponse". pub kind: Option, } impl client::ResponseResult for EventTagsListResponse {} /// 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". /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get files](FileGetCall) (response) /// * [list files](FileListCall) (none) /// * [files get reports](ReportFileGetCall) (response) /// * [run reports](ReportRunCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct File { /// 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. #[serde(rename="dateRange")] pub date_range: Option, /// The eTag of this response for caching purposes. pub etag: Option, /// The filename of the file. #[serde(rename="fileName")] pub file_name: Option, /// The output format of the report. Only available once the file is available. pub format: Option, /// The unique ID of this report file. pub id: Option, /// The kind of resource this is, in this case dfareporting#file. pub kind: Option, /// The timestamp in milliseconds since epoch when this file was last modified. #[serde(rename="lastModifiedTime")] pub last_modified_time: Option, /// The ID of the report this file was generated from. #[serde(rename="reportId")] pub report_id: Option, /// The status of the report file. pub status: Option, /// The URLs where the completed report file can be downloaded. pub urls: Option, } impl client::Resource for File {} impl client::ResponseResult for File {} /// Represents the list of File resources. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list files](FileListCall) (response) /// * [files list reports](ReportFileListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileList { /// The eTag of this response for caching purposes. pub etag: Option, /// The files returned in this response. pub items: Option>, /// The kind of list this is, in this case dfareporting#fileList. pub kind: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for FileList {} /// Flight /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Flight { /// Inventory item flight end date. #[serde(rename="endDate")] pub end_date: Option, /// Rate or cost of this flight. #[serde(rename="rateOrCost")] pub rate_or_cost: Option, /// Inventory item flight start date. #[serde(rename="startDate")] pub start_date: Option, /// Units of this flight. pub units: Option, } impl client::Part for Flight {} /// Floodlight Activity GenerateTag Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [generatetag floodlight activities](FloodlightActivityGeneratetagCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivitiesGenerateTagResponse { /// Generated tag for this Floodlight activity. For global site tags, this is the event snippet. #[serde(rename="floodlightActivityTag")] pub floodlight_activity_tag: Option, /// 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. #[serde(rename="globalSiteTagGlobalSnippet")] pub global_site_tag_global_snippet: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesGenerateTagResponse". pub kind: Option, } impl client::ResponseResult for FloodlightActivitiesGenerateTagResponse {} /// Floodlight Activity List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list floodlight activities](FloodlightActivityListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivitiesListResponse { /// Floodlight activity collection. #[serde(rename="floodlightActivities")] pub floodlight_activities: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivitiesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for FloodlightActivitiesListResponse {} /// Contains properties of a Floodlight activity. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get floodlight activities](FloodlightActivityGetCall) (response) /// * [insert floodlight activities](FloodlightActivityInsertCall) (request|response) /// * [patch floodlight activities](FloodlightActivityPatchCall) (request|response) /// * [update floodlight activities](FloodlightActivityUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivity { /// Account ID of this floodlight activity. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Code type used for cache busting in the generated tag. Applicable only when floodlightActivityGroupType is COUNTER and countingMethod is STANDARD_COUNTING or UNIQUE_COUNTING. #[serde(rename="cacheBustingType")] pub cache_busting_type: Option, /// Counting method for conversions for this floodlight activity. This is a required field. #[serde(rename="countingMethod")] pub counting_method: Option, /// Dynamic floodlight tags. #[serde(rename="defaultTags")] pub default_tags: Option>, /// URL where this tag will be deployed. If specified, must be less than 256 characters long. #[serde(rename="expectedUrl")] pub expected_url: Option, /// Floodlight activity group ID of this floodlight activity. This is a required field. #[serde(rename="floodlightActivityGroupId")] pub floodlight_activity_group_id: Option, /// Name of the associated floodlight activity group. This is a read-only field. #[serde(rename="floodlightActivityGroupName")] pub floodlight_activity_group_name: Option, /// Tag string of the associated floodlight activity group. This is a read-only field. #[serde(rename="floodlightActivityGroupTagString")] pub floodlight_activity_group_tag_string: Option, /// Type of the associated floodlight activity group. This is a read-only field. #[serde(rename="floodlightActivityGroupType")] pub floodlight_activity_group_type: Option, /// 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. #[serde(rename="floodlightConfigurationId")] pub floodlight_configuration_id: Option, /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. #[serde(rename="floodlightConfigurationIdDimensionValue")] pub floodlight_configuration_id_dimension_value: Option, /// The type of Floodlight tag this activity will generate. This is a required field. #[serde(rename="floodlightTagType")] pub floodlight_tag_type: Option, /// Whether this activity is archived. pub hidden: Option, /// ID of this floodlight activity. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this floodlight activity. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivity". pub kind: Option, /// Name of this floodlight activity. This is a required field. Must be less than 129 characters long and cannot contain quotes. pub name: Option, /// General notes or implementation instructions for the tag. pub notes: Option, /// Publisher dynamic floodlight tags. #[serde(rename="publisherTags")] pub publisher_tags: Option>, /// Whether this tag should use SSL. pub secure: Option, /// Whether the floodlight activity is SSL-compliant. This is a read-only field, its value detected by the system from the floodlight tags. #[serde(rename="sslCompliant")] pub ssl_compliant: Option, /// Whether this floodlight activity must be SSL-compliant. #[serde(rename="sslRequired")] pub ssl_required: Option, /// Subaccount ID of this floodlight activity. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Tag format type for the floodlight activity. If left blank, the tag format will default to HTML. #[serde(rename="tagFormat")] pub tag_format: Option, /// 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. #[serde(rename="tagString")] pub tag_string: Option, /// 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. /// Acceptable values are U1 to U100, inclusive. #[serde(rename="userDefinedVariableTypes")] pub user_defined_variable_types: Option>, } impl client::RequestValue for FloodlightActivity {} impl client::ResponseResult for FloodlightActivity {} /// Dynamic Tag /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivityDynamicTag { /// ID of this dynamic tag. This is a read-only, auto-generated field. pub id: Option, /// Name of this tag. pub name: Option, /// Tag code. pub tag: Option, } impl client::Part for FloodlightActivityDynamicTag {} /// Contains properties of a Floodlight activity group. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get floodlight activity groups](FloodlightActivityGroupGetCall) (response) /// * [insert floodlight activity groups](FloodlightActivityGroupInsertCall) (request|response) /// * [list floodlight activity groups](FloodlightActivityGroupListCall) (none) /// * [patch floodlight activity groups](FloodlightActivityGroupPatchCall) (request|response) /// * [update floodlight activity groups](FloodlightActivityGroupUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivityGroup { /// Account ID of this floodlight activity group. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Floodlight configuration ID of this floodlight activity group. This is a required field. #[serde(rename="floodlightConfigurationId")] pub floodlight_configuration_id: Option, /// Dimension value for the ID of the floodlight configuration. This is a read-only, auto-generated field. #[serde(rename="floodlightConfigurationIdDimensionValue")] pub floodlight_configuration_id_dimension_value: Option, /// ID of this floodlight activity group. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this floodlight activity group. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroup". pub kind: Option, /// Name of this floodlight activity group. This is a required field. Must be less than 65 characters long and cannot contain quotes. pub name: Option, /// Subaccount ID of this floodlight activity group. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// 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. #[serde(rename="tagString")] pub tag_string: Option, /// Type of the floodlight activity group. This is a required field that is read-only after insertion. #[serde(rename="type")] pub type_: Option, } impl client::RequestValue for FloodlightActivityGroup {} impl client::Resource for FloodlightActivityGroup {} impl client::ResponseResult for FloodlightActivityGroup {} /// Floodlight Activity Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list floodlight activity groups](FloodlightActivityGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivityGroupsListResponse { /// Floodlight activity group collection. #[serde(rename="floodlightActivityGroups")] pub floodlight_activity_groups: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightActivityGroupsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for FloodlightActivityGroupsListResponse {} /// Publisher Dynamic Tag /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightActivityPublisherDynamicTag { /// Whether this tag is applicable only for click-throughs. #[serde(rename="clickThrough")] pub click_through: Option, /// 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. #[serde(rename="directorySiteId")] pub directory_site_id: Option, /// Dynamic floodlight tag. #[serde(rename="dynamicTag")] pub dynamic_tag: Option, /// Site ID of this dynamic tag. #[serde(rename="siteId")] pub site_id: Option, /// Dimension value for the ID of the site. This is a read-only, auto-generated field. #[serde(rename="siteIdDimensionValue")] pub site_id_dimension_value: Option, /// Whether this tag is applicable only for view-throughs. #[serde(rename="viewThrough")] pub view_through: Option, } impl client::Part for FloodlightActivityPublisherDynamicTag {} /// Contains properties of a Floodlight configuration. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get floodlight configurations](FloodlightConfigurationGetCall) (response) /// * [list floodlight configurations](FloodlightConfigurationListCall) (none) /// * [patch floodlight configurations](FloodlightConfigurationPatchCall) (request|response) /// * [update floodlight configurations](FloodlightConfigurationUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightConfiguration { /// Account ID of this floodlight configuration. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of the parent advertiser of this floodlight configuration. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Whether advertiser data is shared with Google Analytics. #[serde(rename="analyticsDataSharingEnabled")] pub analytics_data_sharing_enabled: Option, /// 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. #[serde(rename="exposureToConversionEnabled")] pub exposure_to_conversion_enabled: Option, /// Day that will be counted as the first day of the week in reports. This is a required field. #[serde(rename="firstDayOfWeek")] pub first_day_of_week: Option, /// ID of this floodlight configuration. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this floodlight configuration. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Whether in-app attribution tracking is enabled. #[serde(rename="inAppAttributionTrackingEnabled")] pub in_app_attribution_tracking_enabled: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfiguration". pub kind: Option, /// Lookback window settings for this floodlight configuration. #[serde(rename="lookbackConfiguration")] pub lookback_configuration: Option, /// Types of attribution options for natural search conversions. #[serde(rename="naturalSearchConversionAttributionOption")] pub natural_search_conversion_attribution_option: Option, /// Settings for Campaign Manager Omniture integration. #[serde(rename="omnitureSettings")] pub omniture_settings: Option, /// Subaccount ID of this floodlight configuration. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Configuration settings for dynamic and image floodlight tags. #[serde(rename="tagSettings")] pub tag_settings: Option, /// List of third-party authentication tokens enabled for this configuration. #[serde(rename="thirdPartyAuthenticationTokens")] pub third_party_authentication_tokens: Option>, /// List of user defined variables enabled for this configuration. #[serde(rename="userDefinedVariableConfigurations")] pub user_defined_variable_configurations: Option>, } impl client::RequestValue for FloodlightConfiguration {} impl client::Resource for FloodlightConfiguration {} impl client::ResponseResult for FloodlightConfiguration {} /// Floodlight Configuration List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list floodlight configurations](FloodlightConfigurationListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightConfigurationsListResponse { /// Floodlight configuration collection. #[serde(rename="floodlightConfigurations")] pub floodlight_configurations: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#floodlightConfigurationsListResponse". pub kind: Option, } impl client::ResponseResult for FloodlightConfigurationsListResponse {} /// Represents fields that are compatible to be selected for a report of type "FlOODLIGHT". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FloodlightReportCompatibleFields { /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. pub dimensions: Option>, /// The kind of resource this is, in this case dfareporting#floodlightReportCompatibleFields. pub kind: Option, /// Metrics which are compatible to be selected in the "metricNames" section of the report. pub metrics: Option>, } impl client::Part for FloodlightReportCompatibleFields {} /// Frequency Cap. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FrequencyCap { /// Duration of time, in seconds, for this frequency cap. The maximum duration is 90 days. Acceptable values are 1 to 7776000, inclusive. pub duration: Option, /// Number of times an individual user can be served the ad within the specified duration. Acceptable values are 1 to 15, inclusive. pub impressions: Option, } impl client::Part for FrequencyCap {} /// FsCommand. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FsCommand { /// Distance from the left of the browser.Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. pub left: Option, /// Position in the browser where the window will open. #[serde(rename="positionOption")] pub position_option: Option, /// Distance from the top of the browser. Applicable when positionOption is DISTANCE_FROM_TOP_LEFT_CORNER. pub top: Option, /// Height of the window. #[serde(rename="windowHeight")] pub window_height: Option, /// Width of the window. #[serde(rename="windowWidth")] pub window_width: Option, } impl client::Part for FsCommand {} /// Geographical Targeting. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GeoTargeting { /// 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. pub cities: Option>, /// 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. pub countries: Option>, /// 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. #[serde(rename="excludeCountries")] pub exclude_countries: Option, /// 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. pub metros: Option>, /// 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. #[serde(rename="postalCodes")] pub postal_codes: Option>, /// 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. pub regions: Option>, } impl client::Part for GeoTargeting {} /// Represents a buy from the Planning inventory store. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get inventory items](InventoryItemGetCall) (response) /// * [list inventory items](InventoryItemListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InventoryItem { /// Account ID of this inventory item. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="adSlots")] pub ad_slots: Option>, /// Advertiser ID of this inventory item. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Content category ID of this inventory item. #[serde(rename="contentCategoryId")] pub content_category_id: Option, /// Estimated click-through rate of this inventory item. #[serde(rename="estimatedClickThroughRate")] pub estimated_click_through_rate: Option, /// Estimated conversion rate of this inventory item. #[serde(rename="estimatedConversionRate")] pub estimated_conversion_rate: Option, /// ID of this inventory item. pub id: Option, /// Whether this inventory item is in plan. #[serde(rename="inPlan")] pub in_plan: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItem". pub kind: Option, /// Information about the most recent modification of this inventory item. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// 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. pub name: Option, /// Negotiation channel ID of this inventory item. #[serde(rename="negotiationChannelId")] pub negotiation_channel_id: Option, /// Order ID of this inventory item. #[serde(rename="orderId")] pub order_id: Option, /// Placement strategy ID of this inventory item. #[serde(rename="placementStrategyId")] pub placement_strategy_id: Option, /// Pricing of this inventory item. pub pricing: Option, /// Project ID of this inventory item. #[serde(rename="projectId")] pub project_id: Option, /// RFP ID of this inventory item. #[serde(rename="rfpId")] pub rfp_id: Option, /// ID of the site this inventory item is associated with. #[serde(rename="siteId")] pub site_id: Option, /// Subaccount ID of this inventory item. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Type of inventory item. #[serde(rename="type")] pub type_: Option, } impl client::Resource for InventoryItem {} impl client::ResponseResult for InventoryItem {} /// Inventory item List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list inventory items](InventoryItemListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct InventoryItemsListResponse { /// Inventory item collection #[serde(rename="inventoryItems")] pub inventory_items: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#inventoryItemsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for InventoryItemsListResponse {} /// Key Value Targeting Expression. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct KeyValueTargetingExpression { /// Keyword expression being targeted by the ad. pub expression: Option, } impl client::Part for KeyValueTargetingExpression {} /// Contains information about where a user's browser is taken after the user clicks an ad. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get advertiser landing pages](AdvertiserLandingPageGetCall) (response) /// * [insert advertiser landing pages](AdvertiserLandingPageInsertCall) (request|response) /// * [patch advertiser landing pages](AdvertiserLandingPagePatchCall) (request|response) /// * [update advertiser landing pages](AdvertiserLandingPageUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LandingPage { /// Advertiser ID of this landing page. This is a required field. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Whether this landing page has been archived. pub archived: Option, /// Links that will direct the user to a mobile app, if installed. #[serde(rename="deepLinks")] pub deep_links: Option>, /// ID of this landing page. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#landingPage". pub kind: Option, /// Name of this landing page. This is a required field. It must be less than 256 characters long. pub name: Option, /// URL of this landing page. This is a required field. pub url: Option, } impl client::RequestValue for LandingPage {} impl client::ResponseResult for LandingPage {} /// Contains information about a language that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list languages](LanguageListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Language { /// Language ID of this language. This is the ID used for targeting and generating reports. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#language". pub kind: Option, /// 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. #[serde(rename="languageCode")] pub language_code: Option, /// Name of this language. pub name: Option, } impl client::Resource for Language {} /// Language Targeting. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LanguageTargeting { /// 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. pub languages: Option>, } impl client::Part for LanguageTargeting {} /// Language List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list languages](LanguageListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LanguagesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#languagesListResponse". pub kind: Option, /// Language collection. pub languages: Option>, } impl client::ResponseResult for LanguagesListResponse {} /// Modification timestamp. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LastModifiedInfo { /// Timestamp of the last change in milliseconds since epoch. pub time: Option, } impl client::Part for LastModifiedInfo {} /// A group clause made up of list population terms representing constraints joined by ORs. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListPopulationClause { /// Terms of this list population clause. Each clause is made up of list population terms representing constraints and are joined by ORs. pub terms: Option>, } impl client::Part for ListPopulationClause {} /// Remarketing List Population Rule. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListPopulationRule { /// Floodlight activity ID associated with this rule. This field can be left blank. #[serde(rename="floodlightActivityId")] pub floodlight_activity_id: Option, /// Name of floodlight activity associated with this rule. This is a read-only, auto-generated field. #[serde(rename="floodlightActivityName")] pub floodlight_activity_name: Option, /// 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. #[serde(rename="listPopulationClauses")] pub list_population_clauses: Option>, } impl client::Part for ListPopulationRule {} /// Remarketing List Population Rule Term. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListPopulationTerm { /// 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. pub contains: Option, /// 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. pub negation: Option, /// Comparison operator of this term. This field is only relevant when type is left unset or set to CUSTOM_VARIABLE_TERM or REFERRER_TERM. pub operator: Option, /// ID of the list in question. This field is only relevant when type is set to LIST_MEMBERSHIP_TERM. #[serde(rename="remarketingListId")] pub remarketing_list_id: Option, /// 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. #[serde(rename="type")] pub type_: Option, /// 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. pub value: Option, /// 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. #[serde(rename="variableFriendlyName")] pub variable_friendly_name: Option, /// 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. #[serde(rename="variableName")] pub variable_name: Option, } impl client::Part for ListPopulationTerm {} /// Remarketing List Targeting Expression. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListTargetingExpression { /// Expression describing which lists are being targeted by the ad. pub expression: Option, } impl client::Part for ListTargetingExpression {} /// Lookback configuration settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LookbackConfiguration { /// 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. #[serde(rename="clickDuration")] pub click_duration: Option, /// 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. #[serde(rename="postImpressionActivitiesDuration")] pub post_impression_activities_duration: Option, } impl client::Part for LookbackConfiguration {} /// Represents a metric. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metric { /// The kind of resource this is, in this case dfareporting#metric. pub kind: Option, /// The metric name, e.g. dfa:impressions pub name: Option, } impl client::Part for Metric {} /// Contains information about a metro region that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list metros](MetroListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Metro { /// Country code of the country to which this metro region belongs. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of the country to which this metro region belongs. #[serde(rename="countryDartId")] pub country_dart_id: Option, /// DART ID of this metro region. #[serde(rename="dartId")] pub dart_id: Option, /// DMA ID of this metro region. This is the ID used for targeting and generating reports, and is equivalent to metro_code. #[serde(rename="dmaId")] pub dma_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metro". pub kind: Option, /// Metro code of this metro region. This is equivalent to dma_id. #[serde(rename="metroCode")] pub metro_code: Option, /// Name of this metro region. pub name: Option, } impl client::Resource for Metro {} /// Metro List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list metros](MetroListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MetrosListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#metrosListResponse". pub kind: Option, /// Metro collection. pub metros: Option>, } impl client::ResponseResult for MetrosListResponse {} /// Contains information about a mobile app. Used as a landing page deep link. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get mobile apps](MobileAppGetCall) (response) /// * [list mobile apps](MobileAppListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileApp { /// Mobile app directory. pub directory: Option, /// ID of this mobile app. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileApp". pub kind: Option, /// Publisher name. #[serde(rename="publisherName")] pub publisher_name: Option, /// Title of this mobile app. pub title: Option, } impl client::Resource for MobileApp {} impl client::ResponseResult for MobileApp {} /// Mobile app List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list mobile apps](MobileAppListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileAppsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileAppsListResponse". pub kind: Option, /// Mobile apps collection. #[serde(rename="mobileApps")] pub mobile_apps: Option>, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for MobileAppsListResponse {} /// Contains information about a mobile carrier that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get mobile carriers](MobileCarrierGetCall) (response) /// * [list mobile carriers](MobileCarrierListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileCarrier { /// Country code of the country to which this mobile carrier belongs. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of the country to which this mobile carrier belongs. #[serde(rename="countryDartId")] pub country_dart_id: Option, /// ID of this mobile carrier. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarrier". pub kind: Option, /// Name of this mobile carrier. pub name: Option, } impl client::Resource for MobileCarrier {} impl client::ResponseResult for MobileCarrier {} /// Mobile Carrier List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list mobile carriers](MobileCarrierListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MobileCarriersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#mobileCarriersListResponse". pub kind: Option, /// Mobile carrier collection. #[serde(rename="mobileCarriers")] pub mobile_carriers: Option>, } impl client::ResponseResult for MobileCarriersListResponse {} /// Object Filter. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ObjectFilter { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#objectFilter". pub kind: Option, /// Applicable when status is ASSIGNED. The user has access to objects with these object IDs. #[serde(rename="objectIds")] pub object_ids: Option>, /// 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. pub status: Option, } impl client::Part for ObjectFilter {} /// Offset Position. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OffsetPosition { /// Offset distance from left side of an asset or a window. pub left: Option, /// Offset distance from top side of an asset or a window. pub top: Option, } impl client::Part for OffsetPosition {} /// Omniture Integration Settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OmnitureSettings { /// Whether placement cost data will be sent to Omniture. This property can be enabled only if omnitureIntegrationEnabled is true. #[serde(rename="omnitureCostDataEnabled")] pub omniture_cost_data_enabled: Option, /// Whether Omniture integration is enabled. This property can be enabled only when the "Advanced Ad Serving" account setting is enabled. #[serde(rename="omnitureIntegrationEnabled")] pub omniture_integration_enabled: Option, } impl client::Part for OmnitureSettings {} /// Contains information about an operating system that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get operating systems](OperatingSystemGetCall) (response) /// * [list operating systems](OperatingSystemListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperatingSystem { /// DART ID of this operating system. This is the ID used for targeting. #[serde(rename="dartId")] pub dart_id: Option, /// Whether this operating system is for desktop. pub desktop: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystem". pub kind: Option, /// Whether this operating system is for mobile. pub mobile: Option, /// Name of this operating system. pub name: Option, } impl client::Resource for OperatingSystem {} impl client::ResponseResult for OperatingSystem {} /// Contains information about a particular version of an operating system that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get operating system versions](OperatingSystemVersionGetCall) (response) /// * [list operating system versions](OperatingSystemVersionListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperatingSystemVersion { /// ID of this operating system version. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersion". pub kind: Option, /// Major version (leftmost number) of this operating system version. #[serde(rename="majorVersion")] pub major_version: Option, /// Minor version (number after the first dot) of this operating system version. #[serde(rename="minorVersion")] pub minor_version: Option, /// Name of this operating system version. pub name: Option, /// Operating system of this operating system version. #[serde(rename="operatingSystem")] pub operating_system: Option, } impl client::Resource for OperatingSystemVersion {} impl client::ResponseResult for OperatingSystemVersion {} /// Operating System Version List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list operating system versions](OperatingSystemVersionListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperatingSystemVersionsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemVersionsListResponse". pub kind: Option, /// Operating system version collection. #[serde(rename="operatingSystemVersions")] pub operating_system_versions: Option>, } impl client::ResponseResult for OperatingSystemVersionsListResponse {} /// Operating System List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list operating systems](OperatingSystemListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OperatingSystemsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#operatingSystemsListResponse". pub kind: Option, /// Operating system collection. #[serde(rename="operatingSystems")] pub operating_systems: Option>, } impl client::ResponseResult for OperatingSystemsListResponse {} /// Creative optimization activity. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OptimizationActivity { /// Floodlight activity ID of this optimization activity. This is a required field. #[serde(rename="floodlightActivityId")] pub floodlight_activity_id: Option, /// Dimension value for the ID of the floodlight activity. This is a read-only, auto-generated field. #[serde(rename="floodlightActivityIdDimensionValue")] pub floodlight_activity_id_dimension_value: Option, /// 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. pub weight: Option, } impl client::Part for OptimizationActivity {} /// Describes properties of a Planning order. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get orders](OrderGetCall) (response) /// * [list orders](OrderListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Order { /// Account ID of this order. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this order. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// IDs for users that have to approve documents created for this order. #[serde(rename="approverUserProfileIds")] pub approver_user_profile_ids: Option>, /// Buyer invoice ID associated with this order. #[serde(rename="buyerInvoiceId")] pub buyer_invoice_id: Option, /// Name of the buyer organization. #[serde(rename="buyerOrganizationName")] pub buyer_organization_name: Option, /// Comments in this order. pub comments: Option, /// Contacts for this order. pub contacts: Option>, /// ID of this order. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#order". pub kind: Option, /// Information about the most recent modification of this order. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Name of this order. pub name: Option, /// Notes of this order. pub notes: Option, /// ID of the terms and conditions template used in this order. #[serde(rename="planningTermId")] pub planning_term_id: Option, /// Project ID of this order. #[serde(rename="projectId")] pub project_id: Option, /// Seller order ID associated with this order. #[serde(rename="sellerOrderId")] pub seller_order_id: Option, /// Name of the seller organization. #[serde(rename="sellerOrganizationName")] pub seller_organization_name: Option, /// Site IDs this order is associated with. #[serde(rename="siteId")] pub site_id: Option>, /// Free-form site names this order is associated with. #[serde(rename="siteNames")] pub site_names: Option>, /// Subaccount ID of this order. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Terms and conditions of this order. #[serde(rename="termsAndConditions")] pub terms_and_conditions: Option, } impl client::Resource for Order {} impl client::ResponseResult for Order {} /// Contact of an order. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrderContact { /// 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. #[serde(rename="contactInfo")] pub contact_info: Option, /// Name of this contact. #[serde(rename="contactName")] pub contact_name: Option, /// Title of this contact. #[serde(rename="contactTitle")] pub contact_title: Option, /// Type of this contact. #[serde(rename="contactType")] pub contact_type: Option, /// ID of the user profile containing the signature that will be embedded into order documents. #[serde(rename="signatureUserProfileId")] pub signature_user_profile_id: Option, } impl client::Part for OrderContact {} /// Contains properties of a Planning order document. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get order documents](OrderDocumentGetCall) (response) /// * [list order documents](OrderDocumentListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrderDocument { /// Account ID of this order document. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this order document. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// 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. #[serde(rename="amendedOrderDocumentId")] pub amended_order_document_id: Option, /// IDs of users who have approved this order document. #[serde(rename="approvedByUserProfileIds")] pub approved_by_user_profile_ids: Option>, /// Whether this order document is cancelled. pub cancelled: Option, /// Information about the creation of this order document. #[serde(rename="createdInfo")] pub created_info: Option, /// Effective date of this order document. #[serde(rename="effectiveDate")] pub effective_date: Option, /// ID of this order document. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocument". pub kind: Option, /// List of email addresses that received the last sent document. #[serde(rename="lastSentRecipients")] pub last_sent_recipients: Option>, /// Timestamp of the last email sent with this order document. #[serde(rename="lastSentTime")] pub last_sent_time: Option, /// ID of the order from which this order document is created. #[serde(rename="orderId")] pub order_id: Option, /// Project ID of this order document. #[serde(rename="projectId")] pub project_id: Option, /// Whether this order document has been signed. pub signed: Option, /// Subaccount ID of this order document. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Title of this order document. pub title: Option, /// Type of this order document #[serde(rename="type")] pub type_: Option, } impl client::Resource for OrderDocument {} impl client::ResponseResult for OrderDocument {} /// Order document List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list order documents](OrderDocumentListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrderDocumentsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#orderDocumentsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Order document collection #[serde(rename="orderDocuments")] pub order_documents: Option>, } impl client::ResponseResult for OrderDocumentsListResponse {} /// Order List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list orders](OrderListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct OrdersListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#ordersListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Order collection. pub orders: Option>, } impl client::ResponseResult for OrdersListResponse {} /// Represents fields that are compatible to be selected for a report of type "PATH_TO_CONVERSION". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PathToConversionReportCompatibleFields { /// Conversion dimensions which are compatible to be selected in the "conversionDimensions" section of the report. #[serde(rename="conversionDimensions")] pub conversion_dimensions: Option>, /// Custom floodlight variables which are compatible to be selected in the "customFloodlightVariables" section of the report. #[serde(rename="customFloodlightVariables")] pub custom_floodlight_variables: Option>, /// The kind of resource this is, in this case dfareporting#pathToConversionReportCompatibleFields. pub kind: Option, /// Metrics which are compatible to be selected in the "metricNames" section of the report. pub metrics: Option>, /// Per-interaction dimensions which are compatible to be selected in the "perInteractionDimensions" section of the report. #[serde(rename="perInteractionDimensions")] pub per_interaction_dimensions: Option>, } impl client::Part for PathToConversionReportCompatibleFields {} /// Contains properties of a placement. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [generatetags placements](PlacementGeneratetagCall) (none) /// * [get placements](PlacementGetCall) (response) /// * [insert placements](PlacementInsertCall) (request|response) /// * [list placements](PlacementListCall) (none) /// * [patch placements](PlacementPatchCall) (request|response) /// * [update placements](PlacementUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Placement { /// Account ID of this placement. This field can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="adBlockingOptOut")] pub ad_blocking_opt_out: Option, /// Additional sizes associated with this placement. When inserting or updating a placement, only the size ID field is used. #[serde(rename="additionalSizes")] pub additional_sizes: Option>, /// Advertiser ID of this placement. This field can be left blank. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Whether this placement is archived. pub archived: Option, /// Campaign ID of this placement. This field is a required field on insertion. #[serde(rename="campaignId")] pub campaign_id: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. #[serde(rename="campaignIdDimensionValue")] pub campaign_id_dimension_value: Option, /// Comments for this placement. pub comment: Option, /// 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. pub compatibility: Option, /// ID of the content category assigned to this placement. #[serde(rename="contentCategoryId")] pub content_category_id: Option, /// Information about the creation of this placement. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// 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. #[serde(rename="directorySiteId")] pub directory_site_id: Option, /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. #[serde(rename="directorySiteIdDimensionValue")] pub directory_site_id_dimension_value: Option, /// External ID for this placement. #[serde(rename="externalId")] pub external_id: Option, /// ID of this placement. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this placement. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Key name of this placement. This is a read-only, auto-generated field. #[serde(rename="keyName")] pub key_name: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placement". pub kind: Option, /// Information about the most recent modification of this placement. This is a read-only field. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Lookback window settings for this placement. #[serde(rename="lookbackConfiguration")] pub lookback_configuration: Option, /// Name of this placement.This is a required field and must be less than 256 characters long. pub name: Option, /// Whether payment was approved for this placement. This is a read-only field relevant only to publisher-paid placements. #[serde(rename="paymentApproved")] pub payment_approved: Option, /// Payment source for this placement. This is a required field that is read-only after insertion. #[serde(rename="paymentSource")] pub payment_source: Option, /// ID of this placement's group, if applicable. #[serde(rename="placementGroupId")] pub placement_group_id: Option, /// Dimension value for the ID of the placement group. This is a read-only, auto-generated field. #[serde(rename="placementGroupIdDimensionValue")] pub placement_group_id_dimension_value: Option, /// ID of the placement strategy assigned to this placement. #[serde(rename="placementStrategyId")] pub placement_strategy_id: Option, /// Pricing schedule of this placement. This field is required on insertion, specifically subfields startDate, endDate and pricingType. #[serde(rename="pricingSchedule")] pub pricing_schedule: Option, /// 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. pub primary: Option, /// Information about the last publisher update. This is a read-only field. #[serde(rename="publisherUpdateInfo")] pub publisher_update_info: Option, /// 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. #[serde(rename="siteId")] pub site_id: Option, /// Dimension value for the ID of the site. This is a read-only, auto-generated field. #[serde(rename="siteIdDimensionValue")] pub site_id_dimension_value: Option, /// Size associated with this placement. When inserting or updating a placement, only the size ID field is used. This field is required on insertion. pub size: Option, /// Whether creatives assigned to this placement must be SSL-compliant. #[serde(rename="sslRequired")] pub ssl_required: Option, /// Third-party placement status. pub status: Option, /// Subaccount ID of this placement. This field can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Tag formats to generate for this placement. This field is required on insertion. /// Acceptable values are: /// - "PLACEMENT_TAG_STANDARD" /// - "PLACEMENT_TAG_IFRAME_JAVASCRIPT" /// - "PLACEMENT_TAG_IFRAME_ILAYER" /// - "PLACEMENT_TAG_INTERNAL_REDIRECT" /// - "PLACEMENT_TAG_JAVASCRIPT" /// - "PLACEMENT_TAG_INTERSTITIAL_IFRAME_JAVASCRIPT" /// - "PLACEMENT_TAG_INTERSTITIAL_INTERNAL_REDIRECT" /// - "PLACEMENT_TAG_INTERSTITIAL_JAVASCRIPT" /// - "PLACEMENT_TAG_CLICK_COMMANDS" /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH" /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH_VAST_3" /// - "PLACEMENT_TAG_INSTREAM_VIDEO_PREFETCH_VAST_4" /// - "PLACEMENT_TAG_TRACKING" /// - "PLACEMENT_TAG_TRACKING_IFRAME" /// - "PLACEMENT_TAG_TRACKING_JAVASCRIPT" #[serde(rename="tagFormats")] pub tag_formats: Option>, /// Tag settings for this placement. #[serde(rename="tagSetting")] pub tag_setting: Option, /// 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. #[serde(rename="videoActiveViewOptOut")] pub video_active_view_opt_out: Option, /// A collection of settings which affect video creatives served through this placement. Applicable to placements with IN_STREAM_VIDEO compatibility. #[serde(rename="videoSettings")] pub video_settings: Option, /// VPAID adapter setting for this placement. Controls which VPAID format the measurement adapter will use for in-stream video creatives assigned to this placement. /// /// Note: Flash is no longer supported. This field now defaults to HTML5 when the following values are provided: FLASH, BOTH. #[serde(rename="vpaidAdapterChoice")] pub vpaid_adapter_choice: Option, } impl client::RequestValue for Placement {} impl client::Resource for Placement {} impl client::ResponseResult for Placement {} /// Placement Assignment. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementAssignment { /// Whether this placement assignment is active. When true, the placement will be included in the ad's rotation. pub active: Option, /// ID of the placement to be assigned. This is a required field. #[serde(rename="placementId")] pub placement_id: Option, /// Dimension value for the ID of the placement. This is a read-only, auto-generated field. #[serde(rename="placementIdDimensionValue")] pub placement_id_dimension_value: Option, /// 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. #[serde(rename="sslRequired")] pub ssl_required: Option, } impl client::Part for PlacementAssignment {} /// Contains properties of a package or roadblock. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get placement groups](PlacementGroupGetCall) (response) /// * [insert placement groups](PlacementGroupInsertCall) (request|response) /// * [list placement groups](PlacementGroupListCall) (none) /// * [patch placement groups](PlacementGroupPatchCall) (request|response) /// * [update placement groups](PlacementGroupUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementGroup { /// Account ID of this placement group. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this placement group. This is a required field on insertion. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Whether this placement group is archived. pub archived: Option, /// Campaign ID of this placement group. This field is required on insertion. #[serde(rename="campaignId")] pub campaign_id: Option, /// Dimension value for the ID of the campaign. This is a read-only, auto-generated field. #[serde(rename="campaignIdDimensionValue")] pub campaign_id_dimension_value: Option, /// IDs of placements which are assigned to this placement group. This is a read-only, auto-generated field. #[serde(rename="childPlacementIds")] pub child_placement_ids: Option>, /// Comments for this placement group. pub comment: Option, /// ID of the content category assigned to this placement group. #[serde(rename="contentCategoryId")] pub content_category_id: Option, /// Information about the creation of this placement group. This is a read-only field. #[serde(rename="createInfo")] pub create_info: Option, /// 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. #[serde(rename="directorySiteId")] pub directory_site_id: Option, /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. #[serde(rename="directorySiteIdDimensionValue")] pub directory_site_id_dimension_value: Option, /// External ID for this placement. #[serde(rename="externalId")] pub external_id: Option, /// ID of this placement group. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this placement group. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroup". pub kind: Option, /// Information about the most recent modification of this placement group. This is a read-only field. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Name of this placement group. This is a required field and must be less than 256 characters long. pub name: Option, /// 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. #[serde(rename="placementGroupType")] pub placement_group_type: Option, /// ID of the placement strategy assigned to this placement group. #[serde(rename="placementStrategyId")] pub placement_strategy_id: Option, /// Pricing schedule of this placement group. This field is required on insertion. #[serde(rename="pricingSchedule")] pub pricing_schedule: Option, /// 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. #[serde(rename="primaryPlacementId")] pub primary_placement_id: Option, /// Dimension value for the ID of the primary placement. This is a read-only, auto-generated field. #[serde(rename="primaryPlacementIdDimensionValue")] pub primary_placement_id_dimension_value: Option, /// 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. #[serde(rename="siteId")] pub site_id: Option, /// Dimension value for the ID of the site. This is a read-only, auto-generated field. #[serde(rename="siteIdDimensionValue")] pub site_id_dimension_value: Option, /// Subaccount ID of this placement group. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for PlacementGroup {} impl client::Resource for PlacementGroup {} impl client::ResponseResult for PlacementGroup {} /// Placement Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list placement groups](PlacementGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementGroupsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementGroupsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Placement group collection. #[serde(rename="placementGroups")] pub placement_groups: Option>, } impl client::ResponseResult for PlacementGroupsListResponse {} /// Placement Strategy List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list placement strategies](PlacementStrategyListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementStrategiesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategiesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Placement strategy collection. #[serde(rename="placementStrategies")] pub placement_strategies: Option>, } impl client::ResponseResult for PlacementStrategiesListResponse {} /// Contains properties of a placement strategy. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get placement strategies](PlacementStrategyGetCall) (response) /// * [insert placement strategies](PlacementStrategyInsertCall) (request|response) /// * [patch placement strategies](PlacementStrategyPatchCall) (request|response) /// * [update placement strategies](PlacementStrategyUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementStrategy { /// Account ID of this placement strategy.This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// ID of this placement strategy. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementStrategy". pub kind: Option, /// 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. pub name: Option, } impl client::RequestValue for PlacementStrategy {} impl client::ResponseResult for PlacementStrategy {} /// Placement Tag /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementTag { /// Placement ID #[serde(rename="placementId")] pub placement_id: Option, /// Tags generated for this placement. #[serde(rename="tagDatas")] pub tag_datas: Option>, } impl client::Part for PlacementTag {} /// Placement GenerateTags Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [generatetags placements](PlacementGeneratetagCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementsGenerateTagsResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsGenerateTagsResponse". pub kind: Option, /// Set of generated tags for the specified placements. #[serde(rename="placementTags")] pub placement_tags: Option>, } impl client::ResponseResult for PlacementsGenerateTagsResponse {} /// Placement List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list placements](PlacementListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlacementsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#placementsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Placement collection. pub placements: Option>, } impl client::ResponseResult for PlacementsListResponse {} /// Contains information about a platform type that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get platform types](PlatformTypeGetCall) (response) /// * [list platform types](PlatformTypeListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlatformType { /// ID of this platform type. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformType". pub kind: Option, /// Name of this platform type. pub name: Option, } impl client::Resource for PlatformType {} impl client::ResponseResult for PlatformType {} /// Platform Type List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list platform types](PlatformTypeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PlatformTypesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#platformTypesListResponse". pub kind: Option, /// Platform type collection. #[serde(rename="platformTypes")] pub platform_types: Option>, } impl client::ResponseResult for PlatformTypesListResponse {} /// Popup Window Properties. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PopupWindowProperties { /// Popup dimension for a creative. This is a read-only field. Applicable to the following creative types: all RICH_MEDIA and all VPAID pub dimension: Option, /// Upper-left corner coordinates of the popup window. Applicable if positionType is COORDINATES. pub offset: Option, /// Popup window position either centered or at specific coordinate. #[serde(rename="positionType")] pub position_type: Option, /// Whether to display the browser address bar. #[serde(rename="showAddressBar")] pub show_address_bar: Option, /// Whether to display the browser menu bar. #[serde(rename="showMenuBar")] pub show_menu_bar: Option, /// Whether to display the browser scroll bar. #[serde(rename="showScrollBar")] pub show_scroll_bar: Option, /// Whether to display the browser status bar. #[serde(rename="showStatusBar")] pub show_status_bar: Option, /// Whether to display the browser tool bar. #[serde(rename="showToolBar")] pub show_tool_bar: Option, /// Title of popup window. pub title: Option, } impl client::Part for PopupWindowProperties {} /// Contains information about a postal code that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get postal codes](PostalCodeGetCall) (response) /// * [list postal codes](PostalCodeListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostalCode { /// Postal code. This is equivalent to the id field. pub code: Option, /// Country code of the country to which this postal code belongs. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of the country to which this postal code belongs. #[serde(rename="countryDartId")] pub country_dart_id: Option, /// ID of this postal code. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCode". pub kind: Option, } impl client::Resource for PostalCode {} impl client::ResponseResult for PostalCode {} /// Postal Code List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list postal codes](PostalCodeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PostalCodesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#postalCodesListResponse". pub kind: Option, /// Postal code collection. #[serde(rename="postalCodes")] pub postal_codes: Option>, } impl client::ResponseResult for PostalCodesListResponse {} /// Pricing Information /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Pricing { /// Cap cost type of this inventory item. #[serde(rename="capCostType")] pub cap_cost_type: Option, /// End date of this inventory item. #[serde(rename="endDate")] pub end_date: Option, /// Flights of this inventory item. A flight (a.k.a. pricing period) represents the inventory item pricing information for a specific period of time. pub flights: Option>, /// 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. #[serde(rename="groupType")] pub group_type: Option, /// Pricing type of this inventory item. #[serde(rename="pricingType")] pub pricing_type: Option, /// Start date of this inventory item. #[serde(rename="startDate")] pub start_date: Option, } impl client::Part for Pricing {} /// Pricing Schedule /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PricingSchedule { /// Placement cap cost option. #[serde(rename="capCostOption")] pub cap_cost_option: Option, /// Whether cap costs are ignored by ad serving. #[serde(rename="disregardOverdelivery")] pub disregard_overdelivery: Option, /// 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. #[serde(rename="endDate")] pub end_date: Option, /// Whether this placement is flighted. If true, pricing periods will be computed automatically. pub flighted: Option, /// Floodlight activity ID associated with this placement. This field should be set when placement pricing type is set to PRICING_TYPE_CPA. #[serde(rename="floodlightActivityId")] pub floodlight_activity_id: Option, /// Pricing periods for this placement. #[serde(rename="pricingPeriods")] pub pricing_periods: Option>, /// Placement pricing type. This field is required on insertion. #[serde(rename="pricingType")] pub pricing_type: Option, /// 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. #[serde(rename="startDate")] pub start_date: Option, /// 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. #[serde(rename="testingStartDate")] pub testing_start_date: Option, } impl client::Part for PricingSchedule {} /// Pricing Period /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PricingSchedulePricingPeriod { /// 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. #[serde(rename="endDate")] pub end_date: Option, /// Comments for this pricing period. #[serde(rename="pricingComment")] pub pricing_comment: Option, /// Rate or cost of this pricing period in nanos (i.e., multipled by 1000000000). Acceptable values are 0 to 1000000000000000000, inclusive. #[serde(rename="rateOrCostNanos")] pub rate_or_cost_nanos: Option, /// 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. #[serde(rename="startDate")] pub start_date: Option, /// Units of this pricing period. Acceptable values are 0 to 10000000000, inclusive. pub units: Option, } impl client::Part for PricingSchedulePricingPeriod {} /// Contains properties of a Planning project. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get projects](ProjectGetCall) (response) /// * [list projects](ProjectListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Project { /// Account ID of this project. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this project. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Audience age group of this project. #[serde(rename="audienceAgeGroup")] pub audience_age_group: Option, /// Audience gender of this project. #[serde(rename="audienceGender")] pub audience_gender: Option, /// 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. pub budget: Option, /// Client billing code of this project. #[serde(rename="clientBillingCode")] pub client_billing_code: Option, /// Name of the project client. #[serde(rename="clientName")] pub client_name: Option, /// End date of the project. #[serde(rename="endDate")] pub end_date: Option, /// ID of this project. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#project". pub kind: Option, /// Information about the most recent modification of this project. #[serde(rename="lastModifiedInfo")] pub last_modified_info: Option, /// Name of this project. pub name: Option, /// Overview of this project. pub overview: Option, /// Start date of the project. #[serde(rename="startDate")] pub start_date: Option, /// Subaccount ID of this project. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Number of clicks that the advertiser is targeting. #[serde(rename="targetClicks")] pub target_clicks: Option, /// Number of conversions that the advertiser is targeting. #[serde(rename="targetConversions")] pub target_conversions: Option, /// CPA that the advertiser is targeting. #[serde(rename="targetCpaNanos")] pub target_cpa_nanos: Option, /// CPC that the advertiser is targeting. #[serde(rename="targetCpcNanos")] pub target_cpc_nanos: Option, /// vCPM from Active View that the advertiser is targeting. #[serde(rename="targetCpmActiveViewNanos")] pub target_cpm_active_view_nanos: Option, /// CPM that the advertiser is targeting. #[serde(rename="targetCpmNanos")] pub target_cpm_nanos: Option, /// Number of impressions that the advertiser is targeting. #[serde(rename="targetImpressions")] pub target_impressions: Option, } impl client::Resource for Project {} impl client::ResponseResult for Project {} /// Project List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list projects](ProjectListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ProjectsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#projectsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Project collection. pub projects: Option>, } impl client::ResponseResult for ProjectsListResponse {} /// Represents fields that are compatible to be selected for a report of type "REACH". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReachReportCompatibleFields { /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. pub dimensions: Option>, /// The kind of resource this is, in this case dfareporting#reachReportCompatibleFields. pub kind: Option, /// Metrics which are compatible to be selected in the "metricNames" section of the report. pub metrics: Option>, /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. #[serde(rename="pivotedActivityMetrics")] pub pivoted_activity_metrics: Option>, /// Metrics which are compatible to be selected in the "reachByFrequencyMetricNames" section of the report. #[serde(rename="reachByFrequencyMetrics")] pub reach_by_frequency_metrics: Option>, } impl client::Part for ReachReportCompatibleFields {} /// Represents a recipient. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Recipient { /// The delivery type for the recipient. #[serde(rename="deliveryType")] pub delivery_type: Option, /// The email address of the recipient. pub email: Option, /// The kind of resource this is, in this case dfareporting#recipient. pub kind: Option, } impl client::Part for Recipient {} /// Contains information about a region that can be targeted by ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list regions](RegionListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Region { /// Country code of the country to which this region belongs. #[serde(rename="countryCode")] pub country_code: Option, /// DART ID of the country to which this region belongs. #[serde(rename="countryDartId")] pub country_dart_id: Option, /// DART ID of this region. #[serde(rename="dartId")] pub dart_id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#region". pub kind: Option, /// Name of this region. pub name: Option, /// Region code. #[serde(rename="regionCode")] pub region_code: Option, } impl client::Resource for Region {} /// Region List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list regions](RegionListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RegionsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#regionsListResponse". pub kind: Option, /// Region collection. pub regions: Option>, } impl client::ResponseResult for RegionsListResponse {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get remarketing lists](RemarketingListGetCall) (response) /// * [insert remarketing lists](RemarketingListInsertCall) (request|response) /// * [list remarketing lists](RemarketingListListCall) (none) /// * [patch remarketing lists](RemarketingListPatchCall) (request|response) /// * [update remarketing lists](RemarketingListUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RemarketingList { /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. #[serde(rename="accountId")] pub account_id: Option, /// Whether this remarketing list is active. pub active: Option, /// Dimension value for the advertiser ID that owns this remarketing list. This is a required field. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Remarketing list description. pub description: Option, /// Remarketing list ID. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingList". pub kind: Option, /// Number of days that a user should remain in the remarketing list without an impression. Acceptable values are 1 to 540, inclusive. #[serde(rename="lifeSpan")] pub life_span: Option, /// Rule used to populate the remarketing list with users. #[serde(rename="listPopulationRule")] pub list_population_rule: Option, /// Number of users currently in the list. This is a read-only field. #[serde(rename="listSize")] pub list_size: Option, /// Product from which this remarketing list was originated. #[serde(rename="listSource")] pub list_source: Option, /// Name of the remarketing list. This is a required field. Must be no greater than 128 characters long. pub name: Option, /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for RemarketingList {} impl client::Resource for RemarketingList {} impl client::ResponseResult for RemarketingList {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get remarketing list shares](RemarketingListShareGetCall) (response) /// * [patch remarketing list shares](RemarketingListSharePatchCall) (request|response) /// * [update remarketing list shares](RemarketingListShareUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RemarketingListShare { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListShare". pub kind: Option, /// Remarketing list ID. This is a read-only, auto-generated field. #[serde(rename="remarketingListId")] pub remarketing_list_id: Option, /// Accounts that the remarketing list is shared with. #[serde(rename="sharedAccountIds")] pub shared_account_ids: Option>, /// Advertisers that the remarketing list is shared with. #[serde(rename="sharedAdvertiserIds")] pub shared_advertiser_ids: Option>, } impl client::RequestValue for RemarketingListShare {} impl client::Resource for RemarketingListShare {} impl client::ResponseResult for RemarketingListShare {} /// Remarketing list response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list remarketing lists](RemarketingListListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RemarketingListsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#remarketingListsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Remarketing list collection. #[serde(rename="remarketingLists")] pub remarketing_lists: Option>, } impl client::ResponseResult for RemarketingListsListResponse {} /// Represents a Report resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [compatible fields query reports](ReportCompatibleFieldQueryCall) (request) /// * [files get reports](ReportFileGetCall) (none) /// * [files list reports](ReportFileListCall) (none) /// * [delete reports](ReportDeleteCall) (none) /// * [get reports](ReportGetCall) (response) /// * [insert reports](ReportInsertCall) (request|response) /// * [list reports](ReportListCall) (none) /// * [patch reports](ReportPatchCall) (request|response) /// * [run reports](ReportRunCall) (none) /// * [update reports](ReportUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// The account ID to which this report belongs. #[serde(rename="accountId")] pub account_id: Option, /// The report criteria for a report of type "STANDARD". pub criteria: Option, /// The report criteria for a report of type "CROSS_DIMENSION_REACH". #[serde(rename="crossDimensionReachCriteria")] pub cross_dimension_reach_criteria: Option, /// The report's email delivery settings. pub delivery: Option, /// The eTag of this response for caching purposes. pub etag: Option, /// The filename used when generating report files for this report. #[serde(rename="fileName")] pub file_name: Option, /// The report criteria for a report of type "FLOODLIGHT". #[serde(rename="floodlightCriteria")] pub floodlight_criteria: Option, /// 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. pub format: Option, /// The unique ID identifying this report resource. pub id: Option, /// The kind of resource this is, in this case dfareporting#report. pub kind: Option, /// The timestamp (in milliseconds since epoch) of when this report was last modified. #[serde(rename="lastModifiedTime")] pub last_modified_time: Option, /// The name of the report. pub name: Option, /// The user profile id of the owner of this report. #[serde(rename="ownerProfileId")] pub owner_profile_id: Option, /// The report criteria for a report of type "PATH_TO_CONVERSION". #[serde(rename="pathToConversionCriteria")] pub path_to_conversion_criteria: Option, /// The report criteria for a report of type "REACH". #[serde(rename="reachCriteria")] pub reach_criteria: Option, /// 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". pub schedule: Option, /// The subaccount ID to which this report belongs if applicable. #[serde(rename="subAccountId")] pub sub_account_id: Option, /// The type of the report. #[serde(rename="type")] pub type_: Option, } impl client::RequestValue for Report {} impl client::Resource for Report {} impl client::ResponseResult for Report {} /// Represents fields that are compatible to be selected for a report of type "STANDARD". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCompatibleFields { /// Dimensions which are compatible to be selected in the "dimensionFilters" section of the report. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// Dimensions which are compatible to be selected in the "dimensions" section of the report. pub dimensions: Option>, /// The kind of resource this is, in this case dfareporting#reportCompatibleFields. pub kind: Option, /// Metrics which are compatible to be selected in the "metricNames" section of the report. pub metrics: Option>, /// Metrics which are compatible to be selected as activity metrics to pivot on in the "activities" section of the report. #[serde(rename="pivotedActivityMetrics")] pub pivoted_activity_metrics: Option>, } impl client::Part for ReportCompatibleFields {} /// Represents the list of reports. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list reports](ReportListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportList { /// The eTag of this response for caching purposes. pub etag: Option, /// The reports returned in this response. pub items: Option>, /// The kind of list this is, in this case dfareporting#reportList. pub kind: Option, /// 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. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl client::ResponseResult for ReportList {} /// Reporting Configuration /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportsConfiguration { /// 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. #[serde(rename="exposureToConversionEnabled")] pub exposure_to_conversion_enabled: Option, /// Default lookback windows for new advertisers in this account. #[serde(rename="lookbackConfiguration")] pub lookback_configuration: Option, /// Report generation time zone ID of this account. This is a required field that can only be changed by a superuser. /// Acceptable values are: /// /// - "1" for "America/New_York" /// - "2" for "Europe/London" /// - "3" for "Europe/Paris" /// - "4" for "Africa/Johannesburg" /// - "5" for "Asia/Jerusalem" /// - "6" for "Asia/Shanghai" /// - "7" for "Asia/Hong_Kong" /// - "8" for "Asia/Tokyo" /// - "9" for "Australia/Sydney" /// - "10" for "Asia/Dubai" /// - "11" for "America/Los_Angeles" /// - "12" for "Pacific/Auckland" /// - "13" for "America/Sao_Paulo" #[serde(rename="reportGenerationTimeZoneId")] pub report_generation_time_zone_id: Option, } impl client::Part for ReportsConfiguration {} /// Rich Media Exit Override. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RichMediaExitOverride { /// Click-through URL of this rich media exit override. Applicable if the enabled field is set to true. #[serde(rename="clickThroughUrl")] pub click_through_url: Option, /// Whether to use the clickThroughUrl. If false, the creative-level exit will be used. pub enabled: Option, /// ID for the override to refer to a specific exit in the creative. #[serde(rename="exitId")] pub exit_id: Option, } impl client::Part for RichMediaExitOverride {} /// A rule associates an asset with a targeting template for asset-level targeting. Applicable to INSTREAM_VIDEO creatives. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Rule { /// A creativeAssets[].id. This should refer to one of the parent assets in this creative. This is a required field. #[serde(rename="assetId")] pub asset_id: Option, /// A user-friendly name for this rule. This is a required field. pub name: Option, /// 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. #[serde(rename="targetingTemplateId")] pub targeting_template_id: Option, } impl client::Part for Rule {} /// Contains properties of a site. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get sites](SiteGetCall) (response) /// * [insert sites](SiteInsertCall) (request|response) /// * [list sites](SiteListCall) (none) /// * [patch sites](SitePatchCall) (request|response) /// * [update sites](SiteUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Site { /// Account ID of this site. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// Whether this site is approved. pub approved: Option, /// Directory site associated with this site. This is a required field that is read-only after insertion. #[serde(rename="directorySiteId")] pub directory_site_id: Option, /// Dimension value for the ID of the directory site. This is a read-only, auto-generated field. #[serde(rename="directorySiteIdDimensionValue")] pub directory_site_id_dimension_value: Option, /// ID of this site. This is a read-only, auto-generated field. pub id: Option, /// Dimension value for the ID of this site. This is a read-only, auto-generated field. #[serde(rename="idDimensionValue")] pub id_dimension_value: Option, /// Key name of this site. This is a read-only, auto-generated field. #[serde(rename="keyName")] pub key_name: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#site". pub kind: Option, /// 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. pub name: Option, /// Site contacts. #[serde(rename="siteContacts")] pub site_contacts: Option>, /// Site-wide settings. #[serde(rename="siteSettings")] pub site_settings: Option, /// Subaccount ID of this site. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for Site {} impl client::Resource for Site {} impl client::ResponseResult for Site {} /// Site Contact /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteContact { /// Address of this site contact. pub address: Option, /// Site contact type. #[serde(rename="contactType")] pub contact_type: Option, /// Email address of this site contact. This is a required field. pub email: Option, /// First name of this site contact. #[serde(rename="firstName")] pub first_name: Option, /// ID of this site contact. This is a read-only, auto-generated field. pub id: Option, /// Last name of this site contact. #[serde(rename="lastName")] pub last_name: Option, /// Primary phone number of this site contact. pub phone: Option, /// Title or designation of this site contact. pub title: Option, } impl client::Part for SiteContact {} /// Site Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SiteSettings { /// Whether active view creatives are disabled for this site. #[serde(rename="activeViewOptOut")] pub active_view_opt_out: Option, /// 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. #[serde(rename="adBlockingOptOut")] pub ad_blocking_opt_out: Option, /// Site-wide creative settings. #[serde(rename="creativeSettings")] pub creative_settings: Option, /// Whether new cookies are disabled for this site. #[serde(rename="disableNewCookie")] pub disable_new_cookie: Option, /// Lookback window settings for this site. #[serde(rename="lookbackConfiguration")] pub lookback_configuration: Option, /// Configuration settings for dynamic and image floodlight tags. #[serde(rename="tagSetting")] pub tag_setting: Option, /// 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. #[serde(rename="videoActiveViewOptOutTemplate")] pub video_active_view_opt_out_template: Option, /// 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). /// /// Note: Flash is no longer supported. This field now defaults to HTML5 when the following values are provided: FLASH, BOTH. #[serde(rename="vpaidAdapterChoiceTemplate")] pub vpaid_adapter_choice_template: Option, } impl client::Part for SiteSettings {} /// Site List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list sites](SiteListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SitesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sitesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Site collection. pub sites: Option>, } impl client::ResponseResult for SitesListResponse {} /// Represents the dimensions of ads, placements, creatives, or creative assets. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get sizes](SizeGetCall) (response) /// * [insert sizes](SizeInsertCall) (request|response) /// * [list sizes](SizeListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Size { /// Height of this size. Acceptable values are 0 to 32767, inclusive. pub height: Option, /// IAB standard size. This is a read-only, auto-generated field. pub iab: Option, /// ID of this size. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#size". pub kind: Option, /// Width of this size. Acceptable values are 0 to 32767, inclusive. pub width: Option, } impl client::RequestValue for Size {} impl client::Resource for Size {} impl client::ResponseResult for Size {} /// Size List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list sizes](SizeListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SizesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#sizesListResponse". pub kind: Option, /// Size collection. pub sizes: Option>, } impl client::ResponseResult for SizesListResponse {} /// Skippable Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SkippableSetting { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#skippableSetting". pub kind: Option, /// Amount of time to play videos served to this placement before counting a view. Applicable when skippable is true. #[serde(rename="progressOffset")] pub progress_offset: Option, /// Amount of time to play videos served to this placement before the skip button should appear. Applicable when skippable is true. #[serde(rename="skipOffset")] pub skip_offset: Option, /// Whether the user can skip creatives served to this placement. pub skippable: Option, } impl client::Part for SkippableSetting {} /// Represents a sorted dimension. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SortedDimension { /// The kind of resource this is, in this case dfareporting#sortedDimension. pub kind: Option, /// The name of the dimension. pub name: Option, /// An optional sort order for the dimension column. #[serde(rename="sortOrder")] pub sort_order: Option, } impl client::Part for SortedDimension {} /// Contains properties of a Campaign Manager subaccount. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get subaccounts](SubaccountGetCall) (response) /// * [insert subaccounts](SubaccountInsertCall) (request|response) /// * [list subaccounts](SubaccountListCall) (none) /// * [patch subaccounts](SubaccountPatchCall) (request|response) /// * [update subaccounts](SubaccountUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Subaccount { /// ID of the account that contains this subaccount. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// IDs of the available user role permissions for this subaccount. #[serde(rename="availablePermissionIds")] pub available_permission_ids: Option>, /// ID of this subaccount. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccount". pub kind: Option, /// 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. pub name: Option, } impl client::RequestValue for Subaccount {} impl client::Resource for Subaccount {} impl client::ResponseResult for Subaccount {} /// Subaccount List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list subaccounts](SubaccountListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct SubaccountsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#subaccountsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Subaccount collection. pub subaccounts: Option>, } impl client::ResponseResult for SubaccountsListResponse {} /// Placement Tag Data /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TagData { /// Ad associated with this placement tag. Applicable only when format is PLACEMENT_TAG_TRACKING. #[serde(rename="adId")] pub ad_id: Option, /// Tag string to record a click. #[serde(rename="clickTag")] pub click_tag: Option, /// Creative associated with this placement tag. Applicable only when format is PLACEMENT_TAG_TRACKING. #[serde(rename="creativeId")] pub creative_id: Option, /// TagData tag format of this tag. pub format: Option, /// Tag string for serving an ad. #[serde(rename="impressionTag")] pub impression_tag: Option, } impl client::Part for TagData {} /// Tag Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TagSetting { /// 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. #[serde(rename="additionalKeyValues")] pub additional_key_values: Option, /// Whether static landing page URLs should be included in the tags. This setting applies only to placements. #[serde(rename="includeClickThroughUrls")] pub include_click_through_urls: Option, /// Whether click-tracking string should be included in the tags. #[serde(rename="includeClickTracking")] pub include_click_tracking: Option, /// 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. #[serde(rename="keywordOption")] pub keyword_option: Option, } impl client::Part for TagSetting {} /// Dynamic and Image Tag Settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TagSettings { /// Whether dynamic floodlight tags are enabled. #[serde(rename="dynamicTagEnabled")] pub dynamic_tag_enabled: Option, /// Whether image tags are enabled. #[serde(rename="imageTagEnabled")] pub image_tag_enabled: Option, } impl client::Part for TagSettings {} /// Target Window. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetWindow { /// User-entered value. #[serde(rename="customHtml")] pub custom_html: Option, /// Type of browser window for which the backup image of the flash creative can be displayed. #[serde(rename="targetWindowOption")] pub target_window_option: Option, } impl client::Part for TargetWindow {} /// 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. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get targetable remarketing lists](TargetableRemarketingListGetCall) (response) /// * [list targetable remarketing lists](TargetableRemarketingListListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetableRemarketingList { /// Account ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. #[serde(rename="accountId")] pub account_id: Option, /// Whether this targetable remarketing list is active. pub active: Option, /// Dimension value for the advertiser ID that owns this targetable remarketing list. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Targetable remarketing list description. pub description: Option, /// Targetable remarketing list ID. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingList". pub kind: Option, /// Number of days that a user should remain in the targetable remarketing list without an impression. #[serde(rename="lifeSpan")] pub life_span: Option, /// Number of users currently in the list. This is a read-only field. #[serde(rename="listSize")] pub list_size: Option, /// Product from which this targetable remarketing list was originated. #[serde(rename="listSource")] pub list_source: Option, /// Name of the targetable remarketing list. Is no greater than 128 characters long. pub name: Option, /// Subaccount ID of this remarketing list. This is a read-only, auto-generated field that is only returned in GET requests. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::Resource for TargetableRemarketingList {} impl client::ResponseResult for TargetableRemarketingList {} /// Targetable remarketing list response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list targetable remarketing lists](TargetableRemarketingListListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetableRemarketingListsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetableRemarketingListsListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Targetable remarketing list collection. #[serde(rename="targetableRemarketingLists")] pub targetable_remarketing_lists: Option>, } impl client::ResponseResult for TargetableRemarketingListsListResponse {} /// Contains properties of a targeting template. A targeting template encapsulates targeting information which can be reused across multiple ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get targeting templates](TargetingTemplateGetCall) (response) /// * [insert targeting templates](TargetingTemplateInsertCall) (request|response) /// * [list targeting templates](TargetingTemplateListCall) (none) /// * [patch targeting templates](TargetingTemplatePatchCall) (request|response) /// * [update targeting templates](TargetingTemplateUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetingTemplate { /// Account ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert. #[serde(rename="accountId")] pub account_id: Option, /// Advertiser ID of this targeting template. This is a required field on insert and is read-only after insert. #[serde(rename="advertiserId")] pub advertiser_id: Option, /// Dimension value for the ID of the advertiser. This is a read-only, auto-generated field. #[serde(rename="advertiserIdDimensionValue")] pub advertiser_id_dimension_value: Option, /// Time and day targeting criteria. #[serde(rename="dayPartTargeting")] pub day_part_targeting: Option, /// Geographical targeting criteria. #[serde(rename="geoTargeting")] pub geo_targeting: Option, /// ID of this targeting template. This is a read-only, auto-generated field. pub id: Option, /// Key-value targeting criteria. #[serde(rename="keyValueTargetingExpression")] pub key_value_targeting_expression: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplate". pub kind: Option, /// Language targeting criteria. #[serde(rename="languageTargeting")] pub language_targeting: Option, /// Remarketing list targeting criteria. #[serde(rename="listTargetingExpression")] pub list_targeting_expression: Option, /// Name of this targeting template. This field is required. It must be less than 256 characters long and unique within an advertiser. pub name: Option, /// Subaccount ID of this targeting template. This field, if left unset, will be auto-generated on insert and is read-only after insert. #[serde(rename="subaccountId")] pub subaccount_id: Option, /// Technology platform targeting criteria. #[serde(rename="technologyTargeting")] pub technology_targeting: Option, } impl client::RequestValue for TargetingTemplate {} impl client::Resource for TargetingTemplate {} impl client::ResponseResult for TargetingTemplate {} /// Targeting Template List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list targeting templates](TargetingTemplateListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TargetingTemplatesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#targetingTemplatesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Targeting template collection. #[serde(rename="targetingTemplates")] pub targeting_templates: Option>, } impl client::ResponseResult for TargetingTemplatesListResponse {} /// Technology Targeting. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TechnologyTargeting { /// 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. pub browsers: Option>, /// 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. #[serde(rename="connectionTypes")] pub connection_types: Option>, /// 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. #[serde(rename="mobileCarriers")] pub mobile_carriers: Option>, /// 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. #[serde(rename="operatingSystemVersions")] pub operating_system_versions: Option>, /// 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. #[serde(rename="operatingSystems")] pub operating_systems: Option>, /// 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. #[serde(rename="platformTypes")] pub platform_types: Option>, } impl client::Part for TechnologyTargeting {} /// Third Party Authentication Token /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ThirdPartyAuthenticationToken { /// Name of the third-party authentication token. pub name: Option, /// Value of the third-party authentication token. This is a read-only, auto-generated field. pub value: Option, } impl client::Part for ThirdPartyAuthenticationToken {} /// Third-party Tracking URL. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ThirdPartyTrackingUrl { /// Third-party URL type for in-stream video and in-stream audio creatives. #[serde(rename="thirdPartyUrlType")] pub third_party_url_type: Option, /// URL for the specified third-party URL type. pub url: Option, } impl client::Part for ThirdPartyTrackingUrl {} /// Transcode Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TranscodeSetting { /// Whitelist of video formats to be served to this placement. Set this list to null or empty to serve all video formats. #[serde(rename="enabledVideoFormats")] pub enabled_video_formats: Option>, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#transcodeSetting". pub kind: Option, } impl client::Part for TranscodeSetting {} /// A Universal Ad ID as per the VAST 4.0 spec. Applicable to the following creative types: INSTREAM_AUDIO, INSTREAM_VIDEO and VPAID. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UniversalAdId { /// Registry used for the Ad ID value. pub registry: Option, /// 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. pub value: Option, } impl client::Part for UniversalAdId {} /// User Defined Variable configuration. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserDefinedVariableConfiguration { /// Data type for the variable. This is a required field. #[serde(rename="dataType")] pub data_type: Option, /// 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: ""<>". #[serde(rename="reportName")] pub report_name: Option, /// Variable name in the tag. This is a required field. #[serde(rename="variableType")] pub variable_type: Option, } impl client::Part for UserDefinedVariableConfiguration {} /// Represents a UserProfile resource. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get user profiles](UserProfileGetCall) (response) /// * [list user profiles](UserProfileListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserProfile { /// The account ID to which this profile belongs. #[serde(rename="accountId")] pub account_id: Option, /// The account name this profile belongs to. #[serde(rename="accountName")] pub account_name: Option, /// The eTag of this response for caching purposes. pub etag: Option, /// The kind of resource this is, in this case dfareporting#userProfile. pub kind: Option, /// The unique ID of the user profile. #[serde(rename="profileId")] pub profile_id: Option, /// The sub account ID this profile belongs to if applicable. #[serde(rename="subAccountId")] pub sub_account_id: Option, /// The sub account name this profile belongs to if applicable. #[serde(rename="subAccountName")] pub sub_account_name: Option, /// The user name. #[serde(rename="userName")] pub user_name: Option, } impl client::Resource for UserProfile {} impl client::ResponseResult for UserProfile {} /// Represents the list of user profiles. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list user profiles](UserProfileListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserProfileList { /// The eTag of this response for caching purposes. pub etag: Option, /// The user profiles returned in this response. pub items: Option>, /// The kind of list this is, in this case dfareporting#userProfileList. pub kind: Option, } impl client::ResponseResult for UserProfileList {} /// Contains properties of auser role, which is used to manage user access. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [delete user roles](UserRoleDeleteCall) (none) /// * [get user roles](UserRoleGetCall) (response) /// * [insert user roles](UserRoleInsertCall) (request|response) /// * [list user roles](UserRoleListCall) (none) /// * [patch user roles](UserRolePatchCall) (request|response) /// * [update user roles](UserRoleUpdateCall) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRole { /// Account ID of this user role. This is a read-only field that can be left blank. #[serde(rename="accountId")] pub account_id: Option, /// 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. #[serde(rename="defaultUserRole")] pub default_user_role: Option, /// ID of this user role. This is a read-only, auto-generated field. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRole". pub kind: Option, /// 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. pub name: Option, /// ID of the user role that this user role is based on or copied from. This is a required field. #[serde(rename="parentUserRoleId")] pub parent_user_role_id: Option, /// List of permissions associated with this user role. pub permissions: Option>, /// Subaccount ID of this user role. This is a read-only field that can be left blank. #[serde(rename="subaccountId")] pub subaccount_id: Option, } impl client::RequestValue for UserRole {} impl client::Resource for UserRole {} impl client::ResponseResult for UserRole {} /// Contains properties of a user role permission. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get user role permissions](UserRolePermissionGetCall) (response) /// * [list user role permissions](UserRolePermissionListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolePermission { /// Levels of availability for a user role permission. pub availability: Option, /// ID of this user role permission. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermission". pub kind: Option, /// Name of this user role permission. pub name: Option, /// ID of the permission group that this user role permission belongs to. #[serde(rename="permissionGroupId")] pub permission_group_id: Option, } impl client::Resource for UserRolePermission {} impl client::ResponseResult for UserRolePermission {} /// Represents a grouping of related user role permissions. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get user role permission groups](UserRolePermissionGroupGetCall) (response) /// * [list user role permission groups](UserRolePermissionGroupListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolePermissionGroup { /// ID of this user role permission. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroup". pub kind: Option, /// Name of this user role permission group. pub name: Option, } impl client::Resource for UserRolePermissionGroup {} impl client::ResponseResult for UserRolePermissionGroup {} /// User Role Permission Group List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list user role permission groups](UserRolePermissionGroupListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolePermissionGroupsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionGroupsListResponse". pub kind: Option, /// User role permission group collection. #[serde(rename="userRolePermissionGroups")] pub user_role_permission_groups: Option>, } impl client::ResponseResult for UserRolePermissionGroupsListResponse {} /// User Role Permission List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list user role permissions](UserRolePermissionListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolePermissionsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolePermissionsListResponse". pub kind: Option, /// User role permission collection. #[serde(rename="userRolePermissions")] pub user_role_permissions: Option>, } impl client::ResponseResult for UserRolePermissionsListResponse {} /// User Role List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list user roles](UserRoleListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UserRolesListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#userRolesListResponse". pub kind: Option, /// Pagination token to be used for the next list operation. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// User role collection. #[serde(rename="userRoles")] pub user_roles: Option>, } impl client::ResponseResult for UserRolesListResponse {} /// Contains information about supported video formats. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get video formats](VideoFormatGetCall) (response) /// * [list video formats](VideoFormatListCall) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoFormat { /// File type of the video format. #[serde(rename="fileType")] pub file_type: Option, /// ID of the video format. pub id: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoFormat". pub kind: Option, /// The resolution of this video format. pub resolution: Option, /// The target bit rate of this video format. #[serde(rename="targetBitRate")] pub target_bit_rate: Option, } impl client::Resource for VideoFormat {} impl client::ResponseResult for VideoFormat {} /// Video Format List Response /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list video formats](VideoFormatListCall) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoFormatsListResponse { /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoFormatsListResponse". pub kind: Option, /// Video format collection. #[serde(rename="videoFormats")] pub video_formats: Option>, } impl client::ResponseResult for VideoFormatsListResponse {} /// Video Offset /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoOffset { /// Duration, as a percentage of video duration. Do not set when offsetSeconds is set. Acceptable values are 0 to 100, inclusive. #[serde(rename="offsetPercentage")] pub offset_percentage: Option, /// Duration, in seconds. Do not set when offsetPercentage is set. Acceptable values are 0 to 86399, inclusive. #[serde(rename="offsetSeconds")] pub offset_seconds: Option, } impl client::Part for VideoOffset {} /// Video Settings /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct VideoSettings { /// Settings for the companion creatives of video creatives served to this placement. #[serde(rename="companionSettings")] pub companion_settings: Option, /// Identifies what kind of resource this is. Value: the fixed string "dfareporting#videoSettings". pub kind: Option, /// Orientation of a video placement. If this value is set, placement will return assets matching the specified orientation. pub orientation: Option, /// Settings for the skippability of video creatives served to this placement. If this object is provided, the creative-level skippable settings will be overridden. #[serde(rename="skippableSettings")] pub skippable_settings: Option, /// Settings for the transcodes of video creatives served to this placement. If this object is provided, the creative-level transcode settings will be overridden. #[serde(rename="transcodeSettings")] pub transcode_settings: Option, } impl client::Part for VideoSettings {} /// The URLs where the completed report file can be downloaded. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FileUrls { /// The URL for downloading the report data through the API. #[serde(rename="apiUrl")] pub api_url: Option, /// The URL for downloading the report data through a browser. #[serde(rename="browserUrl")] pub browser_url: Option, } impl client::NestedType for FileUrls {} impl client::Part for FileUrls {} /// The report criteria for a report of type "STANDARD". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCriteria { /// Activity group. pub activities: Option, /// Custom Rich Media Events group. #[serde(rename="customRichMediaEvents")] pub custom_rich_media_events: Option, /// The date range for which this report should be run. #[serde(rename="dateRange")] pub date_range: Option, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// The list of standard dimensions the report should include. pub dimensions: Option>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] pub metric_names: Option>, } impl client::NestedType for ReportCriteria {} impl client::Part for ReportCriteria {} /// The report criteria for a report of type "CROSS_DIMENSION_REACH". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportCrossDimensionReachCriteria { /// The list of dimensions the report should include. pub breakdown: Option>, /// The date range this report should be run for. #[serde(rename="dateRange")] pub date_range: Option, /// The dimension option. pub dimension: Option, /// The list of filters on which dimensions are filtered. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] pub metric_names: Option>, /// The list of names of overlap metrics the report should include. #[serde(rename="overlapMetricNames")] pub overlap_metric_names: Option>, /// Whether the report is pivoted or not. Defaults to true. pub pivoted: Option, } impl client::NestedType for ReportCrossDimensionReachCriteria {} impl client::Part for ReportCrossDimensionReachCriteria {} /// The report's email delivery settings. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportDelivery { /// Whether the report should be emailed to the report owner. #[serde(rename="emailOwner")] pub email_owner: Option, /// The type of delivery for the owner to receive, if enabled. #[serde(rename="emailOwnerDeliveryType")] pub email_owner_delivery_type: Option, /// The message to be sent with each email. pub message: Option, /// The list of recipients to which to email the report. pub recipients: Option>, } impl client::NestedType for ReportDelivery {} impl client::Part for ReportDelivery {} /// The report criteria for a report of type "FLOODLIGHT". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportFloodlightCriteria { /// The list of custom rich media events to include. #[serde(rename="customRichMediaEvents")] pub custom_rich_media_events: Option>, /// The date range this report should be run for. #[serde(rename="dateRange")] pub date_range: Option, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// The list of dimensions the report should include. pub dimensions: Option>, /// 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'. #[serde(rename="floodlightConfigId")] pub floodlight_config_id: Option, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] pub metric_names: Option>, /// The properties of the report. #[serde(rename="reportProperties")] pub report_properties: Option, } impl client::NestedType for ReportFloodlightCriteria {} impl client::Part for ReportFloodlightCriteria {} /// The properties of the report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportFloodlightCriteriaReportProperties { /// Include conversions that have no cookie, but do have an exposure path. #[serde(rename="includeAttributedIPConversions")] pub include_attributed_ip_conversions: Option, /// 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. #[serde(rename="includeUnattributedCookieConversions")] pub include_unattributed_cookie_conversions: Option, /// 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. #[serde(rename="includeUnattributedIPConversions")] pub include_unattributed_ip_conversions: Option, } impl client::NestedType for ReportFloodlightCriteriaReportProperties {} impl client::Part for ReportFloodlightCriteriaReportProperties {} /// The report criteria for a report of type "PATH_TO_CONVERSION". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportPathToConversionCriteria { /// The list of 'dfa:activity' values to filter on. #[serde(rename="activityFilters")] pub activity_filters: Option>, /// The list of conversion dimensions the report should include. #[serde(rename="conversionDimensions")] pub conversion_dimensions: Option>, /// The list of custom floodlight variables the report should include. #[serde(rename="customFloodlightVariables")] pub custom_floodlight_variables: Option>, /// The list of custom rich media events to include. #[serde(rename="customRichMediaEvents")] pub custom_rich_media_events: Option>, /// The date range this report should be run for. #[serde(rename="dateRange")] pub date_range: Option, /// 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'. #[serde(rename="floodlightConfigId")] pub floodlight_config_id: Option, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] pub metric_names: Option>, /// The list of per interaction dimensions the report should include. #[serde(rename="perInteractionDimensions")] pub per_interaction_dimensions: Option>, /// The properties of the report. #[serde(rename="reportProperties")] pub report_properties: Option, } impl client::NestedType for ReportPathToConversionCriteria {} impl client::Part for ReportPathToConversionCriteria {} /// The properties of the report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportPathToConversionCriteriaReportProperties { /// 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. #[serde(rename="clicksLookbackWindow")] pub clicks_lookback_window: Option, /// 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. #[serde(rename="impressionsLookbackWindow")] pub impressions_lookback_window: Option, /// Deprecated: has no effect. #[serde(rename="includeAttributedIPConversions")] pub include_attributed_ip_conversions: Option, /// 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. #[serde(rename="includeUnattributedCookieConversions")] pub include_unattributed_cookie_conversions: Option, /// 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. #[serde(rename="includeUnattributedIPConversions")] pub include_unattributed_ip_conversions: Option, /// 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. #[serde(rename="maximumClickInteractions")] pub maximum_click_interactions: Option, /// 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. #[serde(rename="maximumImpressionInteractions")] pub maximum_impression_interactions: Option, /// The maximum amount of time that can take place between interactions (clicks or impressions) by the same user. Valid values: 1-90. #[serde(rename="maximumInteractionGap")] pub maximum_interaction_gap: Option, /// Enable pivoting on interaction path. #[serde(rename="pivotOnInteractionPath")] pub pivot_on_interaction_path: Option, } impl client::NestedType for ReportPathToConversionCriteriaReportProperties {} impl client::Part for ReportPathToConversionCriteriaReportProperties {} /// The report criteria for a report of type "REACH". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportReachCriteria { /// Activity group. pub activities: Option, /// Custom Rich Media Events group. #[serde(rename="customRichMediaEvents")] pub custom_rich_media_events: Option, /// The date range this report should be run for. #[serde(rename="dateRange")] pub date_range: Option, /// The list of filters on which dimensions are filtered. /// Filters for different dimensions are ANDed, filters for the same dimension are grouped together and ORed. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// The list of dimensions the report should include. pub dimensions: Option>, /// 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. #[serde(rename="enableAllDimensionCombinations")] pub enable_all_dimension_combinations: Option, /// The list of names of metrics the report should include. #[serde(rename="metricNames")] pub metric_names: Option>, /// The list of names of Reach By Frequency metrics the report should include. #[serde(rename="reachByFrequencyMetricNames")] pub reach_by_frequency_metric_names: Option>, } impl client::NestedType for ReportReachCriteria {} impl client::Part for ReportReachCriteria {} /// 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". /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportSchedule { /// Whether the schedule is active or not. Must be set to either true or false. pub active: Option, /// 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". pub every: Option, /// The expiration date when the scheduled report stops running. #[serde(rename="expirationDate")] pub expiration_date: Option, /// The interval for which the report is repeated. Note: /// - "DAILY" also requires field "every" to be set. /// - "WEEKLY" also requires fields "every" and "repeatsOnWeekDays" to be set. /// - "MONTHLY" also requires fields "every" and "runsOnDayOfMonth" to be set. pub repeats: Option, /// List of week days "WEEKLY" on which scheduled reports should run. #[serde(rename="repeatsOnWeekDays")] pub repeats_on_week_days: Option>, /// 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. /// 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. #[serde(rename="runsOnDayOfMonth")] pub runs_on_day_of_month: Option, /// Start date of date range for which scheduled reports should be run. #[serde(rename="startDate")] pub start_date: Option, } impl client::NestedType for ReportSchedule {} impl client::Part for ReportSchedule {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *accountActiveAdSummary* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` /// // to build up your call. /// let rb = hub.account_active_ad_summaries(); /// # } /// ``` pub struct AccountActiveAdSummaryMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AccountActiveAdSummaryMethods<'a, S> {} impl<'a, S> AccountActiveAdSummaryMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets the account's active ad summary by account ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `summaryAccountId` - Account ID. pub fn get(&self, profile_id: &str, summary_account_id: &str) -> AccountActiveAdSummaryGetCall<'a, S> { AccountActiveAdSummaryGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _summary_account_id: summary_account_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *accountPermissionGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.account_permission_groups(); /// # } /// ``` pub struct AccountPermissionGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AccountPermissionGroupMethods<'a, S> {} impl<'a, S> AccountPermissionGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one account permission group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Account permission group ID. pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGroupGetCall<'a, S> { AccountPermissionGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves the list of account permission groups. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AccountPermissionGroupListCall<'a, S> { AccountPermissionGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *accountPermission* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.account_permissions(); /// # } /// ``` pub struct AccountPermissionMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AccountPermissionMethods<'a, S> {} impl<'a, S> AccountPermissionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one account permission by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Account permission ID. pub fn get(&self, profile_id: &str, id: &str) -> AccountPermissionGetCall<'a, S> { AccountPermissionGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves the list of account permissions. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AccountPermissionListCall<'a, S> { AccountPermissionListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *accountUserProfile* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.account_user_profiles(); /// # } /// ``` pub struct AccountUserProfileMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AccountUserProfileMethods<'a, S> {} impl<'a, S> AccountUserProfileMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one account user profile by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - User profile ID. pub fn get(&self, profile_id: &str, id: &str) -> AccountUserProfileGetCall<'a, S> { AccountUserProfileGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new account user profile. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileInsertCall<'a, S> { AccountUserProfileInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of account user profiles, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AccountUserProfileListCall<'a, S> { AccountUserProfileListCall { hub: self.hub, _profile_id: profile_id.to_string(), _user_role_id: Default::default(), _subaccount_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing account user profile. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - User profile ID. pub fn patch(&self, request: AccountUserProfile, profile_id: &str, id: &str) -> AccountUserProfilePatchCall<'a, S> { AccountUserProfilePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing account user profile. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: AccountUserProfile, profile_id: &str) -> AccountUserProfileUpdateCall<'a, S> { AccountUserProfileUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *account* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.accounts(); /// # } /// ``` pub struct AccountMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AccountMethods<'a, S> {} impl<'a, S> AccountMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one account by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Account ID. pub fn get(&self, profile_id: &str, id: &str) -> AccountGetCall<'a, S> { AccountGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves the list of accounts, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AccountListCall<'a, S> { AccountListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing account. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Account ID. pub fn patch(&self, request: Account, profile_id: &str, id: &str) -> AccountPatchCall<'a, S> { AccountPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing account. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Account, profile_id: &str) -> AccountUpdateCall<'a, S> { AccountUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *ad* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.ads(); /// # } /// ``` pub struct AdMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AdMethods<'a, S> {} impl<'a, S> AdMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one ad by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Ad ID. pub fn get(&self, profile_id: &str, id: &str) -> AdGetCall<'a, S> { AdGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new ad. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Ad, profile_id: &str) -> AdInsertCall<'a, S> { AdInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of ads, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AdListCall<'a, S> { AdListCall { hub: self.hub, _profile_id: profile_id.to_string(), _type_: Default::default(), _ssl_required: Default::default(), _ssl_compliant: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _size_ids: Default::default(), _search_string: Default::default(), _remarketing_list_ids: Default::default(), _placement_ids: Default::default(), _page_token: Default::default(), _overridden_event_tag_id: Default::default(), _max_results: Default::default(), _landing_page_ids: Default::default(), _ids: Default::default(), _dynamic_click_tracker: Default::default(), _creative_optimization_configuration_ids: Default::default(), _creative_ids: Default::default(), _compatibility: Default::default(), _campaign_ids: Default::default(), _audience_segment_ids: Default::default(), _archived: Default::default(), _advertiser_id: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing ad. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Ad ID. pub fn patch(&self, request: Ad, profile_id: &str, id: &str) -> AdPatchCall<'a, S> { AdPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing ad. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Ad, profile_id: &str) -> AdUpdateCall<'a, S> { AdUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *advertiserGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.advertiser_groups(); /// # } /// ``` pub struct AdvertiserGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AdvertiserGroupMethods<'a, S> {} impl<'a, S> AdvertiserGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing advertiser group. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser group ID. pub fn delete(&self, profile_id: &str, id: &str) -> AdvertiserGroupDeleteCall<'a, S> { AdvertiserGroupDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one advertiser group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser group ID. pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGroupGetCall<'a, S> { AdvertiserGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new advertiser group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupInsertCall<'a, S> { AdvertiserGroupInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of advertiser groups, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AdvertiserGroupListCall<'a, S> { AdvertiserGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing advertiser group. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser group ID. pub fn patch(&self, request: AdvertiserGroup, profile_id: &str, id: &str) -> AdvertiserGroupPatchCall<'a, S> { AdvertiserGroupPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing advertiser group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: AdvertiserGroup, profile_id: &str) -> AdvertiserGroupUpdateCall<'a, S> { AdvertiserGroupUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *advertiserLandingPage* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.advertiser_landing_pages(); /// # } /// ``` pub struct AdvertiserLandingPageMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AdvertiserLandingPageMethods<'a, S> {} impl<'a, S> AdvertiserLandingPageMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one landing page by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Landing page ID. pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserLandingPageGetCall<'a, S> { AdvertiserLandingPageGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new landing page. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: LandingPage, profile_id: &str) -> AdvertiserLandingPageInsertCall<'a, S> { AdvertiserLandingPageInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of landing pages. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AdvertiserLandingPageListCall<'a, S> { AdvertiserLandingPageListCall { hub: self.hub, _profile_id: profile_id.to_string(), _subaccount_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _campaign_ids: Default::default(), _archived: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing landing page. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Landing page ID. pub fn patch(&self, request: LandingPage, profile_id: &str, id: &str) -> AdvertiserLandingPagePatchCall<'a, S> { AdvertiserLandingPagePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing landing page. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: LandingPage, profile_id: &str) -> AdvertiserLandingPageUpdateCall<'a, S> { AdvertiserLandingPageUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *advertiser* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.advertisers(); /// # } /// ``` pub struct AdvertiserMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for AdvertiserMethods<'a, S> {} impl<'a, S> AdvertiserMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one advertiser by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser ID. pub fn get(&self, profile_id: &str, id: &str) -> AdvertiserGetCall<'a, S> { AdvertiserGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new advertiser. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Advertiser, profile_id: &str) -> AdvertiserInsertCall<'a, S> { AdvertiserInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of advertisers, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> AdvertiserListCall<'a, S> { AdvertiserListCall { hub: self.hub, _profile_id: profile_id.to_string(), _subaccount_id: Default::default(), _status: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _only_parent: Default::default(), _max_results: Default::default(), _include_advertisers_without_groups_only: Default::default(), _ids: Default::default(), _floodlight_configuration_ids: Default::default(), _advertiser_group_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing advertiser. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Advertiser ID. pub fn patch(&self, request: Advertiser, profile_id: &str, id: &str) -> AdvertiserPatchCall<'a, S> { AdvertiserPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing advertiser. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Advertiser, profile_id: &str) -> AdvertiserUpdateCall<'a, S> { AdvertiserUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *browser* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.browsers(); /// # } /// ``` pub struct BrowserMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for BrowserMethods<'a, S> {} impl<'a, S> BrowserMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a list of browsers. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> BrowserListCall<'a, S> { BrowserListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *campaignCreativeAssociation* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.campaign_creative_associations(); /// # } /// ``` pub struct CampaignCreativeAssociationMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CampaignCreativeAssociationMethods<'a, S> {} impl<'a, S> CampaignCreativeAssociationMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Campaign ID in this association. pub fn insert(&self, request: CampaignCreativeAssociation, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationInsertCall<'a, S> { CampaignCreativeAssociationInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves the list of creative IDs associated with the specified campaign. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `campaignId` - Campaign ID in this association. pub fn list(&self, profile_id: &str, campaign_id: &str) -> CampaignCreativeAssociationListCall<'a, S> { CampaignCreativeAssociationListCall { hub: self.hub, _profile_id: profile_id.to_string(), _campaign_id: campaign_id.to_string(), _sort_order: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *campaign* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.campaigns(); /// # } /// ``` pub struct CampaignMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CampaignMethods<'a, S> {} impl<'a, S> CampaignMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one campaign by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Campaign ID. pub fn get(&self, profile_id: &str, id: &str) -> CampaignGetCall<'a, S> { CampaignGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new campaign. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Campaign, profile_id: &str) -> CampaignInsertCall<'a, S> { CampaignInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of campaigns, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CampaignListCall<'a, S> { CampaignListCall { hub: self.hub, _profile_id: profile_id.to_string(), _subaccount_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _overridden_event_tag_id: Default::default(), _max_results: Default::default(), _ids: Default::default(), _excluded_ids: Default::default(), _at_least_one_optimization_activity: Default::default(), _archived: Default::default(), _advertiser_ids: Default::default(), _advertiser_group_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing campaign. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Campaign ID. pub fn patch(&self, request: Campaign, profile_id: &str, id: &str) -> CampaignPatchCall<'a, S> { CampaignPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing campaign. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Campaign, profile_id: &str) -> CampaignUpdateCall<'a, S> { CampaignUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *changeLog* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.change_logs(); /// # } /// ``` pub struct ChangeLogMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ChangeLogMethods<'a, S> {} impl<'a, S> ChangeLogMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one change log by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Change log ID. pub fn get(&self, profile_id: &str, id: &str) -> ChangeLogGetCall<'a, S> { ChangeLogGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of change logs. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> ChangeLogListCall<'a, S> { ChangeLogListCall { hub: self.hub, _profile_id: profile_id.to_string(), _user_profile_ids: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _object_type: Default::default(), _object_ids: Default::default(), _min_change_time: Default::default(), _max_results: Default::default(), _max_change_time: Default::default(), _ids: Default::default(), _action: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *city* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.cities(); /// # } /// ``` pub struct CityMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CityMethods<'a, S> {} impl<'a, S> CityMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a list of cities, possibly filtered. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CityListCall<'a, S> { CityListCall { hub: self.hub, _profile_id: profile_id.to_string(), _region_dart_ids: Default::default(), _name_prefix: Default::default(), _dart_ids: Default::default(), _country_dart_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *connectionType* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.connection_types(); /// # } /// ``` pub struct ConnectionTypeMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ConnectionTypeMethods<'a, S> {} impl<'a, S> ConnectionTypeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one connection type by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Connection type ID. pub fn get(&self, profile_id: &str, id: &str) -> ConnectionTypeGetCall<'a, S> { ConnectionTypeGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of connection types. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> ConnectionTypeListCall<'a, S> { ConnectionTypeListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *contentCategory* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.content_categories(); /// # } /// ``` pub struct ContentCategoryMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ContentCategoryMethods<'a, S> {} impl<'a, S> ContentCategoryMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing content category. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Content category ID. pub fn delete(&self, profile_id: &str, id: &str) -> ContentCategoryDeleteCall<'a, S> { ContentCategoryDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one content category by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Content category ID. pub fn get(&self, profile_id: &str, id: &str) -> ContentCategoryGetCall<'a, S> { ContentCategoryGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new content category. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryInsertCall<'a, S> { ContentCategoryInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of content categories, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> ContentCategoryListCall<'a, S> { ContentCategoryListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing content category. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Content category ID. pub fn patch(&self, request: ContentCategory, profile_id: &str, id: &str) -> ContentCategoryPatchCall<'a, S> { ContentCategoryPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing content category. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: ContentCategory, profile_id: &str) -> ContentCategoryUpdateCall<'a, S> { ContentCategoryUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *conversion* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `batchinsert(...)` and `batchupdate(...)` /// // to build up your call. /// let rb = hub.conversions(); /// # } /// ``` pub struct ConversionMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ConversionMethods<'a, S> {} impl<'a, S> ConversionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Inserts conversions. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn batchinsert(&self, request: ConversionsBatchInsertRequest, profile_id: &str) -> ConversionBatchinsertCall<'a, S> { ConversionBatchinsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates existing conversions. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn batchupdate(&self, request: ConversionsBatchUpdateRequest, profile_id: &str) -> ConversionBatchupdateCall<'a, S> { ConversionBatchupdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *country* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.countries(); /// # } /// ``` pub struct CountryMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CountryMethods<'a, S> {} impl<'a, S> CountryMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one country by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `dartId` - Country DART ID. pub fn get(&self, profile_id: &str, dart_id: &str) -> CountryGetCall<'a, S> { CountryGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _dart_id: dart_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of countries. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CountryListCall<'a, S> { CountryListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *creativeAsset* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `insert(...)` /// // to build up your call. /// let rb = hub.creative_assets(); /// # } /// ``` pub struct CreativeAssetMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CreativeAssetMethods<'a, S> {} impl<'a, S> CreativeAssetMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Inserts a new creative asset. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `advertiserId` - Advertiser ID of this creative. This is a required field. pub fn insert(&self, request: CreativeAssetMetadata, profile_id: &str, advertiser_id: &str) -> CreativeAssetInsertCall<'a, S> { CreativeAssetInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _advertiser_id: advertiser_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *creativeFieldValue* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.creative_field_values(); /// # } /// ``` pub struct CreativeFieldValueMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CreativeFieldValueMethods<'a, S> {} impl<'a, S> CreativeFieldValueMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing creative field value. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. /// * `id` - Creative Field Value ID pub fn delete(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueDeleteCall<'a, S> { CreativeFieldValueDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one creative field value by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. /// * `id` - Creative Field Value ID pub fn get(&self, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValueGetCall<'a, S> { CreativeFieldValueGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new creative field value. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. pub fn insert(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueInsertCall<'a, S> { CreativeFieldValueInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of creative field values, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. pub fn list(&self, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueListCall<'a, S> { CreativeFieldValueListCall { hub: self.hub, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative field value. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. /// * `id` - Creative Field Value ID pub fn patch(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str, id: &str) -> CreativeFieldValuePatchCall<'a, S> { CreativeFieldValuePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative field value. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `creativeFieldId` - Creative field ID for this creative field value. pub fn update(&self, request: CreativeFieldValue, profile_id: &str, creative_field_id: &str) -> CreativeFieldValueUpdateCall<'a, S> { CreativeFieldValueUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _creative_field_id: creative_field_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *creativeField* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.creative_fields(); /// # } /// ``` pub struct CreativeFieldMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CreativeFieldMethods<'a, S> {} impl<'a, S> CreativeFieldMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing creative field. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative Field ID pub fn delete(&self, profile_id: &str, id: &str) -> CreativeFieldDeleteCall<'a, S> { CreativeFieldDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one creative field by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative Field ID pub fn get(&self, profile_id: &str, id: &str) -> CreativeFieldGetCall<'a, S> { CreativeFieldGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new creative field. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: CreativeField, profile_id: &str) -> CreativeFieldInsertCall<'a, S> { CreativeFieldInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of creative fields, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CreativeFieldListCall<'a, S> { CreativeFieldListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative field. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative Field ID pub fn patch(&self, request: CreativeField, profile_id: &str, id: &str) -> CreativeFieldPatchCall<'a, S> { CreativeFieldPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative field. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: CreativeField, profile_id: &str) -> CreativeFieldUpdateCall<'a, S> { CreativeFieldUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *creativeGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.creative_groups(); /// # } /// ``` pub struct CreativeGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CreativeGroupMethods<'a, S> {} impl<'a, S> CreativeGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one creative group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative group ID. pub fn get(&self, profile_id: &str, id: &str) -> CreativeGroupGetCall<'a, S> { CreativeGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new creative group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupInsertCall<'a, S> { CreativeGroupInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of creative groups, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CreativeGroupListCall<'a, S> { CreativeGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _group_number: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative group. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative group ID. pub fn patch(&self, request: CreativeGroup, profile_id: &str, id: &str) -> CreativeGroupPatchCall<'a, S> { CreativeGroupPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: CreativeGroup, profile_id: &str) -> CreativeGroupUpdateCall<'a, S> { CreativeGroupUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *creative* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.creatives(); /// # } /// ``` pub struct CreativeMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for CreativeMethods<'a, S> {} impl<'a, S> CreativeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one creative by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative ID. pub fn get(&self, profile_id: &str, id: &str) -> CreativeGetCall<'a, S> { CreativeGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new creative. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Creative, profile_id: &str) -> CreativeInsertCall<'a, S> { CreativeInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of creatives, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> CreativeListCall<'a, S> { CreativeListCall { hub: self.hub, _profile_id: profile_id.to_string(), _types: Default::default(), _studio_creative_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _size_ids: Default::default(), _search_string: Default::default(), _rendering_ids: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _creative_field_ids: Default::default(), _companion_creative_ids: Default::default(), _campaign_id: Default::default(), _archived: Default::default(), _advertiser_id: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Creative ID. pub fn patch(&self, request: Creative, profile_id: &str, id: &str) -> CreativePatchCall<'a, S> { CreativePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing creative. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Creative, profile_id: &str) -> CreativeUpdateCall<'a, S> { CreativeUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *dimensionValue* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `query(...)` /// // to build up your call. /// let rb = hub.dimension_values(); /// # } /// ``` pub struct DimensionValueMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for DimensionValueMethods<'a, S> {} impl<'a, S> DimensionValueMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves list of report dimension values for a list of filters. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. pub fn query(&self, request: DimensionValueRequest, profile_id: &str) -> DimensionValueQueryCall<'a, S> { DimensionValueQueryCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *directorySiteContact* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.directory_site_contacts(); /// # } /// ``` pub struct DirectorySiteContactMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for DirectorySiteContactMethods<'a, S> {} impl<'a, S> DirectorySiteContactMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one directory site contact by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Directory site contact ID. pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteContactGetCall<'a, S> { DirectorySiteContactGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of directory site contacts, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> DirectorySiteContactListCall<'a, S> { DirectorySiteContactListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _directory_site_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *directorySite* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.directory_sites(); /// # } /// ``` pub struct DirectorySiteMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for DirectorySiteMethods<'a, S> {} impl<'a, S> DirectorySiteMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one directory site by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Directory site ID. pub fn get(&self, profile_id: &str, id: &str) -> DirectorySiteGetCall<'a, S> { DirectorySiteGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new directory site. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: DirectorySite, profile_id: &str) -> DirectorySiteInsertCall<'a, S> { DirectorySiteInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of directory sites, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> DirectorySiteListCall<'a, S> { DirectorySiteListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _parent_id: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _dfp_network_code: Default::default(), _country_id: Default::default(), _active: Default::default(), _accepts_publisher_paid_placements: Default::default(), _accepts_interstitial_placements: Default::default(), _accepts_in_stream_video_placements: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *dynamicTargetingKey* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.dynamic_targeting_keys(); /// # } /// ``` pub struct DynamicTargetingKeyMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for DynamicTargetingKeyMethods<'a, S> {} impl<'a, S> DynamicTargetingKeyMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing dynamic targeting key. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `objectId` - ID of the object of this dynamic targeting key. This is a required field. /// * `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. /// * `objectType` - Type of the object of this dynamic targeting key. This is a required field. pub fn delete(&self, profile_id: &str, object_id: &str, name: &str, object_type: &str) -> DynamicTargetingKeyDeleteCall<'a, S> { DynamicTargetingKeyDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _object_id: object_id.to_string(), _name: name.to_string(), _object_type: object_type.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: DynamicTargetingKey, profile_id: &str) -> DynamicTargetingKeyInsertCall<'a, S> { DynamicTargetingKeyInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of dynamic targeting keys. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> DynamicTargetingKeyListCall<'a, S> { DynamicTargetingKeyListCall { hub: self.hub, _profile_id: profile_id.to_string(), _object_type: Default::default(), _object_id: Default::default(), _names: Default::default(), _advertiser_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *eventTag* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.event_tags(); /// # } /// ``` pub struct EventTagMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for EventTagMethods<'a, S> {} impl<'a, S> EventTagMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing event tag. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Event tag ID. pub fn delete(&self, profile_id: &str, id: &str) -> EventTagDeleteCall<'a, S> { EventTagDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one event tag by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Event tag ID. pub fn get(&self, profile_id: &str, id: &str) -> EventTagGetCall<'a, S> { EventTagGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new event tag. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: EventTag, profile_id: &str) -> EventTagInsertCall<'a, S> { EventTagInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of event tags, possibly filtered. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> EventTagListCall<'a, S> { EventTagListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _ids: Default::default(), _event_tag_types: Default::default(), _enabled: Default::default(), _definitions_only: Default::default(), _campaign_id: Default::default(), _advertiser_id: Default::default(), _ad_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing event tag. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Event tag ID. pub fn patch(&self, request: EventTag, profile_id: &str, id: &str) -> EventTagPatchCall<'a, S> { EventTagPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing event tag. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: EventTag, profile_id: &str) -> EventTagUpdateCall<'a, S> { EventTagUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *file* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.files(); /// # } /// ``` pub struct FileMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for FileMethods<'a, S> {} impl<'a, S> FileMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a report file by its report ID and file ID. This method supports media download. /// /// # Arguments /// /// * `reportId` - The ID of the report. /// * `fileId` - The ID of the report file. pub fn get(&self, report_id: &str, file_id: &str) -> FileGetCall<'a, S> { FileGetCall { hub: self.hub, _report_id: report_id.to_string(), _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists files for a user profile. /// /// # Arguments /// /// * `profileId` - The DFA profile ID. pub fn list(&self, profile_id: &str) -> FileListCall<'a, S> { FileListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _scope: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *floodlightActivity* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `generatetag(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.floodlight_activities(); /// # } /// ``` pub struct FloodlightActivityMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for FloodlightActivityMethods<'a, S> {} impl<'a, S> FloodlightActivityMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing floodlight activity. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity ID. pub fn delete(&self, profile_id: &str, id: &str) -> FloodlightActivityDeleteCall<'a, S> { FloodlightActivityDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Generates a tag for a floodlight activity. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn generatetag(&self, profile_id: &str) -> FloodlightActivityGeneratetagCall<'a, S> { FloodlightActivityGeneratetagCall { hub: self.hub, _profile_id: profile_id.to_string(), _floodlight_activity_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one floodlight activity by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity ID. pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGetCall<'a, S> { FloodlightActivityGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new floodlight activity. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityInsertCall<'a, S> { FloodlightActivityInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of floodlight activities, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> FloodlightActivityListCall<'a, S> { FloodlightActivityListCall { hub: self.hub, _profile_id: profile_id.to_string(), _tag_string: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _floodlight_configuration_id: Default::default(), _floodlight_activity_group_type: Default::default(), _floodlight_activity_group_tag_string: Default::default(), _floodlight_activity_group_name: Default::default(), _floodlight_activity_group_ids: Default::default(), _advertiser_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight activity. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity ID. pub fn patch(&self, request: FloodlightActivity, profile_id: &str, id: &str) -> FloodlightActivityPatchCall<'a, S> { FloodlightActivityPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight activity. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: FloodlightActivity, profile_id: &str) -> FloodlightActivityUpdateCall<'a, S> { FloodlightActivityUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *floodlightActivityGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.floodlight_activity_groups(); /// # } /// ``` pub struct FloodlightActivityGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for FloodlightActivityGroupMethods<'a, S> {} impl<'a, S> FloodlightActivityGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one floodlight activity group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity Group ID. pub fn get(&self, profile_id: &str, id: &str) -> FloodlightActivityGroupGetCall<'a, S> { FloodlightActivityGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new floodlight activity group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupInsertCall<'a, S> { FloodlightActivityGroupInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of floodlight activity groups, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> FloodlightActivityGroupListCall<'a, S> { FloodlightActivityGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _type_: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _floodlight_configuration_id: Default::default(), _advertiser_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight activity group. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight activity Group ID. pub fn patch(&self, request: FloodlightActivityGroup, profile_id: &str, id: &str) -> FloodlightActivityGroupPatchCall<'a, S> { FloodlightActivityGroupPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight activity group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: FloodlightActivityGroup, profile_id: &str) -> FloodlightActivityGroupUpdateCall<'a, S> { FloodlightActivityGroupUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *floodlightConfiguration* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.floodlight_configurations(); /// # } /// ``` pub struct FloodlightConfigurationMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for FloodlightConfigurationMethods<'a, S> {} impl<'a, S> FloodlightConfigurationMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one floodlight configuration by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight configuration ID. pub fn get(&self, profile_id: &str, id: &str) -> FloodlightConfigurationGetCall<'a, S> { FloodlightConfigurationGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of floodlight configurations, possibly filtered. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> FloodlightConfigurationListCall<'a, S> { FloodlightConfigurationListCall { hub: self.hub, _profile_id: profile_id.to_string(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight configuration. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Floodlight configuration ID. pub fn patch(&self, request: FloodlightConfiguration, profile_id: &str, id: &str) -> FloodlightConfigurationPatchCall<'a, S> { FloodlightConfigurationPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing floodlight configuration. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: FloodlightConfiguration, profile_id: &str) -> FloodlightConfigurationUpdateCall<'a, S> { FloodlightConfigurationUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *inventoryItem* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.inventory_items(); /// # } /// ``` pub struct InventoryItemMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for InventoryItemMethods<'a, S> {} impl<'a, S> InventoryItemMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one inventory item by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for order documents. /// * `id` - Inventory item ID. pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> InventoryItemGetCall<'a, S> { InventoryItemGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of inventory items, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for order documents. pub fn list(&self, profile_id: &str, project_id: &str) -> InventoryItemListCall<'a, S> { InventoryItemListCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _type_: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _site_id: Default::default(), _page_token: Default::default(), _order_id: Default::default(), _max_results: Default::default(), _in_plan: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *language* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.languages(); /// # } /// ``` pub struct LanguageMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for LanguageMethods<'a, S> {} impl<'a, S> LanguageMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a list of languages. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> LanguageListCall<'a, S> { LanguageListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *metro* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.metros(); /// # } /// ``` pub struct MetroMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for MetroMethods<'a, S> {} impl<'a, S> MetroMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a list of metros. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> MetroListCall<'a, S> { MetroListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *mobileApp* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.mobile_apps(); /// # } /// ``` pub struct MobileAppMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for MobileAppMethods<'a, S> {} impl<'a, S> MobileAppMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one mobile app by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Mobile app ID. pub fn get(&self, profile_id: &str, id: &str) -> MobileAppGetCall<'a, S> { MobileAppGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves list of available mobile apps. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> MobileAppListCall<'a, S> { MobileAppListCall { hub: self.hub, _profile_id: profile_id.to_string(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _directories: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *mobileCarrier* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.mobile_carriers(); /// # } /// ``` pub struct MobileCarrierMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for MobileCarrierMethods<'a, S> {} impl<'a, S> MobileCarrierMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one mobile carrier by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Mobile carrier ID. pub fn get(&self, profile_id: &str, id: &str) -> MobileCarrierGetCall<'a, S> { MobileCarrierGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of mobile carriers. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> MobileCarrierListCall<'a, S> { MobileCarrierListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *operatingSystemVersion* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.operating_system_versions(); /// # } /// ``` pub struct OperatingSystemVersionMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for OperatingSystemVersionMethods<'a, S> {} impl<'a, S> OperatingSystemVersionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one operating system version by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Operating system version ID. pub fn get(&self, profile_id: &str, id: &str) -> OperatingSystemVersionGetCall<'a, S> { OperatingSystemVersionGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of operating system versions. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> OperatingSystemVersionListCall<'a, S> { OperatingSystemVersionListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *operatingSystem* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.operating_systems(); /// # } /// ``` pub struct OperatingSystemMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for OperatingSystemMethods<'a, S> {} impl<'a, S> OperatingSystemMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one operating system by DART ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `dartId` - Operating system DART ID. pub fn get(&self, profile_id: &str, dart_id: &str) -> OperatingSystemGetCall<'a, S> { OperatingSystemGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _dart_id: dart_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of operating systems. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> OperatingSystemListCall<'a, S> { OperatingSystemListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *orderDocument* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.order_documents(); /// # } /// ``` pub struct OrderDocumentMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for OrderDocumentMethods<'a, S> {} impl<'a, S> OrderDocumentMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one order document by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for order documents. /// * `id` - Order document ID. pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderDocumentGetCall<'a, S> { OrderDocumentGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of order documents, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for order documents. pub fn list(&self, profile_id: &str, project_id: &str) -> OrderDocumentListCall<'a, S> { OrderDocumentListCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _site_id: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _order_id: Default::default(), _max_results: Default::default(), _ids: Default::default(), _approved: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *order* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.orders(); /// # } /// ``` pub struct OrderMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for OrderMethods<'a, S> {} impl<'a, S> OrderMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one order by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for orders. /// * `id` - Order ID. pub fn get(&self, profile_id: &str, project_id: &str, id: &str) -> OrderGetCall<'a, S> { OrderGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of orders, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `projectId` - Project ID for orders. pub fn list(&self, profile_id: &str, project_id: &str) -> OrderListCall<'a, S> { OrderListCall { hub: self.hub, _profile_id: profile_id.to_string(), _project_id: project_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _site_id: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *placementGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.placement_groups(); /// # } /// ``` pub struct PlacementGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for PlacementGroupMethods<'a, S> {} impl<'a, S> PlacementGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one placement group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement group ID. pub fn get(&self, profile_id: &str, id: &str) -> PlacementGroupGetCall<'a, S> { PlacementGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new placement group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupInsertCall<'a, S> { PlacementGroupInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of placement groups, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> PlacementGroupListCall<'a, S> { PlacementGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _site_ids: Default::default(), _search_string: Default::default(), _pricing_types: Default::default(), _placement_strategy_ids: Default::default(), _placement_group_type: Default::default(), _page_token: Default::default(), _min_start_date: Default::default(), _min_end_date: Default::default(), _max_start_date: Default::default(), _max_results: Default::default(), _max_end_date: Default::default(), _ids: Default::default(), _directory_site_ids: Default::default(), _content_category_ids: Default::default(), _campaign_ids: Default::default(), _archived: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement group. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement group ID. pub fn patch(&self, request: PlacementGroup, profile_id: &str, id: &str) -> PlacementGroupPatchCall<'a, S> { PlacementGroupPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement group. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: PlacementGroup, profile_id: &str) -> PlacementGroupUpdateCall<'a, S> { PlacementGroupUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *placementStrategy* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.placement_strategies(); /// # } /// ``` pub struct PlacementStrategyMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for PlacementStrategyMethods<'a, S> {} impl<'a, S> PlacementStrategyMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing placement strategy. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement strategy ID. pub fn delete(&self, profile_id: &str, id: &str) -> PlacementStrategyDeleteCall<'a, S> { PlacementStrategyDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one placement strategy by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement strategy ID. pub fn get(&self, profile_id: &str, id: &str) -> PlacementStrategyGetCall<'a, S> { PlacementStrategyGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new placement strategy. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyInsertCall<'a, S> { PlacementStrategyInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of placement strategies, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> PlacementStrategyListCall<'a, S> { PlacementStrategyListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement strategy. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement strategy ID. pub fn patch(&self, request: PlacementStrategy, profile_id: &str, id: &str) -> PlacementStrategyPatchCall<'a, S> { PlacementStrategyPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement strategy. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: PlacementStrategy, profile_id: &str) -> PlacementStrategyUpdateCall<'a, S> { PlacementStrategyUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *placement* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `generatetags(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.placements(); /// # } /// ``` pub struct PlacementMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for PlacementMethods<'a, S> {} impl<'a, S> PlacementMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Generates tags for a placement. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn generatetags(&self, profile_id: &str) -> PlacementGeneratetagCall<'a, S> { PlacementGeneratetagCall { hub: self.hub, _profile_id: profile_id.to_string(), _tag_formats: Default::default(), _placement_ids: Default::default(), _campaign_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one placement by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement ID. pub fn get(&self, profile_id: &str, id: &str) -> PlacementGetCall<'a, S> { PlacementGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new placement. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Placement, profile_id: &str) -> PlacementInsertCall<'a, S> { PlacementInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of placements, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> PlacementListCall<'a, S> { PlacementListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _size_ids: Default::default(), _site_ids: Default::default(), _search_string: Default::default(), _pricing_types: Default::default(), _placement_strategy_ids: Default::default(), _payment_source: Default::default(), _page_token: Default::default(), _min_start_date: Default::default(), _min_end_date: Default::default(), _max_start_date: Default::default(), _max_results: Default::default(), _max_end_date: Default::default(), _ids: Default::default(), _group_ids: Default::default(), _directory_site_ids: Default::default(), _content_category_ids: Default::default(), _compatibilities: Default::default(), _campaign_ids: Default::default(), _archived: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Placement ID. pub fn patch(&self, request: Placement, profile_id: &str, id: &str) -> PlacementPatchCall<'a, S> { PlacementPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing placement. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Placement, profile_id: &str) -> PlacementUpdateCall<'a, S> { PlacementUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *platformType* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.platform_types(); /// # } /// ``` pub struct PlatformTypeMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for PlatformTypeMethods<'a, S> {} impl<'a, S> PlatformTypeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one platform type by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Platform type ID. pub fn get(&self, profile_id: &str, id: &str) -> PlatformTypeGetCall<'a, S> { PlatformTypeGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of platform types. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> PlatformTypeListCall<'a, S> { PlatformTypeListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *postalCode* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.postal_codes(); /// # } /// ``` pub struct PostalCodeMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for PostalCodeMethods<'a, S> {} impl<'a, S> PostalCodeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one postal code by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `code` - Postal code ID. pub fn get(&self, profile_id: &str, code: &str) -> PostalCodeGetCall<'a, S> { PostalCodeGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _code: code.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of postal codes. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> PostalCodeListCall<'a, S> { PostalCodeListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *project* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.projects(); /// # } /// ``` pub struct ProjectMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {} impl<'a, S> ProjectMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one project by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Project ID. pub fn get(&self, profile_id: &str, id: &str) -> ProjectGetCall<'a, S> { ProjectGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of projects, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> ProjectListCall<'a, S> { ProjectListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _advertiser_ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *region* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `list(...)` /// // to build up your call. /// let rb = hub.regions(); /// # } /// ``` pub struct RegionMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for RegionMethods<'a, S> {} impl<'a, S> RegionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Retrieves a list of regions. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> RegionListCall<'a, S> { RegionListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *remarketingListShare* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.remarketing_list_shares(); /// # } /// ``` pub struct RemarketingListShareMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for RemarketingListShareMethods<'a, S> {} impl<'a, S> RemarketingListShareMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one remarketing list share by remarketing list ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `remarketingListId` - Remarketing list ID. pub fn get(&self, profile_id: &str, remarketing_list_id: &str) -> RemarketingListShareGetCall<'a, S> { RemarketingListShareGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _remarketing_list_id: remarketing_list_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing remarketing list share. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `remarketingListId` - Remarketing list ID. pub fn patch(&self, request: RemarketingListShare, profile_id: &str, remarketing_list_id: &str) -> RemarketingListSharePatchCall<'a, S> { RemarketingListSharePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _remarketing_list_id: remarketing_list_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing remarketing list share. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: RemarketingListShare, profile_id: &str) -> RemarketingListShareUpdateCall<'a, S> { RemarketingListShareUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *remarketingList* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.remarketing_lists(); /// # } /// ``` pub struct RemarketingListMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for RemarketingListMethods<'a, S> {} impl<'a, S> RemarketingListMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one remarketing list by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Remarketing list ID. pub fn get(&self, profile_id: &str, id: &str) -> RemarketingListGetCall<'a, S> { RemarketingListGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new remarketing list. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: RemarketingList, profile_id: &str) -> RemarketingListInsertCall<'a, S> { RemarketingListInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of remarketing lists, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `advertiserId` - Select only remarketing lists owned by this advertiser. pub fn list(&self, profile_id: &str, advertiser_id: &str) -> RemarketingListListCall<'a, S> { RemarketingListListCall { hub: self.hub, _profile_id: profile_id.to_string(), _advertiser_id: advertiser_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _page_token: Default::default(), _name: Default::default(), _max_results: Default::default(), _floodlight_activity_id: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing remarketing list. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Remarketing list ID. pub fn patch(&self, request: RemarketingList, profile_id: &str, id: &str) -> RemarketingListPatchCall<'a, S> { RemarketingListPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing remarketing list. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: RemarketingList, profile_id: &str) -> RemarketingListUpdateCall<'a, S> { RemarketingListUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *report* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `compatible_fields_query(...)`, `delete(...)`, `files_get(...)`, `files_list(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `run(...)` and `update(...)` /// // to build up your call. /// let rb = hub.reports(); /// # } /// ``` pub struct ReportMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for ReportMethods<'a, S> {} impl<'a, S> ReportMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. pub fn compatible_fields_query(&self, request: Report, profile_id: &str) -> ReportCompatibleFieldQueryCall<'a, S> { ReportCompatibleFieldQueryCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a report file. This method supports media download. /// /// # Arguments /// /// * `profileId` - The DFA profile ID. /// * `reportId` - The ID of the report. /// * `fileId` - The ID of the report file. pub fn files_get(&self, profile_id: &str, report_id: &str, file_id: &str) -> ReportFileGetCall<'a, S> { ReportFileGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _file_id: file_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists files for a report. /// /// # Arguments /// /// * `profileId` - The DFA profile ID. /// * `reportId` - The ID of the parent report. pub fn files_list(&self, profile_id: &str, report_id: &str) -> ReportFileListCall<'a, S> { ReportFileListCall { hub: self.hub, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a report by its ID. /// /// # Arguments /// /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. pub fn delete(&self, profile_id: &str, report_id: &str) -> ReportDeleteCall<'a, S> { ReportDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a report by its ID. /// /// # Arguments /// /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. pub fn get(&self, profile_id: &str, report_id: &str) -> ReportGetCall<'a, S> { ReportGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a report. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. pub fn insert(&self, request: Report, profile_id: &str) -> ReportInsertCall<'a, S> { ReportInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves list of reports. /// /// # Arguments /// /// * `profileId` - The DFA user profile ID. pub fn list(&self, profile_id: &str) -> ReportListCall<'a, S> { ReportListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _scope: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a report. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. pub fn patch(&self, request: Report, profile_id: &str, report_id: &str) -> ReportPatchCall<'a, S> { ReportPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Runs a report. /// /// # Arguments /// /// * `profileId` - The DFA profile ID. /// * `reportId` - The ID of the report. pub fn run(&self, profile_id: &str, report_id: &str) -> ReportRunCall<'a, S> { ReportRunCall { hub: self.hub, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _synchronous: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates a report. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - The DFA user profile ID. /// * `reportId` - The ID of the report. pub fn update(&self, request: Report, profile_id: &str, report_id: &str) -> ReportUpdateCall<'a, S> { ReportUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _report_id: report_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *site* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.sites(); /// # } /// ``` pub struct SiteMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for SiteMethods<'a, S> {} impl<'a, S> SiteMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one site by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Site ID. pub fn get(&self, profile_id: &str, id: &str) -> SiteGetCall<'a, S> { SiteGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new site. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Site, profile_id: &str) -> SiteInsertCall<'a, S> { SiteInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of sites, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> SiteListCall<'a, S> { SiteListCall { hub: self.hub, _profile_id: profile_id.to_string(), _unmapped_site: Default::default(), _subaccount_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _directory_site_ids: Default::default(), _campaign_ids: Default::default(), _approved: Default::default(), _ad_words_site: Default::default(), _accepts_publisher_paid_placements: Default::default(), _accepts_interstitial_placements: Default::default(), _accepts_in_stream_video_placements: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing site. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Site ID. pub fn patch(&self, request: Site, profile_id: &str, id: &str) -> SitePatchCall<'a, S> { SitePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing site. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Site, profile_id: &str) -> SiteUpdateCall<'a, S> { SiteUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *size* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)` and `list(...)` /// // to build up your call. /// let rb = hub.sizes(); /// # } /// ``` pub struct SizeMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for SizeMethods<'a, S> {} impl<'a, S> SizeMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one size by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Size ID. pub fn get(&self, profile_id: &str, id: &str) -> SizeGetCall<'a, S> { SizeGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new size. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Size, profile_id: &str) -> SizeInsertCall<'a, S> { SizeInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// 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. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> SizeListCall<'a, S> { SizeListCall { hub: self.hub, _profile_id: profile_id.to_string(), _width: Default::default(), _ids: Default::default(), _iab_standard: Default::default(), _height: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *subaccount* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.subaccounts(); /// # } /// ``` pub struct SubaccountMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for SubaccountMethods<'a, S> {} impl<'a, S> SubaccountMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one subaccount by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Subaccount ID. pub fn get(&self, profile_id: &str, id: &str) -> SubaccountGetCall<'a, S> { SubaccountGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new subaccount. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: Subaccount, profile_id: &str) -> SubaccountInsertCall<'a, S> { SubaccountInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a list of subaccounts, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> SubaccountListCall<'a, S> { SubaccountListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing subaccount. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Subaccount ID. pub fn patch(&self, request: Subaccount, profile_id: &str, id: &str) -> SubaccountPatchCall<'a, S> { SubaccountPatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing subaccount. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: Subaccount, profile_id: &str) -> SubaccountUpdateCall<'a, S> { SubaccountUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *targetableRemarketingList* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.targetable_remarketing_lists(); /// # } /// ``` pub struct TargetableRemarketingListMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for TargetableRemarketingListMethods<'a, S> {} impl<'a, S> TargetableRemarketingListMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one remarketing list by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Remarketing list ID. pub fn get(&self, profile_id: &str, id: &str) -> TargetableRemarketingListGetCall<'a, S> { TargetableRemarketingListGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of targetable remarketing lists, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `advertiserId` - Select only targetable remarketing lists targetable by these advertisers. pub fn list(&self, profile_id: &str, advertiser_id: &str) -> TargetableRemarketingListListCall<'a, S> { TargetableRemarketingListListCall { hub: self.hub, _profile_id: profile_id.to_string(), _advertiser_id: advertiser_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _page_token: Default::default(), _name: Default::default(), _max_results: Default::default(), _active: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *targetingTemplate* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.targeting_templates(); /// # } /// ``` pub struct TargetingTemplateMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for TargetingTemplateMethods<'a, S> {} impl<'a, S> TargetingTemplateMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one targeting template by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Targeting template ID. pub fn get(&self, profile_id: &str, id: &str) -> TargetingTemplateGetCall<'a, S> { TargetingTemplateGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new targeting template. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: TargetingTemplate, profile_id: &str) -> TargetingTemplateInsertCall<'a, S> { TargetingTemplateInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of targeting templates, optionally filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> TargetingTemplateListCall<'a, S> { TargetingTemplateListCall { hub: self.hub, _profile_id: profile_id.to_string(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _advertiser_id: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing targeting template. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - Targeting template ID. pub fn patch(&self, request: TargetingTemplate, profile_id: &str, id: &str) -> TargetingTemplatePatchCall<'a, S> { TargetingTemplatePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing targeting template. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: TargetingTemplate, profile_id: &str) -> TargetingTemplateUpdateCall<'a, S> { TargetingTemplateUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *userProfile* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.user_profiles(); /// # } /// ``` pub struct UserProfileMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for UserProfileMethods<'a, S> {} impl<'a, S> UserProfileMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one user profile by ID. /// /// # Arguments /// /// * `profileId` - The user profile ID. pub fn get(&self, profile_id: &str) -> UserProfileGetCall<'a, S> { UserProfileGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves list of user profiles for a user. pub fn list(&self) -> UserProfileListCall<'a, S> { UserProfileListCall { hub: self.hub, _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *userRolePermissionGroup* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.user_role_permission_groups(); /// # } /// ``` pub struct UserRolePermissionGroupMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for UserRolePermissionGroupMethods<'a, S> {} impl<'a, S> UserRolePermissionGroupMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one user role permission group by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - User role permission group ID. pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGroupGetCall<'a, S> { UserRolePermissionGroupGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a list of all supported user role permission groups. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> UserRolePermissionGroupListCall<'a, S> { UserRolePermissionGroupListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *userRolePermission* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.user_role_permissions(); /// # } /// ``` pub struct UserRolePermissionMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for UserRolePermissionMethods<'a, S> {} impl<'a, S> UserRolePermissionMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one user role permission by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - User role permission ID. pub fn get(&self, profile_id: &str, id: &str) -> UserRolePermissionGetCall<'a, S> { UserRolePermissionGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets a list of user role permissions, possibly filtered. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> UserRolePermissionListCall<'a, S> { UserRolePermissionListCall { hub: self.hub, _profile_id: profile_id.to_string(), _ids: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *userRole* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)` /// // to build up your call. /// let rb = hub.user_roles(); /// # } /// ``` pub struct UserRoleMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for UserRoleMethods<'a, S> {} impl<'a, S> UserRoleMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Deletes an existing user role. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - User role ID. pub fn delete(&self, profile_id: &str, id: &str) -> UserRoleDeleteCall<'a, S> { UserRoleDeleteCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets one user role by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - User role ID. pub fn get(&self, profile_id: &str, id: &str) -> UserRoleGetCall<'a, S> { UserRoleGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Inserts a new user role. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn insert(&self, request: UserRole, profile_id: &str) -> UserRoleInsertCall<'a, S> { UserRoleInsertCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a list of user roles, possibly filtered. This method supports paging. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> UserRoleListCall<'a, S> { UserRoleListCall { hub: self.hub, _profile_id: profile_id.to_string(), _subaccount_id: Default::default(), _sort_order: Default::default(), _sort_field: Default::default(), _search_string: Default::default(), _page_token: Default::default(), _max_results: Default::default(), _ids: Default::default(), _account_user_role_only: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing user role. This method supports patch semantics. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. /// * `id` - User role ID. pub fn patch(&self, request: UserRole, profile_id: &str, id: &str) -> UserRolePatchCall<'a, S> { UserRolePatchCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _id: id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Updates an existing user role. /// /// # Arguments /// /// * `request` - No description provided. /// * `profileId` - User profile ID associated with this request. pub fn update(&self, request: UserRole, profile_id: &str) -> UserRoleUpdateCall<'a, S> { UserRoleUpdateCall { hub: self.hub, _request: request, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } /// A builder providing access to all methods supported on *videoFormat* resources. /// It is not used directly, but through the `Dfareporting` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate google_dfareporting3d2 as dfareporting3d2; /// /// # async fn dox() { /// use std::default::Default; /// use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// let secret: oauth2::ApplicationSecret = Default::default(); /// let auth = oauth2::InstalledFlowAuthenticator::builder( /// secret, /// oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// ).build().await.unwrap(); /// let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)` and `list(...)` /// // to build up your call. /// let rb = hub.video_formats(); /// # } /// ``` pub struct VideoFormatMethods<'a, S> where S: 'a { hub: &'a Dfareporting, } impl<'a, S> client::MethodsBuilder for VideoFormatMethods<'a, S> {} impl<'a, S> VideoFormatMethods<'a, S> { /// Create a builder to help you perform the following task: /// /// Gets one video format by ID. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. /// * `id` - Video format ID. pub fn get(&self, profile_id: &str, id: i32) -> VideoFormatGetCall<'a, S> { VideoFormatGetCall { hub: self.hub, _profile_id: profile_id.to_string(), _id: id, _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Lists available video formats. /// /// # Arguments /// /// * `profileId` - User profile ID associated with this request. pub fn list(&self, profile_id: &str) -> VideoFormatListCall<'a, S> { VideoFormatListCall { hub: self.hub, _profile_id: profile_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), _scopes: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Gets the account's active ad summary by account ID. /// /// A builder for the *get* method supported by a *accountActiveAdSummary* resource. /// It is not used directly, but through a `AccountActiveAdSummaryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_active_ad_summaries().get("profileId", "summaryAccountId") /// .doit().await; /// # } /// ``` pub struct AccountActiveAdSummaryGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _summary_account_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountActiveAdSummaryGetCall<'a, S> {} impl<'a, S> AccountActiveAdSummaryGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountActiveAdSummary)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountActiveAdSummaries.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("summaryAccountId", self._summary_account_id.to_string())); for &field in ["alt", "profileId", "summaryAccountId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountActiveAdSummaries/{summaryAccountId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{summaryAccountId}", "summaryAccountId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["summaryAccountId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Account ID. /// /// Sets the *summary account id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn summary_account_id(mut self, new_value: &str) -> AccountActiveAdSummaryGetCall<'a, S> { self._summary_account_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountActiveAdSummaryGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountActiveAdSummaryGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountActiveAdSummaryGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one account permission group by ID. /// /// A builder for the *get* method supported by a *accountPermissionGroup* resource. /// It is not used directly, but through a `AccountPermissionGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_permission_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountPermissionGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountPermissionGroupGetCall<'a, S> {} impl<'a, S> AccountPermissionGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountPermissionGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountPermissionGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissionGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Account permission group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountPermissionGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountPermissionGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountPermissionGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountPermissionGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves the list of account permission groups. /// /// A builder for the *list* method supported by a *accountPermissionGroup* resource. /// It is not used directly, but through a `AccountPermissionGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_permission_groups().list("profileId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountPermissionGroupListCall<'a, S> {} impl<'a, S> AccountPermissionGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountPermissionGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountPermissionGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissionGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountPermissionGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountPermissionGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountPermissionGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountPermissionGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one account permission by ID. /// /// A builder for the *get* method supported by a *accountPermission* resource. /// It is not used directly, but through a `AccountPermissionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_permissions().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountPermissionGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountPermissionGetCall<'a, S> {} impl<'a, S> AccountPermissionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountPermission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountPermissions.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissions/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Account permission ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountPermissionGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountPermissionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountPermissionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountPermissionGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves the list of account permissions. /// /// A builder for the *list* method supported by a *accountPermission* resource. /// It is not used directly, but through a `AccountPermissionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_permissions().list("profileId") /// .doit().await; /// # } /// ``` pub struct AccountPermissionListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountPermissionListCall<'a, S> {} impl<'a, S> AccountPermissionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountPermissionsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountPermissions.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountPermissions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountPermissionListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountPermissionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountPermissionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountPermissionListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one account user profile by ID. /// /// A builder for the *get* method supported by a *accountUserProfile* resource. /// It is not used directly, but through a `AccountUserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountUserProfileGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUserProfileGetCall<'a, S> {} impl<'a, S> AccountUserProfileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountUserProfile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountUserProfiles.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User profile ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountUserProfileGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUserProfileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUserProfileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUserProfileGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new account user profile. /// /// A builder for the *insert* method supported by a *accountUserProfile* resource. /// It is not used directly, but through a `AccountUserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AccountUserProfile; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AccountUserProfile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AccountUserProfileInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AccountUserProfile, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUserProfileInsertCall<'a, S> {} impl<'a, S> AccountUserProfileInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountUserProfile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountUserProfiles.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUserProfileInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUserProfileInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUserProfileInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUserProfileInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of account user profiles, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *accountUserProfile* resource. /// It is not used directly, but through a `AccountUserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().list("profileId") /// .user_role_id("ipsum") /// .subaccount_id("est") /// .sort_order("gubergren") /// .sort_field("ea") /// .search_string("dolor") /// .page_token("Lorem") /// .max_results(-25) /// .add_ids("labore") /// .active(true) /// .doit().await; /// # } /// ``` pub struct AccountUserProfileListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _user_role_id: Option, _subaccount_id: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUserProfileListCall<'a, S> {} impl<'a, S> AccountUserProfileListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountUserProfilesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountUserProfiles.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(12 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._user_role_id { params.push(("userRoleId", value.to_string())); } if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "userRoleId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only user profiles with the specified user role ID. /// /// Sets the *user role id* query property to the given value. pub fn user_role_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._user_role_id = Some(new_value.to_string()); self } /// Select only user profiles with the specified subaccount ID. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AccountUserProfileListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only user profiles with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AccountUserProfileListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only active user profiles. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> AccountUserProfileListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUserProfileListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUserProfileListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUserProfileListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing account user profile. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *accountUserProfile* resource. /// It is not used directly, but through a `AccountUserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AccountUserProfile; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AccountUserProfile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountUserProfilePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AccountUserProfile, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUserProfilePatchCall<'a, S> {} impl<'a, S> AccountUserProfilePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountUserProfile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountUserProfiles.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfilePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User profile ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountUserProfilePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUserProfilePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUserProfilePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUserProfilePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing account user profile. /// /// A builder for the *update* method supported by a *accountUserProfile* resource. /// It is not used directly, but through a `AccountUserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AccountUserProfile; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AccountUserProfile::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.account_user_profiles().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AccountUserProfileUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AccountUserProfile, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUserProfileUpdateCall<'a, S> {} impl<'a, S> AccountUserProfileUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountUserProfile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accountUserProfiles.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accountUserProfiles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AccountUserProfile) -> AccountUserProfileUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUserProfileUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUserProfileUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUserProfileUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUserProfileUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one account by ID. /// /// A builder for the *get* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountGetCall<'a, S> {} impl<'a, S> AccountGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Account)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accounts.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Account ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves the list of accounts, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().list("profileId") /// .sort_order("sed") /// .sort_field("et") /// .search_string("et") /// .page_token("vero") /// .max_results(-31) /// .add_ids("sed") /// .active(false) /// .doit().await; /// # } /// ``` pub struct AccountListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountListCall<'a, S> {} impl<'a, S> AccountListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AccountsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accounts.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AccountListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AccountListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AccountListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AccountListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only accounts with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AccountListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only active accounts. Don't set this field to select both active and non-active accounts. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> AccountListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing account. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Account; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AccountPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Account, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountPatchCall<'a, S> {} impl<'a, S> AccountPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Account)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accounts.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Account) -> AccountPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Account ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AccountPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing account. /// /// A builder for the *update* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Account; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Account::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AccountUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Account, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AccountUpdateCall<'a, S> {} impl<'a, S> AccountUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Account)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.accounts.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/accounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Account) -> AccountUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AccountUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AccountUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AccountUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AccountUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one ad by ID. /// /// A builder for the *get* method supported by a *ad* resource. /// It is not used directly, but through a `AdMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdGetCall<'a, S> {} impl<'a, S> AdGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Ad)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.ads.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Ad ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new ad. /// /// A builder for the *insert* method supported by a *ad* resource. /// It is not used directly, but through a `AdMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Ad; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Ad, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdInsertCall<'a, S> {} impl<'a, S> AdInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Ad)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.ads.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Ad) -> AdInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of ads, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *ad* resource. /// It is not used directly, but through a `AdMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().list("profileId") /// .add_type("duo") /// .ssl_required(false) /// .ssl_compliant(false) /// .sort_order("invidunt") /// .sort_field("Stet") /// .add_size_ids("vero") /// .search_string("elitr") /// .add_remarketing_list_ids("Lorem") /// .add_placement_ids("diam") /// .page_token("no") /// .overridden_event_tag_id("ipsum") /// .max_results(-23) /// .add_landing_page_ids("takimata") /// .add_ids("consetetur") /// .dynamic_click_tracker(false) /// .add_creative_optimization_configuration_ids("erat") /// .add_creative_ids("consetetur") /// .compatibility("amet.") /// .add_campaign_ids("sed") /// .add_audience_segment_ids("takimata") /// .archived(true) /// .advertiser_id("et") /// .active(false) /// .doit().await; /// # } /// ``` pub struct AdListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _type_: Vec, _ssl_required: Option, _ssl_compliant: Option, _sort_order: Option, _sort_field: Option, _size_ids: Vec, _search_string: Option, _remarketing_list_ids: Vec, _placement_ids: Vec, _page_token: Option, _overridden_event_tag_id: Option, _max_results: Option, _landing_page_ids: Vec, _ids: Vec, _dynamic_click_tracker: Option, _creative_optimization_configuration_ids: Vec, _creative_ids: Vec, _compatibility: Option, _campaign_ids: Vec, _audience_segment_ids: Vec, _archived: Option, _advertiser_id: Option, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdListCall<'a, S> {} impl<'a, S> AdListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.ads.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(26 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._type_.len() > 0 { for f in self._type_.iter() { params.push(("type", f.to_string())); } } if let Some(value) = self._ssl_required { params.push(("sslRequired", value.to_string())); } if let Some(value) = self._ssl_compliant { params.push(("sslCompliant", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._size_ids.len() > 0 { for f in self._size_ids.iter() { params.push(("sizeIds", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if self._remarketing_list_ids.len() > 0 { for f in self._remarketing_list_ids.iter() { params.push(("remarketingListIds", f.to_string())); } } if self._placement_ids.len() > 0 { for f in self._placement_ids.iter() { params.push(("placementIds", f.to_string())); } } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._overridden_event_tag_id { params.push(("overriddenEventTagId", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._landing_page_ids.len() > 0 { for f in self._landing_page_ids.iter() { params.push(("landingPageIds", f.to_string())); } } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._dynamic_click_tracker { params.push(("dynamicClickTracker", value.to_string())); } if self._creative_optimization_configuration_ids.len() > 0 { for f in self._creative_optimization_configuration_ids.iter() { params.push(("creativeOptimizationConfigurationIds", f.to_string())); } } if self._creative_ids.len() > 0 { for f in self._creative_ids.iter() { params.push(("creativeIds", f.to_string())); } } if let Some(value) = self._compatibility { params.push(("compatibility", value.to_string())); } if self._campaign_ids.len() > 0 { for f in self._campaign_ids.iter() { params.push(("campaignIds", f.to_string())); } } if self._audience_segment_ids.len() > 0 { for f in self._audience_segment_ids.iter() { params.push(("audienceSegmentIds", f.to_string())); } } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "type", "sslRequired", "sslCompliant", "sortOrder", "sortField", "sizeIds", "searchString", "remarketingListIds", "placementIds", "pageToken", "overriddenEventTagId", "maxResults", "landingPageIds", "ids", "dynamicClickTracker", "creativeOptimizationConfigurationIds", "creativeIds", "compatibility", "campaignIds", "audienceSegmentIds", "archived", "advertiserId", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only ads with these types. /// /// Append the given value to the *type* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_type(mut self, new_value: &str) -> AdListCall<'a, S> { self._type_.push(new_value.to_string()); self } /// Select only ads that require SSL. /// /// Sets the *ssl required* query property to the given value. pub fn ssl_required(mut self, new_value: bool) -> AdListCall<'a, S> { self._ssl_required = Some(new_value); self } /// Select only ads that are SSL-compliant. /// /// Sets the *ssl compliant* query property to the given value. pub fn ssl_compliant(mut self, new_value: bool) -> AdListCall<'a, S> { self._ssl_compliant = Some(new_value); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AdListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AdListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only ads with these size IDs. /// /// Append the given value to the *size ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_size_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._size_ids.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AdListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only ads whose list targeting expression use these remarketing list IDs. /// /// Append the given value to the *remarketing list ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_remarketing_list_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._remarketing_list_ids.push(new_value.to_string()); self } /// Select only ads with these placement IDs assigned. /// /// Append the given value to the *placement ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_placement_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._placement_ids.push(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AdListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only ads with this event tag override ID. /// /// Sets the *overridden event tag id* query property to the given value. pub fn overridden_event_tag_id(mut self, new_value: &str) -> AdListCall<'a, S> { self._overridden_event_tag_id = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AdListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only ads with these landing page IDs. /// /// Append the given value to the *landing page ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_landing_page_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._landing_page_ids.push(new_value.to_string()); self } /// Select only ads with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// 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. /// /// Sets the *dynamic click tracker* query property to the given value. pub fn dynamic_click_tracker(mut self, new_value: bool) -> AdListCall<'a, S> { self._dynamic_click_tracker = Some(new_value); self } /// Select only ads with these creative optimization configuration IDs. /// /// Append the given value to the *creative optimization configuration ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_creative_optimization_configuration_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._creative_optimization_configuration_ids.push(new_value.to_string()); self } /// Select only ads with these creative IDs assigned. /// /// Append the given value to the *creative ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_creative_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._creative_ids.push(new_value.to_string()); self } /// 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. /// /// Sets the *compatibility* query property to the given value. pub fn compatibility(mut self, new_value: &str) -> AdListCall<'a, S> { self._compatibility = Some(new_value.to_string()); self } /// Select only ads with these campaign IDs. /// /// Append the given value to the *campaign ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_campaign_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._campaign_ids.push(new_value.to_string()); self } /// Select only ads with these audience segment IDs. /// /// Append the given value to the *audience segment ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_audience_segment_ids(mut self, new_value: &str) -> AdListCall<'a, S> { self._audience_segment_ids.push(new_value.to_string()); self } /// Select only archived ads. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> AdListCall<'a, S> { self._archived = Some(new_value); self } /// Select only ads with this advertiser ID. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> AdListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// Select only active ads. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> AdListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing ad. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *ad* resource. /// It is not used directly, but through a `AdMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Ad; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Ad, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdPatchCall<'a, S> {} impl<'a, S> AdPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Ad)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.ads.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Ad) -> AdPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Ad ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing ad. /// /// A builder for the *update* method supported by a *ad* resource. /// It is not used directly, but through a `AdMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Ad; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Ad::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.ads().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Ad, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdUpdateCall<'a, S> {} impl<'a, S> AdUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Ad)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.ads.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/ads"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Ad) -> AdUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing advertiser group. /// /// A builder for the *delete* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupDeleteCall<'a, S> {} impl<'a, S> AdvertiserGroupDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserGroupDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one advertiser group by ID. /// /// A builder for the *get* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupGetCall<'a, S> {} impl<'a, S> AdvertiserGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new advertiser group. /// /// A builder for the *insert* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AdvertiserGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AdvertiserGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupInsertCall<'a, S> {} impl<'a, S> AdvertiserGroupInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of advertiser groups, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().list("profileId") /// .sort_order("no") /// .sort_field("est") /// .search_string("At") /// .page_token("sed") /// .max_results(-98) /// .add_ids("et") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupListCall<'a, S> {} impl<'a, S> AdvertiserGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AdvertiserGroupListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only advertiser groups with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AdvertiserGroupListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing advertiser group. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AdvertiserGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AdvertiserGroup, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupPatchCall<'a, S> {} impl<'a, S> AdvertiserGroupPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser group ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserGroupPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing advertiser group. /// /// A builder for the *update* method supported by a *advertiserGroup* resource. /// It is not used directly, but through a `AdvertiserGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::AdvertiserGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = AdvertiserGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_groups().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserGroupUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: AdvertiserGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGroupUpdateCall<'a, S> {} impl<'a, S> AdvertiserGroupUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserGroups.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: AdvertiserGroup) -> AdvertiserGroupUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGroupUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGroupUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGroupUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGroupUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one landing page by ID. /// /// A builder for the *get* method supported by a *advertiserLandingPage* resource. /// It is not used directly, but through a `AdvertiserLandingPageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_landing_pages().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserLandingPageGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserLandingPageGetCall<'a, S> {} impl<'a, S> AdvertiserLandingPageGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LandingPage)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserLandingPages.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserLandingPageGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Landing page ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserLandingPageGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserLandingPageGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserLandingPageGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserLandingPageGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new landing page. /// /// A builder for the *insert* method supported by a *advertiserLandingPage* resource. /// It is not used directly, but through a `AdvertiserLandingPageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::LandingPage; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_landing_pages().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserLandingPageInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: LandingPage, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserLandingPageInsertCall<'a, S> {} impl<'a, S> AdvertiserLandingPageInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LandingPage)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserLandingPages.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPageInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserLandingPageInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserLandingPageInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserLandingPageInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserLandingPageInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of landing pages. /// /// A builder for the *list* method supported by a *advertiserLandingPage* resource. /// It is not used directly, but through a `AdvertiserLandingPageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_landing_pages().list("profileId") /// .subaccount_id("sed") /// .sort_order("diam") /// .sort_field("dolores") /// .search_string("dolores") /// .page_token("et") /// .max_results(-93) /// .add_ids("no") /// .add_campaign_ids("et") /// .archived(false) /// .add_advertiser_ids("sed") /// .doit().await; /// # } /// ``` pub struct AdvertiserLandingPageListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _subaccount_id: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _campaign_ids: Vec, _archived: Option, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserLandingPageListCall<'a, S> {} impl<'a, S> AdvertiserLandingPageListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertiserLandingPagesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserLandingPages.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._campaign_ids.len() > 0 { for f in self._campaign_ids.iter() { params.push(("campaignIds", f.to_string())); } } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "campaignIds", "archived", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only landing pages that belong to this subaccount. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AdvertiserLandingPageListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only landing pages with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only landing pages that are associated with these campaigns. /// /// Append the given value to the *campaign ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_campaign_ids(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._campaign_ids.push(new_value.to_string()); self } /// Select only archived landing pages. Don't set this field to select both archived and non-archived landing pages. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> AdvertiserLandingPageListCall<'a, S> { self._archived = Some(new_value); self } /// Select only landing pages that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> AdvertiserLandingPageListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserLandingPageListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserLandingPageListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserLandingPageListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing landing page. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *advertiserLandingPage* resource. /// It is not used directly, but through a `AdvertiserLandingPageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::LandingPage; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_landing_pages().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserLandingPagePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: LandingPage, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserLandingPagePatchCall<'a, S> {} impl<'a, S> AdvertiserLandingPagePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LandingPage)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserLandingPages.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPagePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserLandingPagePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Landing page ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserLandingPagePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserLandingPagePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserLandingPagePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserLandingPagePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing landing page. /// /// A builder for the *update* method supported by a *advertiserLandingPage* resource. /// It is not used directly, but through a `AdvertiserLandingPageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::LandingPage; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = LandingPage::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertiser_landing_pages().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserLandingPageUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: LandingPage, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserLandingPageUpdateCall<'a, S> {} impl<'a, S> AdvertiserLandingPageUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LandingPage)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertiserLandingPages.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertiserLandingPages"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: LandingPage) -> AdvertiserLandingPageUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserLandingPageUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserLandingPageUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserLandingPageUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserLandingPageUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one advertiser by ID. /// /// A builder for the *get* method supported by a *advertiser* resource. /// It is not used directly, but through a `AdvertiserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserGetCall<'a, S> {} impl<'a, S> AdvertiserGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Advertiser)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertisers.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new advertiser. /// /// A builder for the *insert* method supported by a *advertiser* resource. /// It is not used directly, but through a `AdvertiserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Advertiser; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Advertiser, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserInsertCall<'a, S> {} impl<'a, S> AdvertiserInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Advertiser)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertisers.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Advertiser) -> AdvertiserInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of advertisers, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *advertiser* resource. /// It is not used directly, but through a `AdvertiserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().list("profileId") /// .subaccount_id("erat") /// .status("aliquyam") /// .sort_order("amet") /// .sort_field("est") /// .search_string("et") /// .page_token("sea") /// .only_parent(false) /// .max_results(-46) /// .include_advertisers_without_groups_only(true) /// .add_ids("est") /// .add_floodlight_configuration_ids("aliquyam") /// .add_advertiser_group_ids("elitr") /// .doit().await; /// # } /// ``` pub struct AdvertiserListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _subaccount_id: Option, _status: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _only_parent: Option, _max_results: Option, _include_advertisers_without_groups_only: Option, _ids: Vec, _floodlight_configuration_ids: Vec, _advertiser_group_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserListCall<'a, S> {} impl<'a, S> AdvertiserListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, AdvertisersListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertisers.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(15 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._status { params.push(("status", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._only_parent { params.push(("onlyParent", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._include_advertisers_without_groups_only { params.push(("includeAdvertisersWithoutGroupsOnly", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._floodlight_configuration_ids.len() > 0 { for f in self._floodlight_configuration_ids.iter() { params.push(("floodlightConfigurationIds", f.to_string())); } } if self._advertiser_group_ids.len() > 0 { for f in self._advertiser_group_ids.iter() { params.push(("advertiserGroupIds", f.to_string())); } } for &field in ["alt", "profileId", "subaccountId", "status", "sortOrder", "sortField", "searchString", "pageToken", "onlyParent", "maxResults", "includeAdvertisersWithoutGroupsOnly", "ids", "floodlightConfigurationIds", "advertiserGroupIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only advertisers with these subaccount IDs. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Select only advertisers with the specified status. /// /// Sets the *status* query property to the given value. pub fn status(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._status = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only advertisers which use another advertiser's floodlight configuration. /// /// Sets the *only parent* query property to the given value. pub fn only_parent(mut self, new_value: bool) -> AdvertiserListCall<'a, S> { self._only_parent = Some(new_value); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> AdvertiserListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only advertisers which do not belong to any advertiser group. /// /// Sets the *include advertisers without groups only* query property to the given value. pub fn include_advertisers_without_groups_only(mut self, new_value: bool) -> AdvertiserListCall<'a, S> { self._include_advertisers_without_groups_only = Some(new_value); self } /// Select only advertisers with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only advertisers with these floodlight configuration IDs. /// /// Append the given value to the *floodlight configuration ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_floodlight_configuration_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._floodlight_configuration_ids.push(new_value.to_string()); self } /// Select only advertisers with these advertiser group IDs. /// /// Append the given value to the *advertiser group ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_group_ids(mut self, new_value: &str) -> AdvertiserListCall<'a, S> { self._advertiser_group_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing advertiser. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *advertiser* resource. /// It is not used directly, but through a `AdvertiserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Advertiser; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct AdvertiserPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Advertiser, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserPatchCall<'a, S> {} impl<'a, S> AdvertiserPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Advertiser)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertisers.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Advertiser) -> AdvertiserPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> AdvertiserPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing advertiser. /// /// A builder for the *update* method supported by a *advertiser* resource. /// It is not used directly, but through a `AdvertiserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Advertiser; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Advertiser::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.advertisers().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct AdvertiserUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Advertiser, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for AdvertiserUpdateCall<'a, S> {} impl<'a, S> AdvertiserUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Advertiser)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.advertisers.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/advertisers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Advertiser) -> AdvertiserUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> AdvertiserUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AdvertiserUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> AdvertiserUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> AdvertiserUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of browsers. /// /// A builder for the *list* method supported by a *browser* resource. /// It is not used directly, but through a `BrowserMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.browsers().list("profileId") /// .doit().await; /// # } /// ``` pub struct BrowserListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for BrowserListCall<'a, S> {} impl<'a, S> BrowserListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, BrowsersListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.browsers.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/browsers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> BrowserListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BrowserListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> BrowserListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> BrowserListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *insert* method supported by a *campaignCreativeAssociation* resource. /// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CampaignCreativeAssociation; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CampaignCreativeAssociation::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaign_creative_associations().insert(req, "profileId", "campaignId") /// .doit().await; /// # } /// ``` pub struct CampaignCreativeAssociationInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CampaignCreativeAssociation, _profile_id: String, _campaign_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignCreativeAssociationInsertCall<'a, S> {} impl<'a, S> CampaignCreativeAssociationInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CampaignCreativeAssociation)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaignCreativeAssociations.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("campaignId", self._campaign_id.to_string())); for &field in ["alt", "profileId", "campaignId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["campaignId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CampaignCreativeAssociation) -> CampaignCreativeAssociationInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Campaign ID in this association. /// /// Sets the *campaign id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationInsertCall<'a, S> { self._campaign_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignCreativeAssociationInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignCreativeAssociationInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignCreativeAssociationInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves the list of creative IDs associated with the specified campaign. This method supports paging. /// /// A builder for the *list* method supported by a *campaignCreativeAssociation* resource. /// It is not used directly, but through a `CampaignCreativeAssociationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaign_creative_associations().list("profileId", "campaignId") /// .sort_order("Stet") /// .page_token("dolores") /// .max_results(-25) /// .doit().await; /// # } /// ``` pub struct CampaignCreativeAssociationListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _campaign_id: String, _sort_order: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignCreativeAssociationListCall<'a, S> {} impl<'a, S> CampaignCreativeAssociationListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CampaignCreativeAssociationsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaignCreativeAssociations.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("campaignId", self._campaign_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } for &field in ["alt", "profileId", "campaignId", "sortOrder", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns/{campaignId}/campaignCreativeAssociations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{campaignId}", "campaignId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["campaignId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Campaign ID in this association. /// /// Sets the *campaign id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn campaign_id(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, S> { self._campaign_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CampaignCreativeAssociationListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CampaignCreativeAssociationListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignCreativeAssociationListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignCreativeAssociationListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignCreativeAssociationListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one campaign by ID. /// /// A builder for the *get* method supported by a *campaign* resource. /// It is not used directly, but through a `CampaignMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct CampaignGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignGetCall<'a, S> {} impl<'a, S> CampaignGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Campaign)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaigns.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Campaign ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CampaignGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new campaign. /// /// A builder for the *insert* method supported by a *campaign* resource. /// It is not used directly, but through a `CampaignMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Campaign; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CampaignInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Campaign, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignInsertCall<'a, S> {} impl<'a, S> CampaignInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Campaign)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaigns.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Campaign) -> CampaignInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of campaigns, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *campaign* resource. /// It is not used directly, but through a `CampaignMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().list("profileId") /// .subaccount_id("dolore") /// .sort_order("eirmod") /// .sort_field("Lorem") /// .search_string("accusam") /// .page_token("amet") /// .overridden_event_tag_id("erat") /// .max_results(-69) /// .add_ids("erat") /// .add_excluded_ids("accusam") /// .at_least_one_optimization_activity(true) /// .archived(true) /// .add_advertiser_ids("et") /// .add_advertiser_group_ids("At") /// .doit().await; /// # } /// ``` pub struct CampaignListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _subaccount_id: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _overridden_event_tag_id: Option, _max_results: Option, _ids: Vec, _excluded_ids: Vec, _at_least_one_optimization_activity: Option, _archived: Option, _advertiser_ids: Vec, _advertiser_group_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignListCall<'a, S> {} impl<'a, S> CampaignListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CampaignsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaigns.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(16 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._overridden_event_tag_id { params.push(("overriddenEventTagId", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._excluded_ids.len() > 0 { for f in self._excluded_ids.iter() { params.push(("excludedIds", f.to_string())); } } if let Some(value) = self._at_least_one_optimization_activity { params.push(("atLeastOneOptimizationActivity", value.to_string())); } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } if self._advertiser_group_ids.len() > 0 { for f in self._advertiser_group_ids.iter() { params.push(("advertiserGroupIds", f.to_string())); } } for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "overriddenEventTagId", "maxResults", "ids", "excludedIds", "atLeastOneOptimizationActivity", "archived", "advertiserIds", "advertiserGroupIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only campaigns that belong to this subaccount. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only campaigns that have overridden this event tag ID. /// /// Sets the *overridden event tag id* query property to the given value. pub fn overridden_event_tag_id(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._overridden_event_tag_id = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CampaignListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only campaigns with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Exclude campaigns with these IDs. /// /// Append the given value to the *excluded ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_excluded_ids(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._excluded_ids.push(new_value.to_string()); self } /// Select only campaigns that have at least one optimization activity. /// /// Sets the *at least one optimization activity* query property to the given value. pub fn at_least_one_optimization_activity(mut self, new_value: bool) -> CampaignListCall<'a, S> { self._at_least_one_optimization_activity = Some(new_value); self } /// Select only archived campaigns. Don't set this field to select both archived and non-archived campaigns. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> CampaignListCall<'a, S> { self._archived = Some(new_value); self } /// Select only campaigns that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// Select only campaigns whose advertisers belong to these advertiser groups. /// /// Append the given value to the *advertiser group ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_group_ids(mut self, new_value: &str) -> CampaignListCall<'a, S> { self._advertiser_group_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing campaign. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *campaign* resource. /// It is not used directly, but through a `CampaignMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Campaign; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct CampaignPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Campaign, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignPatchCall<'a, S> {} impl<'a, S> CampaignPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Campaign)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaigns.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Campaign) -> CampaignPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Campaign ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CampaignPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing campaign. /// /// A builder for the *update* method supported by a *campaign* resource. /// It is not used directly, but through a `CampaignMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Campaign; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Campaign::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.campaigns().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CampaignUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Campaign, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CampaignUpdateCall<'a, S> {} impl<'a, S> CampaignUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Campaign)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.campaigns.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/campaigns"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Campaign) -> CampaignUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CampaignUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CampaignUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CampaignUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CampaignUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one change log by ID. /// /// A builder for the *get* method supported by a *changeLog* resource. /// It is not used directly, but through a `ChangeLogMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.change_logs().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct ChangeLogGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ChangeLogGetCall<'a, S> {} impl<'a, S> ChangeLogGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChangeLog)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.changeLogs.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/changeLogs/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ChangeLogGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Change log ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ChangeLogGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeLogGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ChangeLogGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ChangeLogGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of change logs. This method supports paging. /// /// A builder for the *list* method supported by a *changeLog* resource. /// It is not used directly, but through a `ChangeLogMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.change_logs().list("profileId") /// .add_user_profile_ids("et") /// .search_string("gubergren") /// .page_token("justo") /// .object_type("sea") /// .add_object_ids("consetetur") /// .min_change_time("sit") /// .max_results(-32) /// .max_change_time("eos") /// .add_ids("At") /// .action("dolores") /// .doit().await; /// # } /// ``` pub struct ChangeLogListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _user_profile_ids: Vec, _search_string: Option, _page_token: Option, _object_type: Option, _object_ids: Vec, _min_change_time: Option, _max_results: Option, _max_change_time: Option, _ids: Vec, _action: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ChangeLogListCall<'a, S> {} impl<'a, S> ChangeLogListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ChangeLogsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.changeLogs.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._user_profile_ids.len() > 0 { for f in self._user_profile_ids.iter() { params.push(("userProfileIds", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._object_type { params.push(("objectType", value.to_string())); } if self._object_ids.len() > 0 { for f in self._object_ids.iter() { params.push(("objectIds", f.to_string())); } } if let Some(value) = self._min_change_time { params.push(("minChangeTime", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._max_change_time { params.push(("maxChangeTime", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._action { params.push(("action", value.to_string())); } for &field in ["alt", "profileId", "userProfileIds", "searchString", "pageToken", "objectType", "objectIds", "minChangeTime", "maxResults", "maxChangeTime", "ids", "action"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/changeLogs"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only change logs with these user profile IDs. /// /// Append the given value to the *user profile ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_user_profile_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._user_profile_ids.push(new_value.to_string()); self } /// Select only change logs whose object ID, user name, old or new values match the search string. /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only change logs with the specified object type. /// /// Sets the *object type* query property to the given value. pub fn object_type(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._object_type = Some(new_value.to_string()); self } /// Select only change logs with these object IDs. /// /// Append the given value to the *object ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_object_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._object_ids.push(new_value.to_string()); self } /// 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. /// /// Sets the *min change time* query property to the given value. pub fn min_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._min_change_time = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ChangeLogListCall<'a, S> { self._max_results = Some(new_value); self } /// 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. /// /// Sets the *max change time* query property to the given value. pub fn max_change_time(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._max_change_time = Some(new_value.to_string()); self } /// Select only change logs with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only change logs with the specified action. /// /// Sets the *action* query property to the given value. pub fn action(mut self, new_value: &str) -> ChangeLogListCall<'a, S> { self._action = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeLogListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ChangeLogListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ChangeLogListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of cities, possibly filtered. /// /// A builder for the *list* method supported by a *city* resource. /// It is not used directly, but through a `CityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.cities().list("profileId") /// .add_region_dart_ids("gubergren") /// .name_prefix("dolor") /// .add_dart_ids("aliquyam") /// .add_country_dart_ids("no") /// .doit().await; /// # } /// ``` pub struct CityListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _region_dart_ids: Vec, _name_prefix: Option, _dart_ids: Vec, _country_dart_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CityListCall<'a, S> {} impl<'a, S> CityListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CitiesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.cities.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._region_dart_ids.len() > 0 { for f in self._region_dart_ids.iter() { params.push(("regionDartIds", f.to_string())); } } if let Some(value) = self._name_prefix { params.push(("namePrefix", value.to_string())); } if self._dart_ids.len() > 0 { for f in self._dart_ids.iter() { params.push(("dartIds", f.to_string())); } } if self._country_dart_ids.len() > 0 { for f in self._country_dart_ids.iter() { params.push(("countryDartIds", f.to_string())); } } for &field in ["alt", "profileId", "regionDartIds", "namePrefix", "dartIds", "countryDartIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/cities"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CityListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only cities from these regions. /// /// Append the given value to the *region dart ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_region_dart_ids(mut self, new_value: &str) -> CityListCall<'a, S> { self._region_dart_ids.push(new_value.to_string()); self } /// Select only cities with names starting with this prefix. /// /// Sets the *name prefix* query property to the given value. pub fn name_prefix(mut self, new_value: &str) -> CityListCall<'a, S> { self._name_prefix = Some(new_value.to_string()); self } /// Select only cities with these DART IDs. /// /// Append the given value to the *dart ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_dart_ids(mut self, new_value: &str) -> CityListCall<'a, S> { self._dart_ids.push(new_value.to_string()); self } /// Select only cities from these countries. /// /// Append the given value to the *country dart ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_country_dart_ids(mut self, new_value: &str) -> CityListCall<'a, S> { self._country_dart_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CityListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CityListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CityListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one connection type by ID. /// /// A builder for the *get* method supported by a *connectionType* resource. /// It is not used directly, but through a `ConnectionTypeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.connection_types().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct ConnectionTypeGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ConnectionTypeGetCall<'a, S> {} impl<'a, S> ConnectionTypeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ConnectionType)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.connectionTypes.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/connectionTypes/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Connection type ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ConnectionTypeGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ConnectionTypeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ConnectionTypeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ConnectionTypeGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of connection types. /// /// A builder for the *list* method supported by a *connectionType* resource. /// It is not used directly, but through a `ConnectionTypeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.connection_types().list("profileId") /// .doit().await; /// # } /// ``` pub struct ConnectionTypeListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ConnectionTypeListCall<'a, S> {} impl<'a, S> ConnectionTypeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ConnectionTypesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.connectionTypes.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/connectionTypes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ConnectionTypeListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ConnectionTypeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ConnectionTypeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ConnectionTypeListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing content category. /// /// A builder for the *delete* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct ContentCategoryDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryDeleteCall<'a, S> {} impl<'a, S> ContentCategoryDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Content category ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ContentCategoryDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one content category by ID. /// /// A builder for the *get* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct ContentCategoryGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryGetCall<'a, S> {} impl<'a, S> ContentCategoryGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ContentCategory)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Content category ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ContentCategoryGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new content category. /// /// A builder for the *insert* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::ContentCategory; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ContentCategoryInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: ContentCategory, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryInsertCall<'a, S> {} impl<'a, S> ContentCategoryInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ContentCategory)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of content categories, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().list("profileId") /// .sort_order("sit") /// .sort_field("magna") /// .search_string("et") /// .page_token("rebum.") /// .max_results(-4) /// .add_ids("Lorem") /// .doit().await; /// # } /// ``` pub struct ContentCategoryListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryListCall<'a, S> {} impl<'a, S> ContentCategoryListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ContentCategoriesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ContentCategoryListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only content categories with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> ContentCategoryListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing content category. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::ContentCategory; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct ContentCategoryPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: ContentCategory, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryPatchCall<'a, S> {} impl<'a, S> ContentCategoryPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ContentCategory)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Content category ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ContentCategoryPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing content category. /// /// A builder for the *update* method supported by a *contentCategory* resource. /// It is not used directly, but through a `ContentCategoryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::ContentCategory; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ContentCategory::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.content_categories().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ContentCategoryUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: ContentCategory, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ContentCategoryUpdateCall<'a, S> {} impl<'a, S> ContentCategoryUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ContentCategory)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.contentCategories.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/contentCategories"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ContentCategory) -> ContentCategoryUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ContentCategoryUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ContentCategoryUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ContentCategoryUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ContentCategoryUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts conversions. /// /// A builder for the *batchinsert* method supported by a *conversion* resource. /// It is not used directly, but through a `ConversionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::ConversionsBatchInsertRequest; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ConversionsBatchInsertRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.conversions().batchinsert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ConversionBatchinsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: ConversionsBatchInsertRequest, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ConversionBatchinsertCall<'a, S> {} impl<'a, S> ConversionBatchinsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ConversionsBatchInsertResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.conversions.batchinsert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/conversions/batchinsert"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Ddmconversion.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ConversionsBatchInsertRequest) -> ConversionBatchinsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ConversionBatchinsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ConversionBatchinsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ConversionBatchinsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Ddmconversion`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ConversionBatchinsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates existing conversions. /// /// A builder for the *batchupdate* method supported by a *conversion* resource. /// It is not used directly, but through a `ConversionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::ConversionsBatchUpdateRequest; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = ConversionsBatchUpdateRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.conversions().batchupdate(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ConversionBatchupdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: ConversionsBatchUpdateRequest, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ConversionBatchupdateCall<'a, S> {} impl<'a, S> ConversionBatchupdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ConversionsBatchUpdateResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.conversions.batchupdate", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/conversions/batchupdate"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Ddmconversion.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: ConversionsBatchUpdateRequest) -> ConversionBatchupdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ConversionBatchupdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ConversionBatchupdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ConversionBatchupdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Ddmconversion`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ConversionBatchupdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one country by ID. /// /// A builder for the *get* method supported by a *country* resource. /// It is not used directly, but through a `CountryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.countries().get("profileId", "dartId") /// .doit().await; /// # } /// ``` pub struct CountryGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _dart_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CountryGetCall<'a, S> {} impl<'a, S> CountryGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Country)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.countries.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("dartId", self._dart_id.to_string())); for &field in ["alt", "profileId", "dartId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/countries/{dartId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["dartId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CountryGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Country DART ID. /// /// Sets the *dart id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn dart_id(mut self, new_value: &str) -> CountryGetCall<'a, S> { self._dart_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CountryGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CountryGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CountryGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of countries. /// /// A builder for the *list* method supported by a *country* resource. /// It is not used directly, but through a `CountryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.countries().list("profileId") /// .doit().await; /// # } /// ``` pub struct CountryListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CountryListCall<'a, S> {} impl<'a, S> CountryListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CountriesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.countries.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/countries"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CountryListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CountryListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CountryListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CountryListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new creative asset. /// /// A builder for the *insert* method supported by a *creativeAsset* resource. /// It is not used directly, but through a `CreativeAssetMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeAssetMetadata; /// use std::fs; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeAssetMetadata::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `upload(...)`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_assets().insert(req, "profileId", "advertiserId") /// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; /// # } /// ``` pub struct CreativeAssetInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeAssetMetadata, _profile_id: String, _advertiser_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeAssetInsertCall<'a, S> {} impl<'a, S> CreativeAssetInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> client::Result<(hyper::Response, CreativeAssetMetadata)> where RS: client::ReadSeek { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeAssets.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("advertiserId", self._advertiser_id.to_string())); for &field in ["alt", "profileId", "advertiserId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let (mut url, upload_type) = if protocol == "resumable" { (self.hub._root_url.clone() + "resumable/upload/dfareporting/v3.2/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets", "resumable") } else if protocol == "simple" { (self.hub._root_url.clone() + "upload/dfareporting/v3.2/userprofiles/{profileId}/creativeAssets/{advertiserId}/creativeAssets", "multipart") } else { unreachable!() }; params.push(("uploadType", upload_type.to_string())); if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{advertiserId}", "advertiserId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["advertiserId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut should_ask_dlg_for_url = false; let mut upload_url_from_server; let mut upload_url: Option = None; loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() { should_ask_dlg_for_url = false; upload_url_from_server = false; Ok(hyper::Response::builder() .status(hyper::StatusCode::OK) .header("Location", upload_url.as_ref().unwrap().clone()) .body(hyper::body::Body::empty()) .unwrap()) } else { let mut mp_reader: client::MultiPartReader = Default::default(); let (mut body_reader, content_type) = match protocol { "simple" => { mp_reader.reserve_exact(2); let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 1073741824 { return Err(client::Error::UploadSizeLimitExceeded(size, 1073741824)) } mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) .add_part(&mut reader, size, reader_mime_type.clone()); let mime_type = mp_reader.mime_type(); (&mut mp_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, mime_type.to_string())) }, _ => (&mut request_value_reader as &mut (dyn io::Read + Send), (CONTENT_TYPE, json_mime_type.to_string())), }; let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); upload_url_from_server = true; if protocol == "resumable" { req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); } let mut body_reader_bytes = vec![]; body_reader.read_to_end(&mut body_reader_bytes).unwrap(); let request = req_builder .header(content_type.0, content_type.1.to_string()) .body(hyper::body::Body::from(body_reader_bytes)); client.request(request.unwrap()).await } }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } if protocol == "resumable" { let size = reader.seek(io::SeekFrom::End(0)).unwrap(); reader.seek(io::SeekFrom::Start(0)).unwrap(); if size > 1073741824 { return Err(client::Error::UploadSizeLimitExceeded(size, 1073741824)) } let upload_result = { let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); if upload_url_from_server { dlg.store_upload_url(Some(url_str)); } client::ResumableUploadHelper { client: &self.hub.client, delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, auth: &self.hub.auth, user_agent: &self.hub._user_agent, auth_header: format!("Bearer {}", token.as_str()), url: url_str, reader: &mut reader, media_type: reader_mime_type.clone(), content_length: size }.upload().await }; match upload_result { None => { dlg.finished(false); return Err(client::Error::Cancelled) } Some(Err(err)) => { dlg.finished(false); return Err(client::Error::HttpError(err)) } Some(Ok(upload_result)) => { res = upload_result; if !res.status().is_success() { dlg.store_upload_url(None); dlg.finished(false); return Err(client::Error::Failure(res)) } } } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Upload media in a resumable fashion. /// Even if the upload fails or is interrupted, it can be resumed for a /// certain amount of time as the server maintains state temporarily. /// /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using /// `cancel_chunk_upload(...)`. /// /// * *multipart*: yes /// * *max size*: 1024MB /// * *valid mime types*: '*/*' pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, CreativeAssetMetadata)> where RS: client::ReadSeek { self.doit(resumeable_stream, mime_type, "resumable").await } /// Upload media all at once. /// If the upload fails for whichever reason, all progress is lost. /// /// * *multipart*: yes /// * *max size*: 1024MB /// * *valid mime types*: '*/*' pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, CreativeAssetMetadata)> where RS: client::ReadSeek { self.doit(stream, mime_type, "simple").await } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeAssetMetadata) -> CreativeAssetInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Advertiser ID of this creative. This is a required field. /// /// Sets the *advertiser id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn advertiser_id(mut self, new_value: &str) -> CreativeAssetInsertCall<'a, S> { self._advertiser_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeAssetInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeAssetInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeAssetInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing creative field value. /// /// A builder for the *delete* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().delete("profileId", "creativeFieldId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValueDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _creative_field_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValueDeleteCall<'a, S> {} impl<'a, S> CreativeFieldValueDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "creativeFieldId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["id", "creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// Creative Field Value ID /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldValueDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValueDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValueDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValueDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one creative field value by ID. /// /// A builder for the *get* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().get("profileId", "creativeFieldId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValueGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _creative_field_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValueGetCall<'a, S> {} impl<'a, S> CreativeFieldValueGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldValue)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["id", "creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// Creative Field Value ID /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldValueGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValueGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValueGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValueGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new creative field value. /// /// A builder for the *insert* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeFieldValue; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeFieldValue::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().insert(req, "profileId", "creativeFieldId") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValueInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeFieldValue, _profile_id: String, _creative_field_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValueInsertCall<'a, S> {} impl<'a, S> CreativeFieldValueInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldValue)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); for &field in ["alt", "profileId", "creativeFieldId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueInsertCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValueInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValueInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValueInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of creative field values, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().list("profileId", "creativeFieldId") /// .sort_order("duo") /// .sort_field("sadipscing") /// .search_string("ut") /// .page_token("rebum.") /// .max_results(-70) /// .add_ids("kasd") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValueListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _creative_field_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValueListCall<'a, S> {} impl<'a, S> CreativeFieldValueListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldValuesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "creativeFieldId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Allows searching for creative field values by their values. Wildcards (e.g. *) are not allowed. /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CreativeFieldValueListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only creative field values with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> CreativeFieldValueListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValueListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValueListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValueListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative field value. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeFieldValue; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeFieldValue::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().patch(req, "profileId", "creativeFieldId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValuePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeFieldValue, _profile_id: String, _creative_field_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValuePatchCall<'a, S> {} impl<'a, S> CreativeFieldValuePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldValue)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "creativeFieldId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValuePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// Creative Field Value ID /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldValuePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValuePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValuePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValuePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative field value. /// /// A builder for the *update* method supported by a *creativeFieldValue* resource. /// It is not used directly, but through a `CreativeFieldValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeFieldValue; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeFieldValue::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_field_values().update(req, "profileId", "creativeFieldId") /// .doit().await; /// # } /// ``` pub struct CreativeFieldValueUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeFieldValue, _profile_id: String, _creative_field_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldValueUpdateCall<'a, S> {} impl<'a, S> CreativeFieldValueUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldValue)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFieldValues.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("creativeFieldId", self._creative_field_id.to_string())); for &field in ["alt", "profileId", "creativeFieldId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{creativeFieldId}/creativeFieldValues"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{creativeFieldId}", "creativeFieldId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["creativeFieldId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeFieldValue) -> CreativeFieldValueUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative field ID for this creative field value. /// /// Sets the *creative field id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn creative_field_id(mut self, new_value: &str) -> CreativeFieldValueUpdateCall<'a, S> { self._creative_field_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldValueUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldValueUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldValueUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing creative field. /// /// A builder for the *delete* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldDeleteCall<'a, S> {} impl<'a, S> CreativeFieldDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative Field ID /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one creative field by ID. /// /// A builder for the *get* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldGetCall<'a, S> {} impl<'a, S> CreativeFieldGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeField)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative Field ID /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new creative field. /// /// A builder for the *insert* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeField; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeFieldInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeField, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldInsertCall<'a, S> {} impl<'a, S> CreativeFieldInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeField)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeField) -> CreativeFieldInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of creative fields, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().list("profileId") /// .sort_order("Stet") /// .sort_field("aliquyam") /// .search_string("ut") /// .page_token("sit") /// .max_results(-26) /// .add_ids("rebum.") /// .add_advertiser_ids("dolores") /// .doit().await; /// # } /// ``` pub struct CreativeFieldListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldListCall<'a, S> {} impl<'a, S> CreativeFieldListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeFieldsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CreativeFieldListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only creative fields with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only creative fields that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeFieldListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative field. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeField; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeFieldPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeField, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldPatchCall<'a, S> {} impl<'a, S> CreativeFieldPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeField)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeField) -> CreativeFieldPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative Field ID /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeFieldPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative field. /// /// A builder for the *update* method supported by a *creativeField* resource. /// It is not used directly, but through a `CreativeFieldMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeField; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeField::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_fields().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeFieldUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeField, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeFieldUpdateCall<'a, S> {} impl<'a, S> CreativeFieldUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeField)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeFields.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeFields"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeField) -> CreativeFieldUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeFieldUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeFieldUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeFieldUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeFieldUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one creative group by ID. /// /// A builder for the *get* method supported by a *creativeGroup* resource. /// It is not used directly, but through a `CreativeGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGroupGetCall<'a, S> {} impl<'a, S> CreativeGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new creative group. /// /// A builder for the *insert* method supported by a *creativeGroup* resource. /// It is not used directly, but through a `CreativeGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeGroupInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGroupInsertCall<'a, S> {} impl<'a, S> CreativeGroupInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeGroups.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGroupInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGroupInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGroupInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGroupInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of creative groups, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *creativeGroup* resource. /// It is not used directly, but through a `CreativeGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().list("profileId") /// .sort_order("magna") /// .sort_field("diam") /// .search_string("nonumy") /// .page_token("et") /// .max_results(-8) /// .add_ids("accusam") /// .group_number(-39) /// .add_advertiser_ids("sed") /// .doit().await; /// # } /// ``` pub struct CreativeGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _group_number: Option, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGroupListCall<'a, S> {} impl<'a, S> CreativeGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(11 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._group_number { params.push(("groupNumber", value.to_string())); } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "groupNumber", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CreativeGroupListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only creative groups with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only creative groups that belong to this subgroup. /// /// Sets the *group number* query property to the given value. pub fn group_number(mut self, new_value: i32) -> CreativeGroupListCall<'a, S> { self._group_number = Some(new_value); self } /// Select only creative groups that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> CreativeGroupListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative group. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *creativeGroup* resource. /// It is not used directly, but through a `CreativeGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeGroupPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeGroup, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGroupPatchCall<'a, S> {} impl<'a, S> CreativeGroupPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeGroups.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative group ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeGroupPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGroupPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGroupPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGroupPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative group. /// /// A builder for the *update* method supported by a *creativeGroup* resource. /// It is not used directly, but through a `CreativeGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::CreativeGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = CreativeGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creative_groups().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeGroupUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: CreativeGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGroupUpdateCall<'a, S> {} impl<'a, S> CreativeGroupUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativeGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creativeGroups.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creativeGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: CreativeGroup) -> CreativeGroupUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGroupUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGroupUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGroupUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGroupUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one creative by ID. /// /// A builder for the *get* method supported by a *creative* resource. /// It is not used directly, but through a `CreativeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativeGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeGetCall<'a, S> {} impl<'a, S> CreativeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Creative)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creatives.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativeGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new creative. /// /// A builder for the *insert* method supported by a *creative* resource. /// It is not used directly, but through a `CreativeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Creative; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Creative, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeInsertCall<'a, S> {} impl<'a, S> CreativeInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Creative)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creatives.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Creative) -> CreativeInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of creatives, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *creative* resource. /// It is not used directly, but through a `CreativeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().list("profileId") /// .add_types("ipsum") /// .studio_creative_id("accusam") /// .sort_order("dolores") /// .sort_field("consetetur") /// .add_size_ids("no") /// .search_string("justo") /// .add_rendering_ids("sadipscing") /// .page_token("diam") /// .max_results(-10) /// .add_ids("ipsum") /// .add_creative_field_ids("Stet") /// .add_companion_creative_ids("gubergren") /// .campaign_id("ipsum") /// .archived(true) /// .advertiser_id("sit") /// .active(true) /// .doit().await; /// # } /// ``` pub struct CreativeListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _types: Vec, _studio_creative_id: Option, _sort_order: Option, _sort_field: Option, _size_ids: Vec, _search_string: Option, _rendering_ids: Vec, _page_token: Option, _max_results: Option, _ids: Vec, _creative_field_ids: Vec, _companion_creative_ids: Vec, _campaign_id: Option, _archived: Option, _advertiser_id: Option, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeListCall<'a, S> {} impl<'a, S> CreativeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CreativesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creatives.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(19 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._types.len() > 0 { for f in self._types.iter() { params.push(("types", f.to_string())); } } if let Some(value) = self._studio_creative_id { params.push(("studioCreativeId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._size_ids.len() > 0 { for f in self._size_ids.iter() { params.push(("sizeIds", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if self._rendering_ids.len() > 0 { for f in self._rendering_ids.iter() { params.push(("renderingIds", f.to_string())); } } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._creative_field_ids.len() > 0 { for f in self._creative_field_ids.iter() { params.push(("creativeFieldIds", f.to_string())); } } if self._companion_creative_ids.len() > 0 { for f in self._companion_creative_ids.iter() { params.push(("companionCreativeIds", f.to_string())); } } if let Some(value) = self._campaign_id { params.push(("campaignId", value.to_string())); } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "types", "studioCreativeId", "sortOrder", "sortField", "sizeIds", "searchString", "renderingIds", "pageToken", "maxResults", "ids", "creativeFieldIds", "companionCreativeIds", "campaignId", "archived", "advertiserId", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only creatives with these creative types. /// /// Append the given value to the *types* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_types(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._types.push(new_value.to_string()); self } /// Select only creatives corresponding to this Studio creative ID. /// /// Sets the *studio creative id* query property to the given value. pub fn studio_creative_id(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._studio_creative_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only creatives with these size IDs. /// /// Append the given value to the *size ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_size_ids(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._size_ids.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only creatives with these rendering IDs. /// /// Append the given value to the *rendering ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_rendering_ids(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._rendering_ids.push(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> CreativeListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only creatives with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only creatives with these creative field IDs. /// /// Append the given value to the *creative field ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_creative_field_ids(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._creative_field_ids.push(new_value.to_string()); self } /// Select only in-stream video creatives with these companion IDs. /// /// Append the given value to the *companion creative ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_companion_creative_ids(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._companion_creative_ids.push(new_value.to_string()); self } /// Select only creatives with this campaign ID. /// /// Sets the *campaign id* query property to the given value. pub fn campaign_id(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._campaign_id = Some(new_value.to_string()); self } /// Select only archived creatives. Leave blank to select archived and unarchived creatives. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> CreativeListCall<'a, S> { self._archived = Some(new_value); self } /// Select only creatives with this advertiser ID. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> CreativeListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// Select only active creatives. Leave blank to select active and inactive creatives. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> CreativeListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *creative* resource. /// It is not used directly, but through a `CreativeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Creative; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct CreativePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Creative, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativePatchCall<'a, S> {} impl<'a, S> CreativePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Creative)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creatives.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Creative) -> CreativePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Creative ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> CreativePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing creative. /// /// A builder for the *update* method supported by a *creative* resource. /// It is not used directly, but through a `CreativeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Creative; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Creative::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.creatives().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct CreativeUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Creative, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for CreativeUpdateCall<'a, S> {} impl<'a, S> CreativeUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Creative)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.creatives.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/creatives"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Creative) -> CreativeUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> CreativeUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CreativeUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> CreativeUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> CreativeUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves list of report dimension values for a list of filters. /// /// A builder for the *query* method supported by a *dimensionValue* resource. /// It is not used directly, but through a `DimensionValueMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::DimensionValueRequest; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = DimensionValueRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.dimension_values().query(req, "profileId") /// .page_token("nonumy") /// .max_results(-10) /// .doit().await; /// # } /// ``` pub struct DimensionValueQueryCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: DimensionValueRequest, _profile_id: String, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DimensionValueQueryCall<'a, S> {} impl<'a, S> DimensionValueQueryCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DimensionValueList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.dimensionValues.query", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } for &field in ["alt", "profileId", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dimensionvalues/query"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: DimensionValueRequest) -> DimensionValueQueryCall<'a, S> { self._request = new_value; self } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DimensionValueQueryCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The value of the nextToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DimensionValueQueryCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> DimensionValueQueryCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DimensionValueQueryCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DimensionValueQueryCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DimensionValueQueryCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one directory site contact by ID. /// /// A builder for the *get* method supported by a *directorySiteContact* resource. /// It is not used directly, but through a `DirectorySiteContactMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_site_contacts().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct DirectorySiteContactGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DirectorySiteContactGetCall<'a, S> {} impl<'a, S> DirectorySiteContactGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DirectorySiteContact)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.directorySiteContacts.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySiteContacts/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Directory site contact ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> DirectorySiteContactGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DirectorySiteContactGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DirectorySiteContactGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DirectorySiteContactGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of directory site contacts, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *directorySiteContact* resource. /// It is not used directly, but through a `DirectorySiteContactMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_site_contacts().list("profileId") /// .sort_order("ea") /// .sort_field("At") /// .search_string("erat") /// .page_token("clita") /// .max_results(-76) /// .add_ids("invidunt") /// .add_directory_site_ids("nonumy") /// .doit().await; /// # } /// ``` pub struct DirectorySiteContactListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _directory_site_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DirectorySiteContactListCall<'a, S> {} impl<'a, S> DirectorySiteContactListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DirectorySiteContactsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.directorySiteContacts.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._directory_site_ids.len() > 0 { for f in self._directory_site_ids.iter() { params.push(("directorySiteIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySiteContacts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> DirectorySiteContactListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only directory site contacts with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only directory site contacts with these directory site IDs. This is a required field. /// /// Append the given value to the *directory site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_directory_site_ids(mut self, new_value: &str) -> DirectorySiteContactListCall<'a, S> { self._directory_site_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DirectorySiteContactListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DirectorySiteContactListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DirectorySiteContactListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one directory site by ID. /// /// A builder for the *get* method supported by a *directorySite* resource. /// It is not used directly, but through a `DirectorySiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_sites().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct DirectorySiteGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DirectorySiteGetCall<'a, S> {} impl<'a, S> DirectorySiteGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DirectorySite)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.directorySites.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Directory site ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> DirectorySiteGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DirectorySiteGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DirectorySiteGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DirectorySiteGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new directory site. /// /// A builder for the *insert* method supported by a *directorySite* resource. /// It is not used directly, but through a `DirectorySiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::DirectorySite; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = DirectorySite::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_sites().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct DirectorySiteInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: DirectorySite, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DirectorySiteInsertCall<'a, S> {} impl<'a, S> DirectorySiteInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DirectorySite)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.directorySites.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: DirectorySite) -> DirectorySiteInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DirectorySiteInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DirectorySiteInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DirectorySiteInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DirectorySiteInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of directory sites, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *directorySite* resource. /// It is not used directly, but through a `DirectorySiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.directory_sites().list("profileId") /// .sort_order("voluptua.") /// .sort_field("eos") /// .search_string("duo") /// .parent_id("elitr") /// .page_token("consetetur") /// .max_results(-72) /// .add_ids("clita") /// .dfp_network_code("sit") /// .country_id("takimata") /// .active(true) /// .accepts_publisher_paid_placements(true) /// .accepts_interstitial_placements(false) /// .accepts_in_stream_video_placements(false) /// .doit().await; /// # } /// ``` pub struct DirectorySiteListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _parent_id: Option, _page_token: Option, _max_results: Option, _ids: Vec, _dfp_network_code: Option, _country_id: Option, _active: Option, _accepts_publisher_paid_placements: Option, _accepts_interstitial_placements: Option, _accepts_in_stream_video_placements: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DirectorySiteListCall<'a, S> {} impl<'a, S> DirectorySiteListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DirectorySitesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.directorySites.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(16 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._parent_id { params.push(("parentId", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._dfp_network_code { params.push(("dfpNetworkCode", value.to_string())); } if let Some(value) = self._country_id { params.push(("countryId", value.to_string())); } if let Some(value) = self._active { params.push(("active", value.to_string())); } if let Some(value) = self._accepts_publisher_paid_placements { params.push(("acceptsPublisherPaidPlacements", value.to_string())); } if let Some(value) = self._accepts_interstitial_placements { params.push(("acceptsInterstitialPlacements", value.to_string())); } if let Some(value) = self._accepts_in_stream_video_placements { params.push(("acceptsInStreamVideoPlacements", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "parentId", "pageToken", "maxResults", "ids", "dfpNetworkCode", "countryId", "active", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/directorySites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only directory sites with this parent ID. /// /// Sets the *parent id* query property to the given value. pub fn parent_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._parent_id = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> DirectorySiteListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only directory sites with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only directory sites with this Ad Manager network code. /// /// Sets the *dfp network code* query property to the given value. pub fn dfp_network_code(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._dfp_network_code = Some(new_value.to_string()); self } /// Select only directory sites with this country ID. /// /// Sets the *country id* query property to the given value. pub fn country_id(mut self, new_value: &str) -> DirectorySiteListCall<'a, S> { self._country_id = Some(new_value.to_string()); self } /// Select only active directory sites. Leave blank to retrieve both active and inactive directory sites. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> DirectorySiteListCall<'a, S> { self._active = Some(new_value); self } /// Select only directory sites that accept publisher paid placements. This field can be left blank. /// /// Sets the *accepts publisher paid placements* query property to the given value. pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, S> { self._accepts_publisher_paid_placements = Some(new_value); self } /// This search filter is no longer supported and will have no effect on the results returned. /// /// Sets the *accepts interstitial placements* query property to the given value. pub fn accepts_interstitial_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, S> { self._accepts_interstitial_placements = Some(new_value); self } /// This search filter is no longer supported and will have no effect on the results returned. /// /// Sets the *accepts in stream video placements* query property to the given value. pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> DirectorySiteListCall<'a, S> { self._accepts_in_stream_video_placements = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DirectorySiteListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DirectorySiteListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DirectorySiteListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing dynamic targeting key. /// /// A builder for the *delete* method supported by a *dynamicTargetingKey* resource. /// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.dynamic_targeting_keys().delete("profileId", "objectId", "name", "objectType") /// .doit().await; /// # } /// ``` pub struct DynamicTargetingKeyDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _object_id: String, _name: String, _object_type: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DynamicTargetingKeyDeleteCall<'a, S> {} impl<'a, S> DynamicTargetingKeyDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.dynamicTargetingKeys.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("objectId", self._object_id.to_string())); params.push(("name", self._name.to_string())); params.push(("objectType", self._object_type.to_string())); for &field in ["profileId", "objectId", "name", "objectType"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys/{objectId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{objectId}", "objectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["objectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// ID of the object of this dynamic targeting key. This is a required field. /// /// Sets the *object id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn object_id(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, S> { self._object_id = new_value.to_string(); self } /// 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. /// /// Sets the *name* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, S> { self._name = new_value.to_string(); self } /// Type of the object of this dynamic targeting key. This is a required field. /// /// Sets the *object type* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyDeleteCall<'a, S> { self._object_type = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DynamicTargetingKeyDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DynamicTargetingKeyDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DynamicTargetingKeyDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *insert* method supported by a *dynamicTargetingKey* resource. /// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::DynamicTargetingKey; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = DynamicTargetingKey::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.dynamic_targeting_keys().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct DynamicTargetingKeyInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: DynamicTargetingKey, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DynamicTargetingKeyInsertCall<'a, S> {} impl<'a, S> DynamicTargetingKeyInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DynamicTargetingKey)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.dynamicTargetingKeys.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: DynamicTargetingKey) -> DynamicTargetingKeyInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DynamicTargetingKeyInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DynamicTargetingKeyInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DynamicTargetingKeyInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DynamicTargetingKeyInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of dynamic targeting keys. /// /// A builder for the *list* method supported by a *dynamicTargetingKey* resource. /// It is not used directly, but through a `DynamicTargetingKeyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.dynamic_targeting_keys().list("profileId") /// .object_type("ea") /// .object_id("At") /// .add_names("sit") /// .advertiser_id("sit") /// .doit().await; /// # } /// ``` pub struct DynamicTargetingKeyListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _object_type: Option, _object_id: Option, _names: Vec, _advertiser_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for DynamicTargetingKeyListCall<'a, S> {} impl<'a, S> DynamicTargetingKeyListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, DynamicTargetingKeysListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.dynamicTargetingKeys.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._object_type { params.push(("objectType", value.to_string())); } if let Some(value) = self._object_id { params.push(("objectId", value.to_string())); } if self._names.len() > 0 { for f in self._names.iter() { params.push(("names", f.to_string())); } } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } for &field in ["alt", "profileId", "objectType", "objectId", "names", "advertiserId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/dynamicTargetingKeys"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only dynamic targeting keys with this object type. /// /// Sets the *object type* query property to the given value. pub fn object_type(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, S> { self._object_type = Some(new_value.to_string()); self } /// Select only dynamic targeting keys with this object ID. /// /// Sets the *object id* query property to the given value. pub fn object_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, S> { self._object_id = Some(new_value.to_string()); self } /// Select only dynamic targeting keys exactly matching these names. /// /// Append the given value to the *names* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_names(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, S> { self._names.push(new_value.to_string()); self } /// Select only dynamic targeting keys whose object has this advertiser ID. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> DynamicTargetingKeyListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DynamicTargetingKeyListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> DynamicTargetingKeyListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> DynamicTargetingKeyListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing event tag. /// /// A builder for the *delete* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct EventTagDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagDeleteCall<'a, S> {} impl<'a, S> EventTagDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Event tag ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> EventTagDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one event tag by ID. /// /// A builder for the *get* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct EventTagGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagGetCall<'a, S> {} impl<'a, S> EventTagGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EventTag)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Event tag ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> EventTagGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new event tag. /// /// A builder for the *insert* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::EventTag; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct EventTagInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: EventTag, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagInsertCall<'a, S> {} impl<'a, S> EventTagInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EventTag)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: EventTag) -> EventTagInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of event tags, possibly filtered. /// /// A builder for the *list* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().list("profileId") /// .sort_order("ut") /// .sort_field("et") /// .search_string("Lorem") /// .add_ids("rebum.") /// .add_event_tag_types("et") /// .enabled(true) /// .definitions_only(false) /// .campaign_id("kasd") /// .advertiser_id("Lorem") /// .ad_id("sit") /// .doit().await; /// # } /// ``` pub struct EventTagListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _ids: Vec, _event_tag_types: Vec, _enabled: Option, _definitions_only: Option, _campaign_id: Option, _advertiser_id: Option, _ad_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagListCall<'a, S> {} impl<'a, S> EventTagListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EventTagsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._event_tag_types.len() > 0 { for f in self._event_tag_types.iter() { params.push(("eventTagTypes", f.to_string())); } } if let Some(value) = self._enabled { params.push(("enabled", value.to_string())); } if let Some(value) = self._definitions_only { params.push(("definitionsOnly", value.to_string())); } if let Some(value) = self._campaign_id { params.push(("campaignId", value.to_string())); } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } if let Some(value) = self._ad_id { params.push(("adId", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "ids", "eventTagTypes", "enabled", "definitionsOnly", "campaignId", "advertiserId", "adId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only event tags with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// 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. /// /// Append the given value to the *event tag types* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_event_tag_types(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._event_tag_types.push(new_value.to_string()); self } /// 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. /// /// Sets the *enabled* query property to the given value. pub fn enabled(mut self, new_value: bool) -> EventTagListCall<'a, S> { self._enabled = Some(new_value); self } /// 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. /// /// Sets the *definitions only* query property to the given value. pub fn definitions_only(mut self, new_value: bool) -> EventTagListCall<'a, S> { self._definitions_only = Some(new_value); self } /// Select only event tags that belong to this campaign. /// /// Sets the *campaign id* query property to the given value. pub fn campaign_id(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._campaign_id = Some(new_value.to_string()); self } /// Select only event tags that belong to this advertiser. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// Select only event tags that belong to this ad. /// /// Sets the *ad id* query property to the given value. pub fn ad_id(mut self, new_value: &str) -> EventTagListCall<'a, S> { self._ad_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing event tag. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::EventTag; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct EventTagPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: EventTag, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagPatchCall<'a, S> {} impl<'a, S> EventTagPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EventTag)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: EventTag) -> EventTagPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Event tag ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> EventTagPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing event tag. /// /// A builder for the *update* method supported by a *eventTag* resource. /// It is not used directly, but through a `EventTagMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::EventTag; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = EventTag::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.event_tags().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct EventTagUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: EventTag, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for EventTagUpdateCall<'a, S> {} impl<'a, S> EventTagUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, EventTag)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.eventTags.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/eventTags"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: EventTag) -> EventTagUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> EventTagUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> EventTagUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> EventTagUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> EventTagUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a report file by its report ID and file ID. This method supports media download. /// /// This method supports **media download**. To enable it, adjust the builder like this: /// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `File` structure that you would usually get. The latter will be a default value. /// /// A builder for the *get* method supported by a *file* resource. /// It is not used directly, but through a `FileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().get("reportId", "fileId") /// .doit().await; /// # } /// ``` pub struct FileGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _report_id: String, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FileGetCall<'a, S> {} impl<'a, S> FileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.files.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("reportId", self._report_id.to_string())); params.push(("fileId", self._file_id.to_string())); for &field in ["reportId", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let (json_field_missing, enable_resource_parsing) = { let mut enable = true; let mut field_present = true; for &(name, ref value) in params.iter() { if name == "alt" { field_present = false; if >::as_ref(&value) != "json" { enable = false; } break; } } (field_present, enable) }; if json_field_missing { params.push(("alt", "json".to_string())); } let mut url = self.hub._base_url.clone() + "reports/{reportId}/files/{fileId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{reportId}", "reportId"), ("{fileId}", "fileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["fileId", "reportId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = if enable_resource_parsing { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } } else { (res, Default::default()) }; dlg.finished(true); return Ok(result_value) } } } } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> FileGetCall<'a, S> { self._report_id = new_value.to_string(); self } /// The ID of the report file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> FileGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FileGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists files for a user profile. /// /// A builder for the *list* method supported by a *file* resource. /// It is not used directly, but through a `FileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.files().list("profileId") /// .sort_order("sea") /// .sort_field("ipsum") /// .scope("ipsum") /// .page_token("et") /// .max_results(-94) /// .doit().await; /// # } /// ``` pub struct FileListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _scope: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FileListCall<'a, S> {} impl<'a, S> FileListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FileList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.files.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._scope { params.push(("scope", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/files"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FileListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> FileListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// The field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> FileListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// The scope that defines which results are returned. /// /// Sets the *scope* query property to the given value. pub fn scope(mut self, new_value: &str) -> FileListCall<'a, S> { self._scope = Some(new_value.to_string()); self } /// The value of the nextToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FileListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FileListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FileListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing floodlight activity. /// /// A builder for the *delete* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityDeleteCall<'a, S> {} impl<'a, S> FloodlightActivityDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightActivityDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Generates a tag for a floodlight activity. /// /// A builder for the *generatetag* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().generatetag("profileId") /// .floodlight_activity_id("dolor") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGeneratetagCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _floodlight_activity_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGeneratetagCall<'a, S> {} impl<'a, S> FloodlightActivityGeneratetagCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivitiesGenerateTagResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.generatetag", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._floodlight_activity_id { params.push(("floodlightActivityId", value.to_string())); } for &field in ["alt", "profileId", "floodlightActivityId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities/generatetag"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity ID for which we want to generate a tag. /// /// Sets the *floodlight activity id* query property to the given value. pub fn floodlight_activity_id(mut self, new_value: &str) -> FloodlightActivityGeneratetagCall<'a, S> { self._floodlight_activity_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGeneratetagCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGeneratetagCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGeneratetagCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one floodlight activity by ID. /// /// A builder for the *get* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGetCall<'a, S> {} impl<'a, S> FloodlightActivityGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivity)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightActivityGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new floodlight activity. /// /// A builder for the *insert* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivity; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivity, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityInsertCall<'a, S> {} impl<'a, S> FloodlightActivityInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivity)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of floodlight activities, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().list("profileId") /// .tag_string("Lorem") /// .sort_order("nonumy") /// .sort_field("diam") /// .search_string("ipsum") /// .page_token("invidunt") /// .max_results(-15) /// .add_ids("voluptua.") /// .floodlight_configuration_id("At") /// .floodlight_activity_group_type("diam") /// .floodlight_activity_group_tag_string("amet") /// .floodlight_activity_group_name("At") /// .add_floodlight_activity_group_ids("eirmod") /// .advertiser_id("erat") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _tag_string: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _floodlight_configuration_id: Option, _floodlight_activity_group_type: Option, _floodlight_activity_group_tag_string: Option, _floodlight_activity_group_name: Option, _floodlight_activity_group_ids: Vec, _advertiser_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityListCall<'a, S> {} impl<'a, S> FloodlightActivityListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivitiesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(16 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._tag_string { params.push(("tagString", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._floodlight_configuration_id { params.push(("floodlightConfigurationId", value.to_string())); } if let Some(value) = self._floodlight_activity_group_type { params.push(("floodlightActivityGroupType", value.to_string())); } if let Some(value) = self._floodlight_activity_group_tag_string { params.push(("floodlightActivityGroupTagString", value.to_string())); } if let Some(value) = self._floodlight_activity_group_name { params.push(("floodlightActivityGroupName", value.to_string())); } if self._floodlight_activity_group_ids.len() > 0 { for f in self._floodlight_activity_group_ids.iter() { params.push(("floodlightActivityGroupIds", f.to_string())); } } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } for &field in ["alt", "profileId", "tagString", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "floodlightActivityGroupType", "floodlightActivityGroupTagString", "floodlightActivityGroupName", "floodlightActivityGroupIds", "advertiserId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only floodlight activities with the specified tag string. /// /// Sets the *tag string* query property to the given value. pub fn tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._tag_string = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FloodlightActivityListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only floodlight activities with the specified IDs. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only floodlight activities for the specified floodlight configuration ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. /// /// Sets the *floodlight configuration id* query property to the given value. pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._floodlight_configuration_id = Some(new_value.to_string()); self } /// Select only floodlight activities with the specified floodlight activity group type. /// /// Sets the *floodlight activity group type* query property to the given value. pub fn floodlight_activity_group_type(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._floodlight_activity_group_type = Some(new_value.to_string()); self } /// Select only floodlight activities with the specified floodlight activity group tag string. /// /// Sets the *floodlight activity group tag string* query property to the given value. pub fn floodlight_activity_group_tag_string(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._floodlight_activity_group_tag_string = Some(new_value.to_string()); self } /// Select only floodlight activities with the specified floodlight activity group name. /// /// Sets the *floodlight activity group name* query property to the given value. pub fn floodlight_activity_group_name(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._floodlight_activity_group_name = Some(new_value.to_string()); self } /// Select only floodlight activities with the specified floodlight activity group IDs. /// /// Append the given value to the *floodlight activity group ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_floodlight_activity_group_ids(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._floodlight_activity_group_ids.push(new_value.to_string()); self } /// Select only floodlight activities for the specified advertiser ID. Must specify either ids, advertiserId, or floodlightConfigurationId for a non-empty result. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight activity. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivity; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivity, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityPatchCall<'a, S> {} impl<'a, S> FloodlightActivityPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivity)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightActivityPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight activity. /// /// A builder for the *update* method supported by a *floodlightActivity* resource. /// It is not used directly, but through a `FloodlightActivityMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivity; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivity::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activities().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivity, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityUpdateCall<'a, S> {} impl<'a, S> FloodlightActivityUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivity)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivities.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivities"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivity) -> FloodlightActivityUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one floodlight activity group by ID. /// /// A builder for the *get* method supported by a *floodlightActivityGroup* resource. /// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGroupGetCall<'a, S> {} impl<'a, S> FloodlightActivityGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivityGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivityGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity Group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightActivityGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new floodlight activity group. /// /// A builder for the *insert* method supported by a *floodlightActivityGroup* resource. /// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivityGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGroupInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivityGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGroupInsertCall<'a, S> {} impl<'a, S> FloodlightActivityGroupInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivityGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivityGroups.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGroupInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGroupInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGroupInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGroupInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of floodlight activity groups, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *floodlightActivityGroup* resource. /// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().list("profileId") /// .type_("accusam") /// .sort_order("ut") /// .sort_field("voluptua.") /// .search_string("consetetur") /// .page_token("dolor") /// .max_results(-47) /// .add_ids("et") /// .floodlight_configuration_id("aliquyam") /// .advertiser_id("ipsum") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _type_: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _floodlight_configuration_id: Option, _advertiser_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGroupListCall<'a, S> {} impl<'a, S> FloodlightActivityGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivityGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivityGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(12 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._type_ { params.push(("type", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._floodlight_configuration_id { params.push(("floodlightConfigurationId", value.to_string())); } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } for &field in ["alt", "profileId", "type", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "floodlightConfigurationId", "advertiserId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only floodlight activity groups with the specified floodlight activity group type. /// /// Sets the *type* query property to the given value. pub fn type_(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._type_ = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> FloodlightActivityGroupListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only floodlight activity groups with the specified IDs. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only floodlight activity groups with the specified floodlight configuration ID. Must specify either advertiserId, or floodlightConfigurationId for a non-empty result. /// /// Sets the *floodlight configuration id* query property to the given value. pub fn floodlight_configuration_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._floodlight_configuration_id = Some(new_value.to_string()); self } /// Select only floodlight activity groups with the specified advertiser ID. Must specify either advertiserId or floodlightConfigurationId for a non-empty result. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> FloodlightActivityGroupListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight activity group. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *floodlightActivityGroup* resource. /// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivityGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGroupPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivityGroup, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGroupPatchCall<'a, S> {} impl<'a, S> FloodlightActivityGroupPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivityGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivityGroups.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight activity Group ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightActivityGroupPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGroupPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGroupPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGroupPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight activity group. /// /// A builder for the *update* method supported by a *floodlightActivityGroup* resource. /// It is not used directly, but through a `FloodlightActivityGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightActivityGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightActivityGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_activity_groups().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct FloodlightActivityGroupUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightActivityGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightActivityGroupUpdateCall<'a, S> {} impl<'a, S> FloodlightActivityGroupUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightActivityGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightActivityGroups.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightActivityGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightActivityGroup) -> FloodlightActivityGroupUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightActivityGroupUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightActivityGroupUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightActivityGroupUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightActivityGroupUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one floodlight configuration by ID. /// /// A builder for the *get* method supported by a *floodlightConfiguration* resource. /// It is not used directly, but through a `FloodlightConfigurationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_configurations().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightConfigurationGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightConfigurationGetCall<'a, S> {} impl<'a, S> FloodlightConfigurationGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightConfiguration)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightConfigurations.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight configuration ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightConfigurationGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightConfigurationGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightConfigurationGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightConfigurationGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of floodlight configurations, possibly filtered. /// /// A builder for the *list* method supported by a *floodlightConfiguration* resource. /// It is not used directly, but through a `FloodlightConfigurationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_configurations().list("profileId") /// .add_ids("sadipscing") /// .doit().await; /// # } /// ``` pub struct FloodlightConfigurationListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightConfigurationListCall<'a, S> {} impl<'a, S> FloodlightConfigurationListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightConfigurationsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightConfigurations.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Set of IDs of floodlight configurations to retrieve. Required field; otherwise an empty list will be returned. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> FloodlightConfigurationListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightConfigurationListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightConfigurationListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightConfigurationListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight configuration. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *floodlightConfiguration* resource. /// It is not used directly, but through a `FloodlightConfigurationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightConfiguration; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_configurations().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct FloodlightConfigurationPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightConfiguration, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightConfigurationPatchCall<'a, S> {} impl<'a, S> FloodlightConfigurationPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightConfiguration)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightConfigurations.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightConfiguration) -> FloodlightConfigurationPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Floodlight configuration ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> FloodlightConfigurationPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightConfigurationPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightConfigurationPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightConfigurationPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing floodlight configuration. /// /// A builder for the *update* method supported by a *floodlightConfiguration* resource. /// It is not used directly, but through a `FloodlightConfigurationMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::FloodlightConfiguration; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = FloodlightConfiguration::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.floodlight_configurations().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct FloodlightConfigurationUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: FloodlightConfiguration, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for FloodlightConfigurationUpdateCall<'a, S> {} impl<'a, S> FloodlightConfigurationUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FloodlightConfiguration)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.floodlightConfigurations.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/floodlightConfigurations"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: FloodlightConfiguration) -> FloodlightConfigurationUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> FloodlightConfigurationUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FloodlightConfigurationUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> FloodlightConfigurationUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> FloodlightConfigurationUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one inventory item by ID. /// /// A builder for the *get* method supported by a *inventoryItem* resource. /// It is not used directly, but through a `InventoryItemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inventory_items().get("profileId", "projectId", "id") /// .doit().await; /// # } /// ``` pub struct InventoryItemGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for InventoryItemGetCall<'a, S> {} impl<'a, S> InventoryItemGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InventoryItem)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.inventoryItems.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "projectId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/inventoryItems/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["id", "projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for order documents. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> InventoryItemGetCall<'a, S> { self._project_id = new_value.to_string(); self } /// Inventory item ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> InventoryItemGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InventoryItemGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InventoryItemGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> InventoryItemGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of inventory items, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *inventoryItem* resource. /// It is not used directly, but through a `InventoryItemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.inventory_items().list("profileId", "projectId") /// .type_("vero") /// .sort_order("takimata") /// .sort_field("gubergren") /// .add_site_id("et") /// .page_token("invidunt") /// .add_order_id("magna") /// .max_results(-98) /// .in_plan(false) /// .add_ids("ipsum") /// .doit().await; /// # } /// ``` pub struct InventoryItemListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _type_: Option, _sort_order: Option, _sort_field: Option, _site_id: Vec, _page_token: Option, _order_id: Vec, _max_results: Option, _in_plan: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for InventoryItemListCall<'a, S> {} impl<'a, S> InventoryItemListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, InventoryItemsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.inventoryItems.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); if let Some(value) = self._type_ { params.push(("type", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._site_id.len() > 0 { for f in self._site_id.iter() { params.push(("siteId", f.to_string())); } } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if self._order_id.len() > 0 { for f in self._order_id.iter() { params.push(("orderId", f.to_string())); } } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._in_plan { params.push(("inPlan", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "projectId", "type", "sortOrder", "sortField", "siteId", "pageToken", "orderId", "maxResults", "inPlan", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/inventoryItems"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for order documents. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._project_id = new_value.to_string(); self } /// Select only inventory items with this type. /// /// Sets the *type* query property to the given value. pub fn type_(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._type_ = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only inventory items that are associated with these sites. /// /// Append the given value to the *site id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_site_id(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._site_id.push(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only inventory items that belong to specified orders. /// /// Append the given value to the *order id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_order_id(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._order_id.push(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> InventoryItemListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only inventory items that are in plan. /// /// Sets the *in plan* query property to the given value. pub fn in_plan(mut self, new_value: bool) -> InventoryItemListCall<'a, S> { self._in_plan = Some(new_value); self } /// Select only inventory items with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> InventoryItemListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> InventoryItemListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> InventoryItemListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> InventoryItemListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of languages. /// /// A builder for the *list* method supported by a *language* resource. /// It is not used directly, but through a `LanguageMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.languages().list("profileId") /// .doit().await; /// # } /// ``` pub struct LanguageListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for LanguageListCall<'a, S> {} impl<'a, S> LanguageListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, LanguagesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.languages.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/languages"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> LanguageListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LanguageListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> LanguageListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> LanguageListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of metros. /// /// A builder for the *list* method supported by a *metro* resource. /// It is not used directly, but through a `MetroMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.metros().list("profileId") /// .doit().await; /// # } /// ``` pub struct MetroListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for MetroListCall<'a, S> {} impl<'a, S> MetroListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, MetrosListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.metros.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/metros"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> MetroListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MetroListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> MetroListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MetroListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one mobile app by ID. /// /// A builder for the *get* method supported by a *mobileApp* resource. /// It is not used directly, but through a `MobileAppMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mobile_apps().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct MobileAppGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for MobileAppGetCall<'a, S> {} impl<'a, S> MobileAppGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, MobileApp)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.mobileApps.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileApps/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> MobileAppGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Mobile app ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> MobileAppGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MobileAppGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> MobileAppGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MobileAppGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves list of available mobile apps. /// /// A builder for the *list* method supported by a *mobileApp* resource. /// It is not used directly, but through a `MobileAppMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mobile_apps().list("profileId") /// .search_string("Lorem") /// .page_token("dolores") /// .max_results(-96) /// .add_ids("Stet") /// .add_directories("accusam") /// .doit().await; /// # } /// ``` pub struct MobileAppListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _directories: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for MobileAppListCall<'a, S> {} impl<'a, S> MobileAppListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, MobileAppsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.mobileApps.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._directories.len() > 0 { for f in self._directories.iter() { params.push(("directories", f.to_string())); } } for &field in ["alt", "profileId", "searchString", "pageToken", "maxResults", "ids", "directories"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileApps"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> MobileAppListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> MobileAppListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> MobileAppListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> MobileAppListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only apps with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> MobileAppListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only apps from these directories. /// /// Append the given value to the *directories* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_directories(mut self, new_value: &str) -> MobileAppListCall<'a, S> { self._directories.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MobileAppListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> MobileAppListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MobileAppListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one mobile carrier by ID. /// /// A builder for the *get* method supported by a *mobileCarrier* resource. /// It is not used directly, but through a `MobileCarrierMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mobile_carriers().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct MobileCarrierGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for MobileCarrierGetCall<'a, S> {} impl<'a, S> MobileCarrierGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, MobileCarrier)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.mobileCarriers.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileCarriers/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Mobile carrier ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> MobileCarrierGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MobileCarrierGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> MobileCarrierGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MobileCarrierGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of mobile carriers. /// /// A builder for the *list* method supported by a *mobileCarrier* resource. /// It is not used directly, but through a `MobileCarrierMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.mobile_carriers().list("profileId") /// .doit().await; /// # } /// ``` pub struct MobileCarrierListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for MobileCarrierListCall<'a, S> {} impl<'a, S> MobileCarrierListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, MobileCarriersListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.mobileCarriers.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/mobileCarriers"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> MobileCarrierListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MobileCarrierListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> MobileCarrierListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> MobileCarrierListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one operating system version by ID. /// /// A builder for the *get* method supported by a *operatingSystemVersion* resource. /// It is not used directly, but through a `OperatingSystemVersionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operating_system_versions().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct OperatingSystemVersionGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OperatingSystemVersionGetCall<'a, S> {} impl<'a, S> OperatingSystemVersionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OperatingSystemVersion)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.operatingSystemVersions.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystemVersions/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Operating system version ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> OperatingSystemVersionGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OperatingSystemVersionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OperatingSystemVersionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OperatingSystemVersionGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of operating system versions. /// /// A builder for the *list* method supported by a *operatingSystemVersion* resource. /// It is not used directly, but through a `OperatingSystemVersionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operating_system_versions().list("profileId") /// .doit().await; /// # } /// ``` pub struct OperatingSystemVersionListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OperatingSystemVersionListCall<'a, S> {} impl<'a, S> OperatingSystemVersionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OperatingSystemVersionsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.operatingSystemVersions.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystemVersions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OperatingSystemVersionListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OperatingSystemVersionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OperatingSystemVersionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OperatingSystemVersionListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one operating system by DART ID. /// /// A builder for the *get* method supported by a *operatingSystem* resource. /// It is not used directly, but through a `OperatingSystemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operating_systems().get("profileId", "dartId") /// .doit().await; /// # } /// ``` pub struct OperatingSystemGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _dart_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OperatingSystemGetCall<'a, S> {} impl<'a, S> OperatingSystemGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OperatingSystem)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.operatingSystems.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("dartId", self._dart_id.to_string())); for &field in ["alt", "profileId", "dartId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystems/{dartId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{dartId}", "dartId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["dartId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Operating system DART ID. /// /// Sets the *dart id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn dart_id(mut self, new_value: &str) -> OperatingSystemGetCall<'a, S> { self._dart_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OperatingSystemGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OperatingSystemGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OperatingSystemGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of operating systems. /// /// A builder for the *list* method supported by a *operatingSystem* resource. /// It is not used directly, but through a `OperatingSystemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.operating_systems().list("profileId") /// .doit().await; /// # } /// ``` pub struct OperatingSystemListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OperatingSystemListCall<'a, S> {} impl<'a, S> OperatingSystemListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OperatingSystemsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.operatingSystems.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/operatingSystems"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OperatingSystemListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OperatingSystemListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OperatingSystemListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OperatingSystemListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one order document by ID. /// /// A builder for the *get* method supported by a *orderDocument* resource. /// It is not used directly, but through a `OrderDocumentMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.order_documents().get("profileId", "projectId", "id") /// .doit().await; /// # } /// ``` pub struct OrderDocumentGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OrderDocumentGetCall<'a, S> {} impl<'a, S> OrderDocumentGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OrderDocument)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.orderDocuments.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "projectId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/orderDocuments/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["id", "projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for order documents. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, S> { self._project_id = new_value.to_string(); self } /// Order document ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> OrderDocumentGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OrderDocumentGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OrderDocumentGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OrderDocumentGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of order documents, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *orderDocument* resource. /// It is not used directly, but through a `OrderDocumentMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.order_documents().list("profileId", "projectId") /// .sort_order("At") /// .sort_field("Stet") /// .add_site_id("sit") /// .search_string("ipsum") /// .page_token("Lorem") /// .add_order_id("dolor") /// .max_results(-97) /// .add_ids("magna") /// .approved(false) /// .doit().await; /// # } /// ``` pub struct OrderDocumentListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _sort_order: Option, _sort_field: Option, _site_id: Vec, _search_string: Option, _page_token: Option, _order_id: Vec, _max_results: Option, _ids: Vec, _approved: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OrderDocumentListCall<'a, S> {} impl<'a, S> OrderDocumentListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OrderDocumentsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.orderDocuments.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(13 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._site_id.len() > 0 { for f in self._site_id.iter() { params.push(("siteId", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if self._order_id.len() > 0 { for f in self._order_id.iter() { params.push(("orderId", f.to_string())); } } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._approved { params.push(("approved", value.to_string())); } for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "orderId", "maxResults", "ids", "approved"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/orderDocuments"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for order documents. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._project_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only order documents that are associated with these sites. /// /// Append the given value to the *site id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_site_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._site_id.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Select only order documents for specified orders. /// /// Append the given value to the *order id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_order_id(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._order_id.push(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> OrderDocumentListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only order documents with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> OrderDocumentListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only order documents that have been approved by at least one user. /// /// Sets the *approved* query property to the given value. pub fn approved(mut self, new_value: bool) -> OrderDocumentListCall<'a, S> { self._approved = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OrderDocumentListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OrderDocumentListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OrderDocumentListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one order by ID. /// /// A builder for the *get* method supported by a *order* resource. /// It is not used directly, but through a `OrderMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.orders().get("profileId", "projectId", "id") /// .doit().await; /// # } /// ``` pub struct OrderGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OrderGetCall<'a, S> {} impl<'a, S> OrderGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Order)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.orders.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "projectId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/orders/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["id", "projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OrderGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for orders. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> OrderGetCall<'a, S> { self._project_id = new_value.to_string(); self } /// Order ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> OrderGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OrderGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OrderGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OrderGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of orders, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *order* resource. /// It is not used directly, but through a `OrderMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.orders().list("profileId", "projectId") /// .sort_order("dolore") /// .sort_field("vero") /// .add_site_id("ea") /// .search_string("et") /// .page_token("amet.") /// .max_results(-40) /// .add_ids("sanctus") /// .doit().await; /// # } /// ``` pub struct OrderListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _project_id: String, _sort_order: Option, _sort_field: Option, _site_id: Vec, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for OrderListCall<'a, S> {} impl<'a, S> OrderListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, OrdersListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.orders.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(11 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("projectId", self._project_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._site_id.len() > 0 { for f in self._site_id.iter() { params.push(("siteId", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "projectId", "sortOrder", "sortField", "siteId", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{projectId}/orders"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{projectId}", "projectId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["projectId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> OrderListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID for orders. /// /// Sets the *project id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn project_id(mut self, new_value: &str) -> OrderListCall<'a, S> { self._project_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> OrderListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> OrderListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only orders that are associated with these site IDs. /// /// Append the given value to the *site id* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_site_id(mut self, new_value: &str) -> OrderListCall<'a, S> { self._site_id.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> OrderListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> OrderListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> OrderListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only orders with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> OrderListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> OrderListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> OrderListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> OrderListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one placement group by ID. /// /// A builder for the *get* method supported by a *placementGroup* resource. /// It is not used directly, but through a `PlacementGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGroupGetCall<'a, S> {} impl<'a, S> PlacementGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new placement group. /// /// A builder for the *insert* method supported by a *placementGroup* resource. /// It is not used directly, but through a `PlacementGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementGroupInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGroupInsertCall<'a, S> {} impl<'a, S> PlacementGroupInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementGroups.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGroupInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGroupInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGroupInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGroupInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of placement groups, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *placementGroup* resource. /// It is not used directly, but through a `PlacementGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().list("profileId") /// .sort_order("erat") /// .sort_field("eos") /// .add_site_ids("nonumy") /// .search_string("ea") /// .add_pricing_types("aliquyam") /// .add_placement_strategy_ids("nonumy") /// .placement_group_type("Stet") /// .page_token("rebum.") /// .min_start_date("eirmod") /// .min_end_date("dolores") /// .max_start_date("aliquyam") /// .max_results(-8) /// .max_end_date("invidunt") /// .add_ids("dolor") /// .add_directory_site_ids("eos") /// .add_content_category_ids("magna") /// .add_campaign_ids("no") /// .archived(false) /// .add_advertiser_ids("aliquyam") /// .doit().await; /// # } /// ``` pub struct PlacementGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _site_ids: Vec, _search_string: Option, _pricing_types: Vec, _placement_strategy_ids: Vec, _placement_group_type: Option, _page_token: Option, _min_start_date: Option, _min_end_date: Option, _max_start_date: Option, _max_results: Option, _max_end_date: Option, _ids: Vec, _directory_site_ids: Vec, _content_category_ids: Vec, _campaign_ids: Vec, _archived: Option, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGroupListCall<'a, S> {} impl<'a, S> PlacementGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(22 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._site_ids.len() > 0 { for f in self._site_ids.iter() { params.push(("siteIds", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if self._pricing_types.len() > 0 { for f in self._pricing_types.iter() { params.push(("pricingTypes", f.to_string())); } } if self._placement_strategy_ids.len() > 0 { for f in self._placement_strategy_ids.iter() { params.push(("placementStrategyIds", f.to_string())); } } if let Some(value) = self._placement_group_type { params.push(("placementGroupType", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._min_start_date { params.push(("minStartDate", value.to_string())); } if let Some(value) = self._min_end_date { params.push(("minEndDate", value.to_string())); } if let Some(value) = self._max_start_date { params.push(("maxStartDate", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._max_end_date { params.push(("maxEndDate", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._directory_site_ids.len() > 0 { for f in self._directory_site_ids.iter() { params.push(("directorySiteIds", f.to_string())); } } if self._content_category_ids.len() > 0 { for f in self._content_category_ids.iter() { params.push(("contentCategoryIds", f.to_string())); } } if self._campaign_ids.len() > 0 { for f in self._campaign_ids.iter() { params.push(("campaignIds", f.to_string())); } } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "placementGroupType", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "directorySiteIds", "contentCategoryIds", "campaignIds", "archived", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only placement groups that are associated with these sites. /// /// Append the given value to the *site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._site_ids.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only placement groups with these pricing types. /// /// Append the given value to the *pricing types* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_pricing_types(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._pricing_types.push(new_value.to_string()); self } /// Select only placement groups that are associated with these placement strategies. /// /// Append the given value to the *placement strategy ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._placement_strategy_ids.push(new_value.to_string()); self } /// 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. /// /// Sets the *placement group type* query property to the given value. pub fn placement_group_type(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._placement_group_type = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// 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". /// /// Sets the *min start date* query property to the given value. pub fn min_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._min_start_date = Some(new_value.to_string()); self } /// 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". /// /// Sets the *min end date* query property to the given value. pub fn min_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._min_end_date = Some(new_value.to_string()); self } /// 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". /// /// Sets the *max start date* query property to the given value. pub fn max_start_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._max_start_date = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> PlacementGroupListCall<'a, S> { self._max_results = Some(new_value); self } /// 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". /// /// Sets the *max end date* query property to the given value. pub fn max_end_date(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._max_end_date = Some(new_value.to_string()); self } /// Select only placement groups with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only placement groups that are associated with these directory sites. /// /// Append the given value to the *directory site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._directory_site_ids.push(new_value.to_string()); self } /// Select only placement groups that are associated with these content categories. /// /// Append the given value to the *content category ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._content_category_ids.push(new_value.to_string()); self } /// Select only placement groups that belong to these campaigns. /// /// Append the given value to the *campaign ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._campaign_ids.push(new_value.to_string()); self } /// Select only archived placements. Don't set this field to select both archived and non-archived placements. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> PlacementGroupListCall<'a, S> { self._archived = Some(new_value); self } /// Select only placement groups that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementGroupListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement group. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *placementGroup* resource. /// It is not used directly, but through a `PlacementGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementGroupPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementGroup, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGroupPatchCall<'a, S> {} impl<'a, S> PlacementGroupPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementGroups.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement group ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementGroupPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGroupPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGroupPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGroupPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement group. /// /// A builder for the *update* method supported by a *placementGroup* resource. /// It is not used directly, but through a `PlacementGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementGroup; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementGroup::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_groups().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementGroupUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementGroup, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGroupUpdateCall<'a, S> {} impl<'a, S> PlacementGroupUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementGroups.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementGroup) -> PlacementGroupUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGroupUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGroupUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGroupUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGroupUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing placement strategy. /// /// A builder for the *delete* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyDeleteCall<'a, S> {} impl<'a, S> PlacementStrategyDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement strategy ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementStrategyDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one placement strategy by ID. /// /// A builder for the *get* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyGetCall<'a, S> {} impl<'a, S> PlacementStrategyGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementStrategy)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement strategy ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementStrategyGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new placement strategy. /// /// A builder for the *insert* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementStrategy; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementStrategy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementStrategy, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyInsertCall<'a, S> {} impl<'a, S> PlacementStrategyInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementStrategy)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of placement strategies, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().list("profileId") /// .sort_order("ea") /// .sort_field("sed") /// .search_string("sanctus") /// .page_token("labore") /// .max_results(-47) /// .add_ids("et") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyListCall<'a, S> {} impl<'a, S> PlacementStrategyListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementStrategiesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> PlacementStrategyListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only placement strategies with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> PlacementStrategyListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement strategy. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementStrategy; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementStrategy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementStrategy, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyPatchCall<'a, S> {} impl<'a, S> PlacementStrategyPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementStrategy)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement strategy ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementStrategyPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement strategy. /// /// A builder for the *update* method supported by a *placementStrategy* resource. /// It is not used directly, but through a `PlacementStrategyMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::PlacementStrategy; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = PlacementStrategy::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placement_strategies().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementStrategyUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: PlacementStrategy, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementStrategyUpdateCall<'a, S> {} impl<'a, S> PlacementStrategyUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementStrategy)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placementStrategies.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placementStrategies"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: PlacementStrategy) -> PlacementStrategyUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementStrategyUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementStrategyUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementStrategyUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementStrategyUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Generates tags for a placement. /// /// A builder for the *generatetags* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().generatetags("profileId") /// .add_tag_formats("ipsum") /// .add_placement_ids("eirmod") /// .campaign_id("vero") /// .doit().await; /// # } /// ``` pub struct PlacementGeneratetagCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _tag_formats: Vec, _placement_ids: Vec, _campaign_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGeneratetagCall<'a, S> {} impl<'a, S> PlacementGeneratetagCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementsGenerateTagsResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.generatetags", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._tag_formats.len() > 0 { for f in self._tag_formats.iter() { params.push(("tagFormats", f.to_string())); } } if self._placement_ids.len() > 0 { for f in self._placement_ids.iter() { params.push(("placementIds", f.to_string())); } } if let Some(value) = self._campaign_id { params.push(("campaignId", value.to_string())); } for &field in ["alt", "profileId", "tagFormats", "placementIds", "campaignId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements/generatetags"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Tag formats to generate for these placements. /// /// Note: PLACEMENT_TAG_STANDARD can only be generated for 1x1 placements. /// /// Append the given value to the *tag formats* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_tag_formats(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, S> { self._tag_formats.push(new_value.to_string()); self } /// Generate tags for these placements. /// /// Append the given value to the *placement ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_placement_ids(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, S> { self._placement_ids.push(new_value.to_string()); self } /// Generate placements belonging to this campaign. This is a required field. /// /// Sets the *campaign id* query property to the given value. pub fn campaign_id(mut self, new_value: &str) -> PlacementGeneratetagCall<'a, S> { self._campaign_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGeneratetagCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGeneratetagCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGeneratetagCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one placement by ID. /// /// A builder for the *get* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementGetCall<'a, S> {} impl<'a, S> PlacementGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Placement)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new placement. /// /// A builder for the *insert* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Placement; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Placement, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementInsertCall<'a, S> {} impl<'a, S> PlacementInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Placement)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Placement) -> PlacementInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of placements, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().list("profileId") /// .sort_order("et") /// .sort_field("gubergren") /// .add_size_ids("dolore") /// .add_site_ids("ea") /// .search_string("elitr") /// .add_pricing_types("takimata") /// .add_placement_strategy_ids("duo") /// .payment_source("tempor") /// .page_token("clita") /// .min_start_date("sed") /// .min_end_date("no") /// .max_start_date("Stet") /// .max_results(-60) /// .max_end_date("clita") /// .add_ids("consetetur") /// .add_group_ids("dolores") /// .add_directory_site_ids("sit") /// .add_content_category_ids("sea") /// .add_compatibilities("sanctus") /// .add_campaign_ids("kasd") /// .archived(false) /// .add_advertiser_ids("dolores") /// .doit().await; /// # } /// ``` pub struct PlacementListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _size_ids: Vec, _site_ids: Vec, _search_string: Option, _pricing_types: Vec, _placement_strategy_ids: Vec, _payment_source: Option, _page_token: Option, _min_start_date: Option, _min_end_date: Option, _max_start_date: Option, _max_results: Option, _max_end_date: Option, _ids: Vec, _group_ids: Vec, _directory_site_ids: Vec, _content_category_ids: Vec, _compatibilities: Vec, _campaign_ids: Vec, _archived: Option, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementListCall<'a, S> {} impl<'a, S> PlacementListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlacementsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(25 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if self._size_ids.len() > 0 { for f in self._size_ids.iter() { params.push(("sizeIds", f.to_string())); } } if self._site_ids.len() > 0 { for f in self._site_ids.iter() { params.push(("siteIds", f.to_string())); } } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if self._pricing_types.len() > 0 { for f in self._pricing_types.iter() { params.push(("pricingTypes", f.to_string())); } } if self._placement_strategy_ids.len() > 0 { for f in self._placement_strategy_ids.iter() { params.push(("placementStrategyIds", f.to_string())); } } if let Some(value) = self._payment_source { params.push(("paymentSource", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._min_start_date { params.push(("minStartDate", value.to_string())); } if let Some(value) = self._min_end_date { params.push(("minEndDate", value.to_string())); } if let Some(value) = self._max_start_date { params.push(("maxStartDate", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._max_end_date { params.push(("maxEndDate", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._group_ids.len() > 0 { for f in self._group_ids.iter() { params.push(("groupIds", f.to_string())); } } if self._directory_site_ids.len() > 0 { for f in self._directory_site_ids.iter() { params.push(("directorySiteIds", f.to_string())); } } if self._content_category_ids.len() > 0 { for f in self._content_category_ids.iter() { params.push(("contentCategoryIds", f.to_string())); } } if self._compatibilities.len() > 0 { for f in self._compatibilities.iter() { params.push(("compatibilities", f.to_string())); } } if self._campaign_ids.len() > 0 { for f in self._campaign_ids.iter() { params.push(("campaignIds", f.to_string())); } } if let Some(value) = self._archived { params.push(("archived", value.to_string())); } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "sizeIds", "siteIds", "searchString", "pricingTypes", "placementStrategyIds", "paymentSource", "pageToken", "minStartDate", "minEndDate", "maxStartDate", "maxResults", "maxEndDate", "ids", "groupIds", "directorySiteIds", "contentCategoryIds", "compatibilities", "campaignIds", "archived", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Select only placements that are associated with these sizes. /// /// Append the given value to the *size ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_size_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._size_ids.push(new_value.to_string()); self } /// Select only placements that are associated with these sites. /// /// Append the given value to the *site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._site_ids.push(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Select only placements with these pricing types. /// /// Append the given value to the *pricing types* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_pricing_types(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._pricing_types.push(new_value.to_string()); self } /// Select only placements that are associated with these placement strategies. /// /// Append the given value to the *placement strategy ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_placement_strategy_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._placement_strategy_ids.push(new_value.to_string()); self } /// Select only placements with this payment source. /// /// Sets the *payment source* query property to the given value. pub fn payment_source(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._payment_source = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// 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". /// /// Sets the *min start date* query property to the given value. pub fn min_start_date(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._min_start_date = Some(new_value.to_string()); self } /// 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". /// /// Sets the *min end date* query property to the given value. pub fn min_end_date(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._min_end_date = Some(new_value.to_string()); self } /// 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". /// /// Sets the *max start date* query property to the given value. pub fn max_start_date(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._max_start_date = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> PlacementListCall<'a, S> { self._max_results = Some(new_value); self } /// 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". /// /// Sets the *max end date* query property to the given value. pub fn max_end_date(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._max_end_date = Some(new_value.to_string()); self } /// Select only placements with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only placements that belong to these placement groups. /// /// Append the given value to the *group ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_group_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._group_ids.push(new_value.to_string()); self } /// Select only placements that are associated with these directory sites. /// /// Append the given value to the *directory site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_directory_site_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._directory_site_ids.push(new_value.to_string()); self } /// Select only placements that are associated with these content categories. /// /// Append the given value to the *content category ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_content_category_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._content_category_ids.push(new_value.to_string()); self } /// 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. /// /// Append the given value to the *compatibilities* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_compatibilities(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._compatibilities.push(new_value.to_string()); self } /// Select only placements that belong to these campaigns. /// /// Append the given value to the *campaign ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_campaign_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._campaign_ids.push(new_value.to_string()); self } /// Select only archived placements. Don't set this field to select both archived and non-archived placements. /// /// Sets the *archived* query property to the given value. pub fn archived(mut self, new_value: bool) -> PlacementListCall<'a, S> { self._archived = Some(new_value); self } /// Select only placements that belong to these advertisers. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> PlacementListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Placement; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlacementPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Placement, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementPatchCall<'a, S> {} impl<'a, S> PlacementPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Placement)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Placement) -> PlacementPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Placement ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlacementPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing placement. /// /// A builder for the *update* method supported by a *placement* resource. /// It is not used directly, but through a `PlacementMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Placement; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Placement::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.placements().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct PlacementUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Placement, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlacementUpdateCall<'a, S> {} impl<'a, S> PlacementUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Placement)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.placements.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/placements"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Placement) -> PlacementUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlacementUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlacementUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlacementUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlacementUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one platform type by ID. /// /// A builder for the *get* method supported by a *platformType* resource. /// It is not used directly, but through a `PlatformTypeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.platform_types().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct PlatformTypeGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlatformTypeGetCall<'a, S> {} impl<'a, S> PlatformTypeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlatformType)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.platformTypes.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/platformTypes/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Platform type ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> PlatformTypeGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlatformTypeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlatformTypeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlatformTypeGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of platform types. /// /// A builder for the *list* method supported by a *platformType* resource. /// It is not used directly, but through a `PlatformTypeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.platform_types().list("profileId") /// .doit().await; /// # } /// ``` pub struct PlatformTypeListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PlatformTypeListCall<'a, S> {} impl<'a, S> PlatformTypeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PlatformTypesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.platformTypes.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/platformTypes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PlatformTypeListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlatformTypeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PlatformTypeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PlatformTypeListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one postal code by ID. /// /// A builder for the *get* method supported by a *postalCode* resource. /// It is not used directly, but through a `PostalCodeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.postal_codes().get("profileId", "code") /// .doit().await; /// # } /// ``` pub struct PostalCodeGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _code: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PostalCodeGetCall<'a, S> {} impl<'a, S> PostalCodeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PostalCode)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.postalCodes.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("code", self._code.to_string())); for &field in ["alt", "profileId", "code"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/postalCodes/{code}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{code}", "code")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["code", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PostalCodeGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Postal code ID. /// /// Sets the *code* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn code(mut self, new_value: &str) -> PostalCodeGetCall<'a, S> { self._code = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PostalCodeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PostalCodeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PostalCodeGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of postal codes. /// /// A builder for the *list* method supported by a *postalCode* resource. /// It is not used directly, but through a `PostalCodeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.postal_codes().list("profileId") /// .doit().await; /// # } /// ``` pub struct PostalCodeListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for PostalCodeListCall<'a, S> {} impl<'a, S> PostalCodeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, PostalCodesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.postalCodes.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/postalCodes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> PostalCodeListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PostalCodeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> PostalCodeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> PostalCodeListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one project by ID. /// /// A builder for the *get* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct ProjectGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ProjectGetCall<'a, S> {} impl<'a, S> ProjectGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Project)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.projects.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ProjectGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Project ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> ProjectGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ProjectGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ProjectGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of projects, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *project* resource. /// It is not used directly, but through a `ProjectMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.projects().list("profileId") /// .sort_order("invidunt") /// .sort_field("dolores") /// .search_string("diam") /// .page_token("sanctus") /// .max_results(-80) /// .add_ids("eos") /// .add_advertiser_ids("sit") /// .doit().await; /// # } /// ``` pub struct ProjectListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _advertiser_ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ProjectListCall<'a, S> {} impl<'a, S> ProjectListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ProjectsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.projects.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._advertiser_ids.len() > 0 { for f in self._advertiser_ids.iter() { params.push(("advertiserIds", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserIds"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/projects"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ProjectListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only projects with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only projects with these advertiser IDs. /// /// Append the given value to the *advertiser ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_advertiser_ids(mut self, new_value: &str) -> ProjectListCall<'a, S> { self._advertiser_ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ProjectListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ProjectListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of regions. /// /// A builder for the *list* method supported by a *region* resource. /// It is not used directly, but through a `RegionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.regions().list("profileId") /// .doit().await; /// # } /// ``` pub struct RegionListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RegionListCall<'a, S> {} impl<'a, S> RegionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RegionsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.regions.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/regions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RegionListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RegionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RegionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RegionListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one remarketing list share by remarketing list ID. /// /// A builder for the *get* method supported by a *remarketingListShare* resource. /// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_list_shares().get("profileId", "remarketingListId") /// .doit().await; /// # } /// ``` pub struct RemarketingListShareGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _remarketing_list_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListShareGetCall<'a, S> {} impl<'a, S> RemarketingListShareGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingListShares.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("remarketingListId", self._remarketing_list_id.to_string())); for &field in ["alt", "profileId", "remarketingListId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingListShares/{remarketingListId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{remarketingListId}", "remarketingListId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["remarketingListId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Remarketing list ID. /// /// Sets the *remarketing list id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn remarketing_list_id(mut self, new_value: &str) -> RemarketingListShareGetCall<'a, S> { self._remarketing_list_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListShareGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListShareGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListShareGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing remarketing list share. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *remarketingListShare* resource. /// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::RemarketingListShare; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = RemarketingListShare::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_list_shares().patch(req, "profileId", "remarketingListId") /// .doit().await; /// # } /// ``` pub struct RemarketingListSharePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: RemarketingListShare, _profile_id: String, _remarketing_list_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListSharePatchCall<'a, S> {} impl<'a, S> RemarketingListSharePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingListShares.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("remarketingListId", self._remarketing_list_id.to_string())); for &field in ["alt", "profileId", "remarketingListId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingListShares"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RemarketingListShare) -> RemarketingListSharePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Remarketing list ID. /// /// Sets the *remarketing list id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn remarketing_list_id(mut self, new_value: &str) -> RemarketingListSharePatchCall<'a, S> { self._remarketing_list_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListSharePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListSharePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListSharePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing remarketing list share. /// /// A builder for the *update* method supported by a *remarketingListShare* resource. /// It is not used directly, but through a `RemarketingListShareMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::RemarketingListShare; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = RemarketingListShare::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_list_shares().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct RemarketingListShareUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: RemarketingListShare, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListShareUpdateCall<'a, S> {} impl<'a, S> RemarketingListShareUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingListShare)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingListShares.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingListShares"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RemarketingListShare) -> RemarketingListShareUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListShareUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListShareUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListShareUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListShareUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one remarketing list by ID. /// /// A builder for the *get* method supported by a *remarketingList* resource. /// It is not used directly, but through a `RemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_lists().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct RemarketingListGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListGetCall<'a, S> {} impl<'a, S> RemarketingListGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingLists.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Remarketing list ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> RemarketingListGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new remarketing list. /// /// A builder for the *insert* method supported by a *remarketingList* resource. /// It is not used directly, but through a `RemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::RemarketingList; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = RemarketingList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_lists().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct RemarketingListInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: RemarketingList, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListInsertCall<'a, S> {} impl<'a, S> RemarketingListInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingLists.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RemarketingList) -> RemarketingListInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of remarketing lists, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *remarketingList* resource. /// It is not used directly, but through a `RemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_lists().list("profileId", "advertiserId") /// .sort_order("gubergren") /// .sort_field("eos") /// .page_token("dolore") /// .name("tempor") /// .max_results(-15) /// .floodlight_activity_id("accusam") /// .active(true) /// .doit().await; /// # } /// ``` pub struct RemarketingListListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _advertiser_id: String, _sort_order: Option, _sort_field: Option, _page_token: Option, _name: Option, _max_results: Option, _floodlight_activity_id: Option, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListListCall<'a, S> {} impl<'a, S> RemarketingListListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingListsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingLists.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(11 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("advertiserId", self._advertiser_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._name { params.push(("name", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._floodlight_activity_id { params.push(("floodlightActivityId", value.to_string())); } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "floodlightActivityId", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only remarketing lists owned by this advertiser. /// /// Sets the *advertiser id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn advertiser_id(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._advertiser_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// 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". /// /// Sets the *name* query property to the given value. pub fn name(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._name = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> RemarketingListListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only remarketing lists that have this floodlight activity ID. /// /// Sets the *floodlight activity id* query property to the given value. pub fn floodlight_activity_id(mut self, new_value: &str) -> RemarketingListListCall<'a, S> { self._floodlight_activity_id = Some(new_value.to_string()); self } /// Select only active or only inactive remarketing lists. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> RemarketingListListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing remarketing list. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *remarketingList* resource. /// It is not used directly, but through a `RemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::RemarketingList; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = RemarketingList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_lists().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct RemarketingListPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: RemarketingList, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListPatchCall<'a, S> {} impl<'a, S> RemarketingListPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingLists.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RemarketingList) -> RemarketingListPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Remarketing list ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> RemarketingListPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing remarketing list. /// /// A builder for the *update* method supported by a *remarketingList* resource. /// It is not used directly, but through a `RemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::RemarketingList; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = RemarketingList::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.remarketing_lists().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct RemarketingListUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: RemarketingList, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for RemarketingListUpdateCall<'a, S> {} impl<'a, S> RemarketingListUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, RemarketingList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.remarketingLists.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/remarketingLists"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RemarketingList) -> RemarketingListUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> RemarketingListUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RemarketingListUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> RemarketingListUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> RemarketingListUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *compatibleFields.query* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Report; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Report::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().compatible_fields_query(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ReportCompatibleFieldQueryCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Report, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportCompatibleFieldQueryCall<'a, S> {} impl<'a, S> ReportCompatibleFieldQueryCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, CompatibleFields)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.compatibleFields.query", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/compatiblefields/query"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Report) -> ReportCompatibleFieldQueryCall<'a, S> { self._request = new_value; self } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportCompatibleFieldQueryCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportCompatibleFieldQueryCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportCompatibleFieldQueryCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportCompatibleFieldQueryCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a report file. This method supports media download. /// /// This method supports **media download**. To enable it, adjust the builder like this: /// `.param("alt", "media")`. /// Please note that due to missing multi-part support on the server side, you will only receive the media, /// but not the `File` structure that you would usually get. The latter will be a default value. /// /// A builder for the *files.get* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().files_get("profileId", "reportId", "fileId") /// .doit().await; /// # } /// ``` pub struct ReportFileGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _report_id: String, _file_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportFileGetCall<'a, S> {} impl<'a, S> ReportFileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.files.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); params.push(("fileId", self._file_id.to_string())); for &field in ["profileId", "reportId", "fileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let (json_field_missing, enable_resource_parsing) = { let mut enable = true; let mut field_present = true; for &(name, ref value) in params.iter() { if name == "alt" { field_present = false; if >::as_ref(&value) != "json" { enable = false; } break; } } (field_present, enable) }; if json_field_missing { params.push(("alt", "json".to_string())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}/files/{fileId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId"), ("{fileId}", "fileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(3); for param_name in ["fileId", "reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = if enable_resource_parsing { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } } else { (res, Default::default()) }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportFileGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportFileGetCall<'a, S> { self._report_id = new_value.to_string(); self } /// The ID of the report file. /// /// Sets the *file id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn file_id(mut self, new_value: &str) -> ReportFileGetCall<'a, S> { self._file_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportFileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportFileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportFileGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists files for a report. /// /// A builder for the *files.list* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().files_list("profileId", "reportId") /// .sort_order("diam") /// .sort_field("diam") /// .page_token("et") /// .max_results(-59) /// .doit().await; /// # } /// ``` pub struct ReportFileListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _report_id: String, _sort_order: Option, _sort_field: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportFileListCall<'a, S> {} impl<'a, S> ReportFileListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, FileList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.files.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } for &field in ["alt", "profileId", "reportId", "sortOrder", "sortField", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}/files"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportFileListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the parent report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportFileListCall<'a, S> { self._report_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> ReportFileListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// The field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> ReportFileListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// The value of the nextToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ReportFileListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ReportFileListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportFileListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportFileListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportFileListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes a report by its ID. /// /// A builder for the *delete* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().delete("profileId", "reportId") /// .doit().await; /// # } /// ``` pub struct ReportDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _report_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportDeleteCall<'a, S> {} impl<'a, S> ReportDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); for &field in ["profileId", "reportId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportDeleteCall<'a, S> { self._report_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a report by its ID. /// /// A builder for the *get* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().get("profileId", "reportId") /// .doit().await; /// # } /// ``` pub struct ReportGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _report_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportGetCall<'a, S> {} impl<'a, S> ReportGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Report)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); for &field in ["alt", "profileId", "reportId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportGetCall<'a, S> { self._report_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Creates a report. /// /// A builder for the *insert* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Report; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Report::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct ReportInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Report, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportInsertCall<'a, S> {} impl<'a, S> ReportInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Report)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Report) -> ReportInsertCall<'a, S> { self._request = new_value; self } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves list of reports. /// /// A builder for the *list* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().list("profileId") /// .sort_order("dolore") /// .sort_field("dolores") /// .scope("invidunt") /// .page_token("tempor") /// .max_results(-22) /// .doit().await; /// # } /// ``` pub struct ReportListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _scope: Option, _page_token: Option, _max_results: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportListCall<'a, S> {} impl<'a, S> ReportListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, ReportList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._scope { params.push(("scope", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "scope", "pageToken", "maxResults"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> ReportListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// The field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> ReportListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// The scope that defines which results are returned. /// /// Sets the *scope* query property to the given value. pub fn scope(mut self, new_value: &str) -> ReportListCall<'a, S> { self._scope = Some(new_value.to_string()); self } /// The value of the nextToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> ReportListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> ReportListCall<'a, S> { self._max_results = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates a report. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Report; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Report::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().patch(req, "profileId", "reportId") /// .doit().await; /// # } /// ``` pub struct ReportPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Report, _profile_id: String, _report_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportPatchCall<'a, S> {} impl<'a, S> ReportPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Report)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); for &field in ["alt", "profileId", "reportId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Report) -> ReportPatchCall<'a, S> { self._request = new_value; self } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportPatchCall<'a, S> { self._report_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Runs a report. /// /// A builder for the *run* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().run("profileId", "reportId") /// .synchronous(true) /// .doit().await; /// # } /// ``` pub struct ReportRunCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _report_id: String, _synchronous: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportRunCall<'a, S> {} impl<'a, S> ReportRunCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, File)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.run", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); if let Some(value) = self._synchronous { params.push(("synchronous", value.to_string())); } for &field in ["alt", "profileId", "reportId", "synchronous"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}/run"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The DFA profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportRunCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportRunCall<'a, S> { self._report_id = new_value.to_string(); self } /// If set and true, tries to run the report synchronously. /// /// Sets the *synchronous* query property to the given value. pub fn synchronous(mut self, new_value: bool) -> ReportRunCall<'a, S> { self._synchronous = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportRunCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportRunCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportRunCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates a report. /// /// A builder for the *update* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Report; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Report::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.reports().update(req, "profileId", "reportId") /// .doit().await; /// # } /// ``` pub struct ReportUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Report, _profile_id: String, _report_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for ReportUpdateCall<'a, S> {} impl<'a, S> ReportUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Report)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.reports.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("reportId", self._report_id.to_string())); for &field in ["alt", "profileId", "reportId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/reports/{reportId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{reportId}", "reportId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["reportId", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Report) -> ReportUpdateCall<'a, S> { self._request = new_value; self } /// The DFA user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> ReportUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The ID of the report. /// /// Sets the *report id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn report_id(mut self, new_value: &str) -> ReportUpdateCall<'a, S> { self._report_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReportUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> ReportUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> ReportUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one site by ID. /// /// A builder for the *get* method supported by a *site* resource. /// It is not used directly, but through a `SiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct SiteGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SiteGetCall<'a, S> {} impl<'a, S> SiteGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Site)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sites.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SiteGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Site ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> SiteGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SiteGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SiteGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SiteGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new site. /// /// A builder for the *insert* method supported by a *site* resource. /// It is not used directly, but through a `SiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Site; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct SiteInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Site, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SiteInsertCall<'a, S> {} impl<'a, S> SiteInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Site)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sites.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Site) -> SiteInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SiteInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SiteInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SiteInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SiteInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of sites, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *site* resource. /// It is not used directly, but through a `SiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().list("profileId") /// .unmapped_site(true) /// .subaccount_id("gubergren") /// .sort_order("est") /// .sort_field("rebum.") /// .search_string("consetetur") /// .page_token("erat") /// .max_results(-99) /// .add_ids("amet.") /// .add_directory_site_ids("kasd") /// .add_campaign_ids("eirmod") /// .approved(true) /// .ad_words_site(true) /// .accepts_publisher_paid_placements(true) /// .accepts_interstitial_placements(false) /// .accepts_in_stream_video_placements(false) /// .doit().await; /// # } /// ``` pub struct SiteListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _unmapped_site: Option, _subaccount_id: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _directory_site_ids: Vec, _campaign_ids: Vec, _approved: Option, _ad_words_site: Option, _accepts_publisher_paid_placements: Option, _accepts_interstitial_placements: Option, _accepts_in_stream_video_placements: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SiteListCall<'a, S> {} impl<'a, S> SiteListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SitesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sites.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(18 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._unmapped_site { params.push(("unmappedSite", value.to_string())); } if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if self._directory_site_ids.len() > 0 { for f in self._directory_site_ids.iter() { params.push(("directorySiteIds", f.to_string())); } } if self._campaign_ids.len() > 0 { for f in self._campaign_ids.iter() { params.push(("campaignIds", f.to_string())); } } if let Some(value) = self._approved { params.push(("approved", value.to_string())); } if let Some(value) = self._ad_words_site { params.push(("adWordsSite", value.to_string())); } if let Some(value) = self._accepts_publisher_paid_placements { params.push(("acceptsPublisherPaidPlacements", value.to_string())); } if let Some(value) = self._accepts_interstitial_placements { params.push(("acceptsInterstitialPlacements", value.to_string())); } if let Some(value) = self._accepts_in_stream_video_placements { params.push(("acceptsInStreamVideoPlacements", value.to_string())); } for &field in ["alt", "profileId", "unmappedSite", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "directorySiteIds", "campaignIds", "approved", "adWordsSite", "acceptsPublisherPaidPlacements", "acceptsInterstitialPlacements", "acceptsInStreamVideoPlacements"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SiteListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only sites that have not been mapped to a directory site. /// /// Sets the *unmapped site* query property to the given value. pub fn unmapped_site(mut self, new_value: bool) -> SiteListCall<'a, S> { self._unmapped_site = Some(new_value); self } /// Select only sites with this subaccount ID. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> SiteListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> SiteListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> SiteListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> SiteListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> SiteListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> SiteListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only sites with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> SiteListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only sites with these directory site IDs. /// /// Append the given value to the *directory site ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_directory_site_ids(mut self, new_value: &str) -> SiteListCall<'a, S> { self._directory_site_ids.push(new_value.to_string()); self } /// Select only sites with these campaign IDs. /// /// Append the given value to the *campaign ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_campaign_ids(mut self, new_value: &str) -> SiteListCall<'a, S> { self._campaign_ids.push(new_value.to_string()); self } /// Select only approved sites. /// /// Sets the *approved* query property to the given value. pub fn approved(mut self, new_value: bool) -> SiteListCall<'a, S> { self._approved = Some(new_value); self } /// Select only AdWords sites. /// /// Sets the *ad words site* query property to the given value. pub fn ad_words_site(mut self, new_value: bool) -> SiteListCall<'a, S> { self._ad_words_site = Some(new_value); self } /// Select only sites that accept publisher paid placements. /// /// Sets the *accepts publisher paid placements* query property to the given value. pub fn accepts_publisher_paid_placements(mut self, new_value: bool) -> SiteListCall<'a, S> { self._accepts_publisher_paid_placements = Some(new_value); self } /// This search filter is no longer supported and will have no effect on the results returned. /// /// Sets the *accepts interstitial placements* query property to the given value. pub fn accepts_interstitial_placements(mut self, new_value: bool) -> SiteListCall<'a, S> { self._accepts_interstitial_placements = Some(new_value); self } /// This search filter is no longer supported and will have no effect on the results returned. /// /// Sets the *accepts in stream video placements* query property to the given value. pub fn accepts_in_stream_video_placements(mut self, new_value: bool) -> SiteListCall<'a, S> { self._accepts_in_stream_video_placements = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SiteListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SiteListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SiteListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing site. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *site* resource. /// It is not used directly, but through a `SiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Site; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct SitePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Site, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SitePatchCall<'a, S> {} impl<'a, S> SitePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Site)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sites.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Site) -> SitePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SitePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Site ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> SitePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SitePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SitePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SitePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing site. /// /// A builder for the *update* method supported by a *site* resource. /// It is not used directly, but through a `SiteMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Site; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Site::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sites().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct SiteUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Site, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SiteUpdateCall<'a, S> {} impl<'a, S> SiteUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Site)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sites.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sites"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Site) -> SiteUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SiteUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SiteUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SiteUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SiteUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one size by ID. /// /// A builder for the *get* method supported by a *size* resource. /// It is not used directly, but through a `SizeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sizes().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct SizeGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SizeGetCall<'a, S> {} impl<'a, S> SizeGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Size)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sizes.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SizeGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Size ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> SizeGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SizeGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SizeGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SizeGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new size. /// /// A builder for the *insert* method supported by a *size* resource. /// It is not used directly, but through a `SizeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Size; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Size::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sizes().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct SizeInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Size, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SizeInsertCall<'a, S> {} impl<'a, S> SizeInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Size)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sizes.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Size) -> SizeInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SizeInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SizeInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SizeInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SizeInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// 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. /// /// A builder for the *list* method supported by a *size* resource. /// It is not used directly, but through a `SizeMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.sizes().list("profileId") /// .width(-93) /// .add_ids("no") /// .iab_standard(false) /// .height(-7) /// .doit().await; /// # } /// ``` pub struct SizeListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _width: Option, _ids: Vec, _iab_standard: Option, _height: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SizeListCall<'a, S> {} impl<'a, S> SizeListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SizesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.sizes.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._width { params.push(("width", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._iab_standard { params.push(("iabStandard", value.to_string())); } if let Some(value) = self._height { params.push(("height", value.to_string())); } for &field in ["alt", "profileId", "width", "ids", "iabStandard", "height"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/sizes"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SizeListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only sizes with this width. /// /// Sets the *width* query property to the given value. pub fn width(mut self, new_value: i32) -> SizeListCall<'a, S> { self._width = Some(new_value); self } /// Select only sizes with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> SizeListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only IAB standard sizes. /// /// Sets the *iab standard* query property to the given value. pub fn iab_standard(mut self, new_value: bool) -> SizeListCall<'a, S> { self._iab_standard = Some(new_value); self } /// Select only sizes with this height. /// /// Sets the *height* query property to the given value. pub fn height(mut self, new_value: i32) -> SizeListCall<'a, S> { self._height = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SizeListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SizeListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SizeListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one subaccount by ID. /// /// A builder for the *get* method supported by a *subaccount* resource. /// It is not used directly, but through a `SubaccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct SubaccountGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SubaccountGetCall<'a, S> {} impl<'a, S> SubaccountGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Subaccount)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.subaccounts.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SubaccountGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Subaccount ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> SubaccountGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubaccountGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SubaccountGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SubaccountGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new subaccount. /// /// A builder for the *insert* method supported by a *subaccount* resource. /// It is not used directly, but through a `SubaccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Subaccount; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct SubaccountInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Subaccount, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SubaccountInsertCall<'a, S> {} impl<'a, S> SubaccountInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Subaccount)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.subaccounts.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Subaccount) -> SubaccountInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SubaccountInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubaccountInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SubaccountInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SubaccountInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a list of subaccounts, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *subaccount* resource. /// It is not used directly, but through a `SubaccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().list("profileId") /// .sort_order("et") /// .sort_field("accusam") /// .search_string("sit") /// .page_token("voluptua.") /// .max_results(-13) /// .add_ids("no") /// .doit().await; /// # } /// ``` pub struct SubaccountListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SubaccountListCall<'a, S> {} impl<'a, S> SubaccountListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, SubaccountsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.subaccounts.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> SubaccountListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only subaccounts with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> SubaccountListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubaccountListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SubaccountListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SubaccountListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing subaccount. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *subaccount* resource. /// It is not used directly, but through a `SubaccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Subaccount; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct SubaccountPatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Subaccount, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SubaccountPatchCall<'a, S> {} impl<'a, S> SubaccountPatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Subaccount)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.subaccounts.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Subaccount) -> SubaccountPatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SubaccountPatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Subaccount ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> SubaccountPatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubaccountPatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SubaccountPatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SubaccountPatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing subaccount. /// /// A builder for the *update* method supported by a *subaccount* resource. /// It is not used directly, but through a `SubaccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::Subaccount; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = Subaccount::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.subaccounts().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct SubaccountUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: Subaccount, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for SubaccountUpdateCall<'a, S> {} impl<'a, S> SubaccountUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, Subaccount)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.subaccounts.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/subaccounts"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Subaccount) -> SubaccountUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> SubaccountUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubaccountUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> SubaccountUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> SubaccountUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one remarketing list by ID. /// /// A builder for the *get* method supported by a *targetableRemarketingList* resource. /// It is not used directly, but through a `TargetableRemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targetable_remarketing_lists().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct TargetableRemarketingListGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetableRemarketingListGetCall<'a, S> {} impl<'a, S> TargetableRemarketingListGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetableRemarketingList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetableRemarketingLists.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetableRemarketingLists/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Remarketing list ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> TargetableRemarketingListGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetableRemarketingListGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetableRemarketingListGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetableRemarketingListGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of targetable remarketing lists, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *targetableRemarketingList* resource. /// It is not used directly, but through a `TargetableRemarketingListMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targetable_remarketing_lists().list("profileId", "advertiserId") /// .sort_order("no") /// .sort_field("kasd") /// .page_token("sanctus") /// .name("gubergren") /// .max_results(-23) /// .active(true) /// .doit().await; /// # } /// ``` pub struct TargetableRemarketingListListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _advertiser_id: String, _sort_order: Option, _sort_field: Option, _page_token: Option, _name: Option, _max_results: Option, _active: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetableRemarketingListListCall<'a, S> {} impl<'a, S> TargetableRemarketingListListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetableRemarketingListsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetableRemarketingLists.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("advertiserId", self._advertiser_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._name { params.push(("name", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if let Some(value) = self._active { params.push(("active", value.to_string())); } for &field in ["alt", "profileId", "advertiserId", "sortOrder", "sortField", "pageToken", "name", "maxResults", "active"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetableRemarketingLists"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only targetable remarketing lists targetable by these advertisers. /// /// Sets the *advertiser id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn advertiser_id(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._advertiser_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// 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". /// /// Sets the *name* query property to the given value. pub fn name(mut self, new_value: &str) -> TargetableRemarketingListListCall<'a, S> { self._name = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> TargetableRemarketingListListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only active or only inactive targetable remarketing lists. /// /// Sets the *active* query property to the given value. pub fn active(mut self, new_value: bool) -> TargetableRemarketingListListCall<'a, S> { self._active = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetableRemarketingListListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetableRemarketingListListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetableRemarketingListListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one targeting template by ID. /// /// A builder for the *get* method supported by a *targetingTemplate* resource. /// It is not used directly, but through a `TargetingTemplateMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targeting_templates().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct TargetingTemplateGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetingTemplateGetCall<'a, S> {} impl<'a, S> TargetingTemplateGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetingTemplate)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetingTemplates.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetingTemplateGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Targeting template ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> TargetingTemplateGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetingTemplateGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetingTemplateGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetingTemplateGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new targeting template. /// /// A builder for the *insert* method supported by a *targetingTemplate* resource. /// It is not used directly, but through a `TargetingTemplateMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::TargetingTemplate; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TargetingTemplate::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targeting_templates().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct TargetingTemplateInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: TargetingTemplate, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetingTemplateInsertCall<'a, S> {} impl<'a, S> TargetingTemplateInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetingTemplate)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetingTemplates.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplateInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetingTemplateInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetingTemplateInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetingTemplateInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetingTemplateInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of targeting templates, optionally filtered. This method supports paging. /// /// A builder for the *list* method supported by a *targetingTemplate* resource. /// It is not used directly, but through a `TargetingTemplateMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targeting_templates().list("profileId") /// .sort_order("amet") /// .sort_field("magna") /// .search_string("accusam") /// .page_token("Lorem") /// .max_results(-89) /// .add_ids("consetetur") /// .advertiser_id("amet") /// .doit().await; /// # } /// ``` pub struct TargetingTemplateListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _advertiser_id: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetingTemplateListCall<'a, S> {} impl<'a, S> TargetingTemplateListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetingTemplatesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetingTemplates.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(10 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._advertiser_id { params.push(("advertiserId", value.to_string())); } for &field in ["alt", "profileId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "advertiserId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> TargetingTemplateListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only targeting templates with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only targeting templates with this advertiser ID. /// /// Sets the *advertiser id* query property to the given value. pub fn advertiser_id(mut self, new_value: &str) -> TargetingTemplateListCall<'a, S> { self._advertiser_id = Some(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetingTemplateListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetingTemplateListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetingTemplateListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing targeting template. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *targetingTemplate* resource. /// It is not used directly, but through a `TargetingTemplateMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::TargetingTemplate; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TargetingTemplate::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targeting_templates().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct TargetingTemplatePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: TargetingTemplate, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetingTemplatePatchCall<'a, S> {} impl<'a, S> TargetingTemplatePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetingTemplate)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetingTemplates.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplatePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetingTemplatePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Targeting template ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> TargetingTemplatePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetingTemplatePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetingTemplatePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetingTemplatePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing targeting template. /// /// A builder for the *update* method supported by a *targetingTemplate* resource. /// It is not used directly, but through a `TargetingTemplateMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::TargetingTemplate; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = TargetingTemplate::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.targeting_templates().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct TargetingTemplateUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: TargetingTemplate, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for TargetingTemplateUpdateCall<'a, S> {} impl<'a, S> TargetingTemplateUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, TargetingTemplate)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.targetingTemplates.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/targetingTemplates"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: TargetingTemplate) -> TargetingTemplateUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> TargetingTemplateUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TargetingTemplateUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> TargetingTemplateUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> TargetingTemplateUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one user profile by ID. /// /// A builder for the *get* method supported by a *userProfile* resource. /// It is not used directly, but through a `UserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_profiles().get("profileId") /// .doit().await; /// # } /// ``` pub struct UserProfileGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserProfileGetCall<'a, S> {} impl<'a, S> UserProfileGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserProfile)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userProfiles.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The user profile ID. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserProfileGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserProfileGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserProfileGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserProfileGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves list of user profiles for a user. /// /// A builder for the *list* method supported by a *userProfile* resource. /// It is not used directly, but through a `UserProfileMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_profiles().list() /// .doit().await; /// # } /// ``` pub struct UserProfileListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserProfileListCall<'a, S> {} impl<'a, S> UserProfileListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserProfileList)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userProfiles.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len()); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Full.as_ref().to_string(), ()); } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserProfileListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserProfileListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Full`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserProfileListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one user role permission group by ID. /// /// A builder for the *get* method supported by a *userRolePermissionGroup* resource. /// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_role_permission_groups().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct UserRolePermissionGroupGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRolePermissionGroupGetCall<'a, S> {} impl<'a, S> UserRolePermissionGroupGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRolePermissionGroup)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRolePermissionGroups.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissionGroups/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User role permission group ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> UserRolePermissionGroupGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRolePermissionGroupGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRolePermissionGroupGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRolePermissionGroupGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a list of all supported user role permission groups. /// /// A builder for the *list* method supported by a *userRolePermissionGroup* resource. /// It is not used directly, but through a `UserRolePermissionGroupMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_role_permission_groups().list("profileId") /// .doit().await; /// # } /// ``` pub struct UserRolePermissionGroupListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRolePermissionGroupListCall<'a, S> {} impl<'a, S> UserRolePermissionGroupListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRolePermissionGroupsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRolePermissionGroups.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissionGroups"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRolePermissionGroupListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRolePermissionGroupListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRolePermissionGroupListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRolePermissionGroupListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one user role permission by ID. /// /// A builder for the *get* method supported by a *userRolePermission* resource. /// It is not used directly, but through a `UserRolePermissionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_role_permissions().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct UserRolePermissionGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRolePermissionGetCall<'a, S> {} impl<'a, S> UserRolePermissionGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRolePermission)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRolePermissions.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissions/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User role permission ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> UserRolePermissionGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRolePermissionGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRolePermissionGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRolePermissionGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets a list of user role permissions, possibly filtered. /// /// A builder for the *list* method supported by a *userRolePermission* resource. /// It is not used directly, but through a `UserRolePermissionMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_role_permissions().list("profileId") /// .add_ids("et") /// .doit().await; /// # } /// ``` pub struct UserRolePermissionListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _ids: Vec, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRolePermissionListCall<'a, S> {} impl<'a, S> UserRolePermissionListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRolePermissionsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRolePermissions.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } for &field in ["alt", "profileId", "ids"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRolePermissions"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRolePermissionListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only user role permissions with these IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> UserRolePermissionListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRolePermissionListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRolePermissionListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRolePermissionListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Deletes an existing user role. /// /// A builder for the *delete* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().delete("profileId", "id") /// .doit().await; /// # } /// ``` pub struct UserRoleDeleteCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRoleDeleteCall<'a, S> {} impl<'a, S> UserRoleDeleteCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.delete", http_method: hyper::Method::DELETE }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User role ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> UserRoleDeleteCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRoleDeleteCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRoleDeleteCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRoleDeleteCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one user role by ID. /// /// A builder for the *get* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().get("profileId", "id") /// .doit().await; /// # } /// ``` pub struct UserRoleGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRoleGetCall<'a, S> {} impl<'a, S> UserRoleGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRole)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRoleGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User role ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> UserRoleGetCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRoleGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRoleGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRoleGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Inserts a new user role. /// /// A builder for the *insert* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::UserRole; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().insert(req, "profileId") /// .doit().await; /// # } /// ``` pub struct UserRoleInsertCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: UserRole, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRoleInsertCall<'a, S> {} impl<'a, S> UserRoleInsertCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRole)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.insert", http_method: hyper::Method::POST }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: UserRole) -> UserRoleInsertCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRoleInsertCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRoleInsertCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRoleInsertCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRoleInsertCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Retrieves a list of user roles, possibly filtered. This method supports paging. /// /// A builder for the *list* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().list("profileId") /// .subaccount_id("sanctus") /// .sort_order("dolores") /// .sort_field("elitr") /// .search_string("diam") /// .page_token("sed") /// .max_results(-101) /// .add_ids("magna") /// .account_user_role_only(true) /// .doit().await; /// # } /// ``` pub struct UserRoleListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _subaccount_id: Option, _sort_order: Option, _sort_field: Option, _search_string: Option, _page_token: Option, _max_results: Option, _ids: Vec, _account_user_role_only: Option, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRoleListCall<'a, S> {} impl<'a, S> UserRoleListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRolesListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(11 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); if let Some(value) = self._subaccount_id { params.push(("subaccountId", value.to_string())); } if let Some(value) = self._sort_order { params.push(("sortOrder", value.to_string())); } if let Some(value) = self._sort_field { params.push(("sortField", value.to_string())); } if let Some(value) = self._search_string { params.push(("searchString", value.to_string())); } if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._max_results { params.push(("maxResults", value.to_string())); } if self._ids.len() > 0 { for f in self._ids.iter() { params.push(("ids", f.to_string())); } } if let Some(value) = self._account_user_role_only { params.push(("accountUserRoleOnly", value.to_string())); } for &field in ["alt", "profileId", "subaccountId", "sortOrder", "sortField", "searchString", "pageToken", "maxResults", "ids", "accountUserRoleOnly"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Select only user roles that belong to this subaccount. /// /// Sets the *subaccount id* query property to the given value. pub fn subaccount_id(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._subaccount_id = Some(new_value.to_string()); self } /// Order of sorted results. /// /// Sets the *sort order* query property to the given value. pub fn sort_order(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._sort_order = Some(new_value.to_string()); self } /// Field by which to sort the list. /// /// Sets the *sort field* query property to the given value. pub fn sort_field(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._sort_field = Some(new_value.to_string()); self } /// 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". /// /// Sets the *search string* query property to the given value. pub fn search_string(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._search_string = Some(new_value.to_string()); self } /// Value of the nextPageToken from the previous result page. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of results to return. /// /// Sets the *max results* query property to the given value. pub fn max_results(mut self, new_value: i32) -> UserRoleListCall<'a, S> { self._max_results = Some(new_value); self } /// Select only user roles with the specified IDs. /// /// Append the given value to the *ids* query property. /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. pub fn add_ids(mut self, new_value: &str) -> UserRoleListCall<'a, S> { self._ids.push(new_value.to_string()); self } /// Select only account level user roles not associated with any specific subaccount. /// /// Sets the *account user role only* query property to the given value. pub fn account_user_role_only(mut self, new_value: bool) -> UserRoleListCall<'a, S> { self._account_user_role_only = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRoleListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRoleListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRoleListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing user role. This method supports patch semantics. /// /// A builder for the *patch* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::UserRole; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().patch(req, "profileId", "id") /// .doit().await; /// # } /// ``` pub struct UserRolePatchCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: UserRole, _profile_id: String, _id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRolePatchCall<'a, S> {} impl<'a, S> UserRolePatchCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRole)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.patch", http_method: hyper::Method::PATCH }); let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: UserRole) -> UserRolePatchCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRolePatchCall<'a, S> { self._profile_id = new_value.to_string(); self } /// User role ID. /// /// Sets the *id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: &str) -> UserRolePatchCall<'a, S> { self._id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRolePatchCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRolePatchCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRolePatchCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Updates an existing user role. /// /// A builder for the *update* method supported by a *userRole* resource. /// It is not used directly, but through a `UserRoleMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// use dfareporting3d2::api::UserRole; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // As the method needs a request, you would usually fill it with the desired information /// // into the respective structure. Some of the parts shown here might not be applicable ! /// // Values shown here are possibly random and not representative ! /// let mut req = UserRole::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.user_roles().update(req, "profileId") /// .doit().await; /// # } /// ``` pub struct UserRoleUpdateCall<'a, S> where S: 'a { hub: &'a Dfareporting, _request: UserRole, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for UserRoleUpdateCall<'a, S> {} impl<'a, S> UserRoleUpdateCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, UserRole)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.userRoles.update", http_method: hyper::Method::PUT }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/userRoles"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); let mut request_value_reader = { let mut value = json::value::to_value(&self._request).expect("serde to work"); client::remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) .header(CONTENT_LENGTH, request_size as u64) .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: UserRole) -> UserRoleUpdateCall<'a, S> { self._request = new_value; self } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> UserRoleUpdateCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRoleUpdateCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> UserRoleUpdateCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> UserRoleUpdateCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Gets one video format by ID. /// /// A builder for the *get* method supported by a *videoFormat* resource. /// It is not used directly, but through a `VideoFormatMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.video_formats().get("profileId", -65) /// .doit().await; /// # } /// ``` pub struct VideoFormatGetCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _id: i32, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for VideoFormatGetCall<'a, S> {} impl<'a, S> VideoFormatGetCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoFormat)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.videoFormats.get", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); params.push(("id", self._id.to_string())); for &field in ["alt", "profileId", "id"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/videoFormats/{id}"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId"), ("{id}", "id")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(2); for param_name in ["id", "profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> VideoFormatGetCall<'a, S> { self._profile_id = new_value.to_string(); self } /// Video format ID. /// /// Sets the *id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn id(mut self, new_value: i32) -> VideoFormatGetCall<'a, S> { self._id = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoFormatGetCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> VideoFormatGetCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> VideoFormatGetCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } } /// Lists available video formats. /// /// A builder for the *list* method supported by a *videoFormat* resource. /// It is not used directly, but through a `VideoFormatMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate google_dfareporting3d2 as dfareporting3d2; /// # async fn dox() { /// # use std::default::Default; /// # use dfareporting3d2::{Dfareporting, oauth2, hyper, hyper_rustls}; /// /// # let secret: oauth2::ApplicationSecret = Default::default(); /// # let auth = oauth2::InstalledFlowAuthenticator::builder( /// # secret, /// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, /// # ).build().await.unwrap(); /// # let mut hub = Dfareporting::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.video_formats().list("profileId") /// .doit().await; /// # } /// ``` pub struct VideoFormatListCall<'a, S> where S: 'a { hub: &'a Dfareporting, _profile_id: String, _delegate: Option<&'a mut dyn client::Delegate>, _additional_params: HashMap, _scopes: BTreeMap } impl<'a, S> client::CallBuilder for VideoFormatListCall<'a, S> {} impl<'a, S> VideoFormatListCall<'a, S> where S: tower_service::Service + Clone + Send + Sync + 'static, S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, S::Future: Send + Unpin + 'static, S::Error: Into>, { /// Perform the operation you have build so far. pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoFormatsListResponse)> { use std::io::{Read, Seek}; use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; use client::ToParts; let mut dd = client::DefaultDelegate; let mut dlg: &mut dyn client::Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(client::MethodInfo { id: "dfareporting.videoFormats.list", http_method: hyper::Method::GET }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("profileId", self._profile_id.to_string())); for &field in ["alt", "profileId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(client::Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = self.hub._base_url.clone() + "userprofiles/{profileId}/videoFormats"; if self._scopes.len() == 0 { self._scopes.insert(Scope::Dfatrafficking.as_ref().to_string(), ()); } for &(find_this, param_name) in [("{profileId}", "profileId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["profileId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = url::Url::parse_with_params(&url, params).unwrap(); loop { let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { Some(token) => token, None => { dlg.finished(false); return Err(client::Error::MissingToken(err)) } } } }; let mut req_result = { let client = &self.hub.client; dlg.pre_request(); let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); let request = req_builder .body(hyper::body::Body::empty()); client.request(request.unwrap()).await }; match req_result { Err(err) => { if let client::Retry::After(d) = dlg.http_error(&err) { sleep(d); continue; } dlg.finished(false); return Err(client::Error::HttpError(err)) } Ok(mut res) => { if !res.status().is_success() { let res_body_string = client::get_body_as_string(res.body_mut()).await; let (parts, _) = res.into_parts(); let body = hyper::Body::from(res_body_string.clone()); let restored_response = hyper::Response::from_parts(parts, body); let server_response = json::from_str::(&res_body_string).ok(); if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { sleep(d); continue; } dlg.finished(false); return match server_response { Some(error_value) => Err(client::Error::BadRequest(error_value)), None => Err(client::Error::Failure(restored_response)), } } let result_value = { let res_body_string = client::get_body_as_string(res.body_mut()).await; match json::from_str(&res_body_string) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&res_body_string, &err); return Err(client::Error::JsonDecodeError(res_body_string, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// User profile ID associated with this request. /// /// Sets the *profile id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn profile_id(mut self, new_value: &str) -> VideoFormatListCall<'a, S> { self._profile_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoFormatListCall<'a, S> { self._delegate = Some(new_value); self } /// Set any additional parameter of the query string used in the request. /// It should be used to set parameters which are not yet available through their own /// setters. /// /// Please note that this method must not be used to set any of the known parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *alt* (query-string) - Data format for the response. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead. pub fn param(mut self, name: T, value: T) -> VideoFormatListCall<'a, S> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } /// Identifies the authorization scope for the method you are building. /// /// Use this method to actively specify which scope should be used, instead the default `Scope` variant /// `Scope::Dfatrafficking`. /// /// The `scope` will be added to a set of scopes. This is important as one can maintain access /// tokens for more than one scope. /// If `None` is specified, then all scopes will be removed and no default scope will be used either. /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` /// function for details). /// /// Usually there is more than one suitable scope to authorize an operation, some of which may /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be /// sufficient, a read-write scope will do as well. pub fn add_scope(mut self, scope: T) -> VideoFormatListCall<'a, S> where T: Into>, St: AsRef { match scope.into() { Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), None => None, }; self } }