Files
google-apis-rs/gen/adexchangebuyer1d4/src/api.rs
Sebastian Thiel a791dde0ce rebuild all APIS
2023-03-16 18:16:47 +01:00

14612 lines
605 KiB
Rust

use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
// ##############
// 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 your Ad Exchange buyer account configuration
AdexchangeBuyer,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::AdexchangeBuyer => "https://www.googleapis.com/auth/adexchange.buyer",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::AdexchangeBuyer
}
}
// ########
// HUB ###
// ######
/// Central instance to access all AdExchangeBuyer related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::{Result, Error};
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// // 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 = AdExchangeBuyer::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()
/// .page_token("ipsum")
/// .open_auction_status_filter("gubergren")
/// .max_results(50)
/// .deals_status_filter("gubergren")
/// .add_buyer_creative_id("eos")
/// .add_account_id(-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 AdExchangeBuyer<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: Box<dyn client::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<'a, S> client::Hub for AdExchangeBuyer<S> {}
impl<'a, S> AdExchangeBuyer<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> AdExchangeBuyer<S> {
AdExchangeBuyer {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.2".to_string(),
_base_url: "https://www.googleapis.com/adexchangebuyer/v1.4/".to_string(),
_root_url: "https://www.googleapis.com/".to_string(),
}
}
pub fn accounts(&'a self) -> AccountMethods<'a, S> {
AccountMethods { hub: &self }
}
pub fn billing_info(&'a self) -> BillingInfoMethods<'a, S> {
BillingInfoMethods { hub: &self }
}
pub fn budget(&'a self) -> BudgetMethods<'a, S> {
BudgetMethods { hub: &self }
}
pub fn creatives(&'a self) -> CreativeMethods<'a, S> {
CreativeMethods { hub: &self }
}
pub fn marketplacedeals(&'a self) -> MarketplacedealMethods<'a, S> {
MarketplacedealMethods { hub: &self }
}
pub fn marketplacenotes(&'a self) -> MarketplacenoteMethods<'a, S> {
MarketplacenoteMethods { hub: &self }
}
pub fn marketplaceprivateauction(&'a self) -> MarketplaceprivateauctionMethods<'a, S> {
MarketplaceprivateauctionMethods { hub: &self }
}
pub fn performance_report(&'a self) -> PerformanceReportMethods<'a, S> {
PerformanceReportMethods { hub: &self }
}
pub fn pretargeting_config(&'a self) -> PretargetingConfigMethods<'a, S> {
PretargetingConfigMethods { hub: &self }
}
pub fn products(&'a self) -> ProductMethods<'a, S> {
ProductMethods { hub: &self }
}
pub fn proposals(&'a self) -> ProposalMethods<'a, S> {
ProposalMethods { hub: &self }
}
pub fn pubprofiles(&'a self) -> PubprofileMethods<'a, S> {
PubprofileMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/5.0.2`.
///
/// 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/adexchangebuyer/v1.4/`.
///
/// 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 ###
// ##########
/// Configuration data for an Ad Exchange buyer 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)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Account {
/// When this is false, bid requests that include a deal ID for a private auction or preferred deal are always sent to your bidder. When true, all active pretargeting configs will be applied to private auctions and preferred deals. Programmatic Guaranteed deals (when enabled) are always sent to your bidder.
#[serde(rename="applyPretargetingToNonGuaranteedDeals")]
pub apply_pretargeting_to_non_guaranteed_deals: Option<bool>,
/// Your bidder locations that have distinct URLs.
#[serde(rename="bidderLocation")]
pub bidder_location: Option<Vec<AccountBidderLocation>>,
/// The nid parameter value used in cookie match requests. Please contact your technical account manager if you need to change this.
#[serde(rename="cookieMatchingNid")]
pub cookie_matching_nid: Option<String>,
/// The base URL used in cookie match requests.
#[serde(rename="cookieMatchingUrl")]
pub cookie_matching_url: Option<String>,
/// Account id.
pub id: Option<i32>,
/// Resource type.
pub kind: Option<String>,
/// The maximum number of active creatives that an account can have, where a creative is active if it was inserted or bid with in the last 30 days. Please contact your technical account manager if you need to change this.
#[serde(rename="maximumActiveCreatives")]
pub maximum_active_creatives: Option<i32>,
/// The sum of all bidderLocation.maximumQps values cannot exceed this. Please contact your technical account manager if you need to change this.
#[serde(rename="maximumTotalQps")]
pub maximum_total_qps: Option<i32>,
/// The number of creatives that this account inserted or bid with in the last 30 days.
#[serde(rename="numberActiveCreatives")]
pub number_active_creatives: Option<i32>,
}
impl client::RequestValue for Account {}
impl client::Resource for Account {}
impl client::ResponseResult for Account {}
/// An account feed lists Ad Exchange buyer accounts that the user has access to. Each entry in the feed corresponds to a single buyer 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*).
///
/// * [list accounts](AccountListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AccountsList {
/// A list of accounts.
pub items: Option<Vec<Account>>,
/// Resource type.
pub kind: Option<String>,
}
impl client::ResponseResult for AccountsList {}
/// There is no detailed description.
///
/// # 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 marketplacedeals](MarketplacedealInsertCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AddOrderDealsRequest {
/// The list of deals to add
pub deals: Option<Vec<MarketplaceDeal>>,
/// The last known proposal revision number.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
/// Indicates an optional action to take on the proposal
#[serde(rename="updateAction")]
pub update_action: Option<String>,
}
impl client::RequestValue for AddOrderDealsRequest {}
/// There is no detailed description.
///
/// # 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 marketplacedeals](MarketplacedealInsertCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AddOrderDealsResponse {
/// List of deals added (in the same proposal as passed in the request)
pub deals: Option<Vec<MarketplaceDeal>>,
/// The updated revision number for the proposal.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
}
impl client::ResponseResult for AddOrderDealsResponse {}
/// There is no detailed description.
///
/// # 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 marketplacenotes](MarketplacenoteInsertCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AddOrderNotesRequest {
/// The list of notes to add.
pub notes: Option<Vec<MarketplaceNote>>,
}
impl client::RequestValue for AddOrderNotesRequest {}
/// There is no detailed description.
///
/// # 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 marketplacenotes](MarketplacenoteInsertCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AddOrderNotesResponse {
/// no description provided
pub notes: Option<Vec<MarketplaceNote>>,
}
impl client::ResponseResult for AddOrderNotesResponse {}
/// The configuration data for an Ad Exchange billing info.
///
/// # 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 billing info](BillingInfoGetCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct BillingInfo {
/// Account id.
#[serde(rename="accountId")]
pub account_id: Option<i32>,
/// Account name.
#[serde(rename="accountName")]
pub account_name: Option<String>,
/// A list of adgroup IDs associated with this particular account. These IDs may show up as part of a realtime bidding BidRequest, which indicates a bid request for this account.
#[serde(rename="billingId")]
pub billing_id: Option<Vec<String>>,
/// Resource type.
pub kind: Option<String>,
}
impl client::ResponseResult for BillingInfo {}
/// A billing info feed lists Billing Info the Ad Exchange buyer account has access to. Each entry in the feed corresponds to a single billing info.
///
/// # 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 billing info](BillingInfoListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct BillingInfoList {
/// A list of billing info relevant for your account.
pub items: Option<Vec<BillingInfo>>,
/// Resource type.
pub kind: Option<String>,
}
impl client::ResponseResult for BillingInfoList {}
/// The configuration data for Ad Exchange RTB - Budget 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 budget](BudgetGetCall) (response)
/// * [patch budget](BudgetPatchCall) (request|response)
/// * [update budget](BudgetUpdateCall) (request|response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Budget {
/// The id of the account. This is required for get and update requests.
#[serde(rename="accountId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub account_id: Option<i64>,
/// The billing id to determine which adgroup to provide budget information for. This is required for get and update requests.
#[serde(rename="billingId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub billing_id: Option<i64>,
/// The daily budget amount in unit amount of the account currency to apply for the billingId provided. This is required for update requests.
#[serde(rename="budgetAmount")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub budget_amount: Option<i64>,
/// The currency code for the buyer. This cannot be altered here.
#[serde(rename="currencyCode")]
pub currency_code: Option<String>,
/// The unique id that describes this item.
pub id: Option<String>,
/// The kind of the resource, i.e. "adexchangebuyer#budget".
pub kind: Option<String>,
}
impl client::RequestValue for Budget {}
impl client::ResponseResult for Budget {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Buyer {
/// Adx account id of the buyer.
#[serde(rename="accountId")]
pub account_id: Option<String>,
}
impl client::Part for Buyer {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ContactInformation {
/// Email address of the contact.
pub email: Option<String>,
/// The name of the contact.
pub name: Option<String>,
}
impl client::Part for ContactInformation {}
/// There is no detailed description.
///
/// # 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 proposals](ProposalInsertCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreateOrdersRequest {
/// The list of proposals to create.
pub proposals: Option<Vec<Proposal>>,
/// Web property id of the seller creating these orders
#[serde(rename="webPropertyCode")]
pub web_property_code: Option<String>,
}
impl client::RequestValue for CreateOrdersRequest {}
/// There is no detailed description.
///
/// # 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 proposals](ProposalInsertCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreateOrdersResponse {
/// The list of proposals successfully created.
pub proposals: Option<Vec<Proposal>>,
}
impl client::ResponseResult for CreateOrdersResponse {}
/// A creative and its classification data.
///
/// # 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*).
///
/// * [add deal creatives](CreativeAddDealCall) (none)
/// * [get creatives](CreativeGetCall) (response)
/// * [insert creatives](CreativeInsertCall) (request|response)
/// * [list creatives](CreativeListCall) (none)
/// * [list deals creatives](CreativeListDealCall) (none)
/// * [remove deal creatives](CreativeRemoveDealCall) (none)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Creative {
/// The HTML snippet that displays the ad when inserted in the web page. If set, videoURL, videoVastXML, and nativeAd should not be set.
#[serde(rename="HTMLSnippet")]
pub html_snippet: Option<String>,
/// Account id.
#[serde(rename="accountId")]
pub account_id: Option<i32>,
/// The link to the Ad Preferences page. This is only supported for native ads.
#[serde(rename="adChoicesDestinationUrl")]
pub ad_choices_destination_url: Option<String>,
/// no description provided
#[serde(rename="adTechnologyProviders")]
pub ad_technology_providers: Option<CreativeAdTechnologyProviders>,
/// Detected advertiser id, if any. Read-only. This field should not be set in requests.
#[serde(rename="advertiserId")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub advertiser_id: Option<Vec<i64>>,
/// The name of the company being advertised in the creative. A list of advertisers is provided in the advertisers.txt file.
#[serde(rename="advertiserName")]
pub advertiser_name: Option<String>,
/// The agency id for this creative.
#[serde(rename="agencyId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub agency_id: Option<i64>,
/// The last upload timestamp of this creative if it was uploaded via API. Read-only. The value of this field is generated, and will be ignored for uploads. (formatted RFC 3339 timestamp).
#[serde(rename="apiUploadTimestamp")]
pub api_upload_timestamp: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
/// List of buyer selectable attributes for the ads that may be shown from this snippet. Each attribute is represented by an integer as defined in buyer-declarable-creative-attributes.txt.
pub attribute: Option<Vec<i32>>,
/// A buyer-specific id identifying the creative in this ad.
#[serde(rename="buyerCreativeId")]
pub buyer_creative_id: Option<String>,
/// The set of destination urls for the snippet.
#[serde(rename="clickThroughUrl")]
pub click_through_url: Option<Vec<String>>,
/// Shows any corrections that were applied to this creative. Read-only. This field should not be set in requests.
pub corrections: Option<Vec<CreativeCorrections>>,
/// Creative status identity type that the creative item applies to. Ad Exchange real-time bidding is migrating to the sizeless creative verification. Originally, Ad Exchange assigned creative verification status to a unique combination of a buyer creative ID and creative dimensions. Post-migration, a single verification status will be assigned at the buyer creative ID level. This field allows to distinguish whether a given creative status applies to a unique combination of a buyer creative ID and creative dimensions, or to a buyer creative ID as a whole.
#[serde(rename="creativeStatusIdentityType")]
pub creative_status_identity_type: Option<String>,
/// Top-level deals status. Read-only. This field should not be set in requests. If disapproved, an entry for auctionType=DIRECT_DEALS (or ALL) in servingRestrictions will also exist. Note that this may be nuanced with other contextual restrictions, in which case it may be preferable to read from servingRestrictions directly.
#[serde(rename="dealsStatus")]
pub deals_status: Option<String>,
/// Detected domains for this creative. Read-only. This field should not be set in requests.
#[serde(rename="detectedDomains")]
pub detected_domains: Option<Vec<String>>,
/// The filtering reasons for the creative. Read-only. This field should not be set in requests.
#[serde(rename="filteringReasons")]
pub filtering_reasons: Option<CreativeFilteringReasons>,
/// Ad height.
pub height: Option<i32>,
/// The set of urls to be called to record an impression.
#[serde(rename="impressionTrackingUrl")]
pub impression_tracking_url: Option<Vec<String>>,
/// Resource type.
pub kind: Option<String>,
/// Detected languages for this creative. Read-only. This field should not be set in requests.
pub languages: Option<Vec<String>>,
/// If nativeAd is set, HTMLSnippet, videoVastXML, and the videoURL outside of nativeAd should not be set. (The videoURL inside nativeAd can be set.)
#[serde(rename="nativeAd")]
pub native_ad: Option<CreativeNativeAd>,
/// Top-level open auction status. Read-only. This field should not be set in requests. If disapproved, an entry for auctionType=OPEN_AUCTION (or ALL) in servingRestrictions will also exist. Note that this may be nuanced with other contextual restrictions, in which case it may be preferable to read from ServingRestrictions directly.
#[serde(rename="openAuctionStatus")]
pub open_auction_status: Option<String>,
/// Detected product categories, if any. Each category is represented by an integer as defined in ad-product-categories.txt. Read-only. This field should not be set in requests.
#[serde(rename="productCategories")]
pub product_categories: Option<Vec<i32>>,
/// All restricted categories for the ads that may be shown from this snippet. Each category is represented by an integer as defined in the ad-restricted-categories.txt.
#[serde(rename="restrictedCategories")]
pub restricted_categories: Option<Vec<i32>>,
/// Detected sensitive categories, if any. Each category is represented by an integer as defined in ad-sensitive-categories.txt. Read-only. This field should not be set in requests.
#[serde(rename="sensitiveCategories")]
pub sensitive_categories: Option<Vec<i32>>,
/// The granular status of this ad in specific contexts. A context here relates to where something ultimately serves (for example, a physical location, a platform, an HTTPS vs HTTP request, or the type of auction). Read-only. This field should not be set in requests. See the examples in the Creatives guide for more details.
#[serde(rename="servingRestrictions")]
pub serving_restrictions: Option<Vec<CreativeServingRestrictions>>,
/// List of vendor types for the ads that may be shown from this snippet. Each vendor type is represented by an integer as defined in vendors.txt.
#[serde(rename="vendorType")]
pub vendor_type: Option<Vec<i32>>,
/// The version for this creative. Read-only. This field should not be set in requests.
pub version: Option<i32>,
/// The URL to fetch a video ad. If set, HTMLSnippet, videoVastXML, and nativeAd should not be set. Note, this is different from resource.native_ad.video_url above.
#[serde(rename="videoURL")]
pub video_url: Option<String>,
/// The contents of a VAST document for a video ad. This document should conform to the VAST 2.0 or 3.0 standard. If set, HTMLSnippet, videoURL, and nativeAd and should not be set.
#[serde(rename="videoVastXML")]
pub video_vast_xml: Option<String>,
/// Ad width.
pub width: Option<i32>,
}
impl client::RequestValue for Creative {}
impl client::Resource for Creative {}
impl client::ResponseResult for Creative {}
/// The external deal ids associated with 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*).
///
/// * [list deals creatives](CreativeListDealCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeDealIds {
/// A list of external deal ids and ARC approval status.
#[serde(rename="dealStatuses")]
pub deal_statuses: Option<Vec<CreativeDealIdsDealStatuses>>,
/// Resource type.
pub kind: Option<String>,
}
impl client::ResponseResult for CreativeDealIds {}
/// The creatives feed lists the active creatives for the Ad Exchange buyer accounts that the user has access to. Each entry in the feed corresponds to a single 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*).
///
/// * [list creatives](CreativeListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativesList {
/// A list of creatives.
pub items: Option<Vec<Creative>>,
/// Resource type.
pub kind: Option<String>,
/// Continuation token used to page through creatives. To retrieve the next page of results, set the next request's "pageToken" value to this.
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
}
impl client::ResponseResult for CreativesList {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealServingMetadata {
/// True if alcohol ads are allowed for this deal (read-only). This field is only populated when querying for finalized orders using the method GetFinalizedOrderDeals
#[serde(rename="alcoholAdsAllowed")]
pub alcohol_ads_allowed: Option<bool>,
/// Tracks which parties (if any) have paused a deal. (readonly, except via PauseResumeOrderDeals action)
#[serde(rename="dealPauseStatus")]
pub deal_pause_status: Option<DealServingMetadataDealPauseStatus>,
}
impl client::Part for DealServingMetadata {}
/// Tracks which parties (if any) have paused a deal. The deal is considered paused if has_buyer_paused || has_seller_paused. Each of the has_buyer_paused or the has_seller_paused bits can be set independently.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealServingMetadataDealPauseStatus {
/// no description provided
#[serde(rename="buyerPauseReason")]
pub buyer_pause_reason: Option<String>,
/// If the deal is paused, records which party paused the deal first.
#[serde(rename="firstPausedBy")]
pub first_paused_by: Option<String>,
/// no description provided
#[serde(rename="hasBuyerPaused")]
pub has_buyer_paused: Option<bool>,
/// no description provided
#[serde(rename="hasSellerPaused")]
pub has_seller_paused: Option<bool>,
/// no description provided
#[serde(rename="sellerPauseReason")]
pub seller_pause_reason: Option<String>,
}
impl client::Part for DealServingMetadataDealPauseStatus {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTerms {
/// Visibility of the URL in bid requests.
#[serde(rename="brandingType")]
pub branding_type: Option<String>,
/// Indicates that this ExternalDealId exists under at least two different AdxInventoryDeals. Currently, the only case that the same ExternalDealId will exist is programmatic cross sell case.
#[serde(rename="crossListedExternalDealIdType")]
pub cross_listed_external_deal_id_type: Option<String>,
/// Description for the proposed terms of the deal.
pub description: Option<String>,
/// Non-binding estimate of the estimated gross spend for this deal Can be set by buyer or seller.
#[serde(rename="estimatedGrossSpend")]
pub estimated_gross_spend: Option<Price>,
/// Non-binding estimate of the impressions served per day Can be set by buyer or seller.
#[serde(rename="estimatedImpressionsPerDay")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub estimated_impressions_per_day: Option<i64>,
/// The terms for guaranteed fixed price deals.
#[serde(rename="guaranteedFixedPriceTerms")]
pub guaranteed_fixed_price_terms: Option<DealTermsGuaranteedFixedPriceTerms>,
/// The terms for non-guaranteed auction deals.
#[serde(rename="nonGuaranteedAuctionTerms")]
pub non_guaranteed_auction_terms: Option<DealTermsNonGuaranteedAuctionTerms>,
/// The terms for non-guaranteed fixed price deals.
#[serde(rename="nonGuaranteedFixedPriceTerms")]
pub non_guaranteed_fixed_price_terms: Option<DealTermsNonGuaranteedFixedPriceTerms>,
/// The terms for rubicon non-guaranteed deals.
#[serde(rename="rubiconNonGuaranteedTerms")]
pub rubicon_non_guaranteed_terms: Option<DealTermsRubiconNonGuaranteedTerms>,
/// For deals with Cost Per Day billing, defines the timezone used to mark the boundaries of a day (buyer-readonly)
#[serde(rename="sellerTimeZone")]
pub seller_time_zone: Option<String>,
}
impl client::Part for DealTerms {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTermsGuaranteedFixedPriceTerms {
/// External billing info for this Deal. This field is relevant when external billing info such as price has a different currency code than DFP/AdX.
#[serde(rename="billingInfo")]
pub billing_info: Option<DealTermsGuaranteedFixedPriceTermsBillingInfo>,
/// Fixed price for the specified buyer.
#[serde(rename="fixedPrices")]
pub fixed_prices: Option<Vec<PricePerBuyer>>,
/// Guaranteed impressions as a percentage. This is the percentage of guaranteed looks that the buyer is guaranteeing to buy.
#[serde(rename="guaranteedImpressions")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub guaranteed_impressions: Option<i64>,
/// Count of guaranteed looks. Required for deal, optional for product. For CPD deals, buyer changes to guaranteed_looks will be ignored.
#[serde(rename="guaranteedLooks")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub guaranteed_looks: Option<i64>,
/// Count of minimum daily looks for a CPD deal. For CPD deals, buyer should negotiate on this field instead of guaranteed_looks.
#[serde(rename="minimumDailyLooks")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub minimum_daily_looks: Option<i64>,
}
impl client::Part for DealTermsGuaranteedFixedPriceTerms {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTermsGuaranteedFixedPriceTermsBillingInfo {
/// The timestamp (in ms since epoch) when the original reservation price for the deal was first converted to DFP currency. This is used to convert the contracted price into buyer's currency without discrepancy.
#[serde(rename="currencyConversionTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub currency_conversion_time_ms: Option<i64>,
/// The DFP line item id associated with this deal. For features like CPD, buyers can retrieve the DFP line item for billing reconciliation.
#[serde(rename="dfpLineItemId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub dfp_line_item_id: Option<i64>,
/// The original contracted quantity (# impressions) for this deal. To ensure delivery, sometimes the publisher will book the deal with a impression buffer, such that guaranteed_looks is greater than the contracted quantity. However clients are billed using the original contracted quantity.
#[serde(rename="originalContractedQuantity")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub original_contracted_quantity: Option<i64>,
/// The original reservation price for the deal, if the currency code is different from the one used in negotiation.
pub price: Option<Price>,
}
impl client::Part for DealTermsGuaranteedFixedPriceTermsBillingInfo {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTermsNonGuaranteedAuctionTerms {
/// True if open auction buyers are allowed to compete with invited buyers in this private auction (buyer-readonly).
#[serde(rename="autoOptimizePrivateAuction")]
pub auto_optimize_private_auction: Option<bool>,
/// Reserve price for the specified buyer.
#[serde(rename="reservePricePerBuyers")]
pub reserve_price_per_buyers: Option<Vec<PricePerBuyer>>,
}
impl client::Part for DealTermsNonGuaranteedAuctionTerms {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTermsNonGuaranteedFixedPriceTerms {
/// Fixed price for the specified buyer.
#[serde(rename="fixedPrices")]
pub fixed_prices: Option<Vec<PricePerBuyer>>,
}
impl client::Part for DealTermsNonGuaranteedFixedPriceTerms {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DealTermsRubiconNonGuaranteedTerms {
/// Optional price for Rubicon priority access in the auction.
#[serde(rename="priorityPrice")]
pub priority_price: Option<Price>,
/// Optional price for Rubicon standard access in the auction.
#[serde(rename="standardPrice")]
pub standard_price: Option<Price>,
}
impl client::Part for DealTermsRubiconNonGuaranteedTerms {}
/// There is no detailed description.
///
/// # 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 marketplacedeals](MarketplacedealDeleteCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DeleteOrderDealsRequest {
/// List of deals to delete for a given proposal
#[serde(rename="dealIds")]
pub deal_ids: Option<Vec<String>>,
/// The last known proposal revision number.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
/// Indicates an optional action to take on the proposal
#[serde(rename="updateAction")]
pub update_action: Option<String>,
}
impl client::RequestValue for DeleteOrderDealsRequest {}
/// There is no detailed description.
///
/// # 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 marketplacedeals](MarketplacedealDeleteCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DeleteOrderDealsResponse {
/// List of deals deleted (in the same proposal as passed in the request)
pub deals: Option<Vec<MarketplaceDeal>>,
/// The updated revision number for the proposal.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
}
impl client::ResponseResult for DeleteOrderDealsResponse {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DeliveryControl {
/// no description provided
#[serde(rename="creativeBlockingLevel")]
pub creative_blocking_level: Option<String>,
/// no description provided
#[serde(rename="deliveryRateType")]
pub delivery_rate_type: Option<String>,
/// no description provided
#[serde(rename="frequencyCaps")]
pub frequency_caps: Option<Vec<DeliveryControlFrequencyCap>>,
}
impl client::Part for DeliveryControl {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DeliveryControlFrequencyCap {
/// no description provided
#[serde(rename="maxImpressions")]
pub max_impressions: Option<i32>,
/// no description provided
#[serde(rename="numTimeUnits")]
pub num_time_units: Option<i32>,
/// no description provided
#[serde(rename="timeUnitType")]
pub time_unit_type: Option<String>,
}
impl client::Part for DeliveryControlFrequencyCap {}
/// This message carries publisher provided breakdown. E.g. {dimension_type: 'COUNTRY', [{dimension_value: {id: 1, name: 'US'}}, {dimension_value: {id: 2, name: 'UK'}}]}
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Dimension {
/// no description provided
#[serde(rename="dimensionType")]
pub dimension_type: Option<String>,
/// no description provided
#[serde(rename="dimensionValues")]
pub dimension_values: Option<Vec<DimensionDimensionValue>>,
}
impl client::Part for Dimension {}
/// Value of the dimension.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DimensionDimensionValue {
/// Id of the dimension.
pub id: Option<i32>,
/// Name of the dimension mainly for debugging purposes, except for the case of CREATIVE_SIZE. For CREATIVE_SIZE, strings are used instead of ids.
pub name: Option<String>,
/// Percent of total impressions for a dimension type. e.g. {dimension_type: 'GENDER', [{dimension_value: {id: 1, name: 'MALE', percentage: 60}}]} Gender MALE is 60% of all impressions which have gender.
pub percentage: Option<i32>,
}
impl client::Part for DimensionDimensionValue {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [update marketplacedeals](MarketplacedealUpdateCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct EditAllOrderDealsRequest {
/// List of deals to edit. Service may perform 3 different operations based on comparison of deals in this list vs deals already persisted in database: 1. Add new deal to proposal If a deal in this list does not exist in the proposal, the service will create a new deal and add it to the proposal. Validation will follow AddOrderDealsRequest. 2. Update existing deal in the proposal If a deal in this list already exist in the proposal, the service will update that existing deal to this new deal in the request. Validation will follow UpdateOrderDealsRequest. 3. Delete deals from the proposal (just need the id) If a existing deal in the proposal is not present in this list, the service will delete that deal from the proposal. Validation will follow DeleteOrderDealsRequest.
pub deals: Option<Vec<MarketplaceDeal>>,
/// If specified, also updates the proposal in the batch transaction. This is useful when the proposal and the deals need to be updated in one transaction.
pub proposal: Option<Proposal>,
/// The last known revision number for the proposal.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
/// Indicates an optional action to take on the proposal
#[serde(rename="updateAction")]
pub update_action: Option<String>,
}
impl client::RequestValue for EditAllOrderDealsRequest {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [update marketplacedeals](MarketplacedealUpdateCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct EditAllOrderDealsResponse {
/// List of all deals in the proposal after edit.
pub deals: Option<Vec<MarketplaceDeal>>,
/// The latest revision number after the update has been applied.
#[serde(rename="orderRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub order_revision_number: Option<i64>,
}
impl client::ResponseResult for EditAllOrderDealsResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [search products](ProductSearchCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetOffersResponse {
/// The returned list of products.
pub products: Option<Vec<Product>>,
}
impl client::ResponseResult for GetOffersResponse {}
/// There is no detailed description.
///
/// # 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 marketplacedeals](MarketplacedealListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetOrderDealsResponse {
/// List of deals for the proposal
pub deals: Option<Vec<MarketplaceDeal>>,
}
impl client::ResponseResult for GetOrderDealsResponse {}
/// There is no detailed description.
///
/// # 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 marketplacenotes](MarketplacenoteListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetOrderNotesResponse {
/// The list of matching notes. The notes for a proposal are ordered from oldest to newest. If the notes span multiple proposals, they will be grouped by proposal, with the notes for the most recently modified proposal appearing first.
pub notes: Option<Vec<MarketplaceNote>>,
}
impl client::ResponseResult for GetOrderNotesResponse {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [search proposals](ProposalSearchCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetOrdersResponse {
/// The list of matching proposals.
pub proposals: Option<Vec<Proposal>>,
}
impl client::ResponseResult for GetOrdersResponse {}
/// There is no detailed description.
///
/// # 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 pubprofiles](PubprofileListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetPublisherProfilesByAccountIdResponse {
/// Profiles for the requested publisher
pub profiles: Option<Vec<PublisherProfileApiProto>>,
}
impl client::ResponseResult for GetPublisherProfilesByAccountIdResponse {}
/// A proposal can contain multiple deals. A deal contains the terms and targeting information that is used for serving.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MarketplaceDeal {
/// Buyer private data (hidden from seller).
#[serde(rename="buyerPrivateData")]
pub buyer_private_data: Option<PrivateData>,
/// The time (ms since epoch) of the deal creation. (readonly)
#[serde(rename="creationTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub creation_time_ms: Option<i64>,
/// Specifies the creative pre-approval policy (buyer-readonly)
#[serde(rename="creativePreApprovalPolicy")]
pub creative_pre_approval_policy: Option<String>,
/// Specifies whether the creative is safeFrame compatible (buyer-readonly)
#[serde(rename="creativeSafeFrameCompatibility")]
pub creative_safe_frame_compatibility: Option<String>,
/// A unique deal-id for the deal (readonly).
#[serde(rename="dealId")]
pub deal_id: Option<String>,
/// Metadata about the serving status of this deal (readonly, writes via custom actions)
#[serde(rename="dealServingMetadata")]
pub deal_serving_metadata: Option<DealServingMetadata>,
/// The set of fields around delivery control that are interesting for a buyer to see but are non-negotiable. These are set by the publisher. This message is assigned an id of 100 since some day we would want to model this as a protobuf extension.
#[serde(rename="deliveryControl")]
pub delivery_control: Option<DeliveryControl>,
/// The external deal id assigned to this deal once the deal is finalized. This is the deal-id that shows up in serving/reporting etc. (readonly)
#[serde(rename="externalDealId")]
pub external_deal_id: Option<String>,
/// Proposed flight end time of the deal (ms since epoch) This will generally be stored in a granularity of a second. (updatable)
#[serde(rename="flightEndTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub flight_end_time_ms: Option<i64>,
/// Proposed flight start time of the deal (ms since epoch) This will generally be stored in a granularity of a second. (updatable)
#[serde(rename="flightStartTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub flight_start_time_ms: Option<i64>,
/// Description for the deal terms. (buyer-readonly)
#[serde(rename="inventoryDescription")]
pub inventory_description: Option<String>,
/// Indicates whether the current deal is a RFP template. RFP template is created by buyer and not based on seller created products.
#[serde(rename="isRfpTemplate")]
pub is_rfp_template: Option<bool>,
/// True, if the buyside inventory setup is complete for this deal. (readonly, except via OrderSetupCompleted action)
#[serde(rename="isSetupComplete")]
pub is_setup_complete: Option<bool>,
/// Identifies what kind of resource this is. Value: the fixed string "adexchangebuyer#marketplaceDeal".
pub kind: Option<String>,
/// The time (ms since epoch) when the deal was last updated. (readonly)
#[serde(rename="lastUpdateTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub last_update_time_ms: Option<i64>,
/// no description provided
#[serde(rename="makegoodRequestedReason")]
pub makegood_requested_reason: Option<String>,
/// The name of the deal. (updatable)
pub name: Option<String>,
/// The product-id from which this deal was created. (readonly, except on create)
#[serde(rename="productId")]
pub product_id: Option<String>,
/// The revision number of the product that the deal was created from (readonly, except on create)
#[serde(rename="productRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub product_revision_number: Option<i64>,
/// Specifies the creative source for programmatic deals, PUBLISHER means creative is provided by seller and ADVERTISR means creative is provided by buyer. (buyer-readonly)
#[serde(rename="programmaticCreativeSource")]
pub programmatic_creative_source: Option<String>,
/// no description provided
#[serde(rename="proposalId")]
pub proposal_id: Option<String>,
/// Optional Seller contact information for the deal (buyer-readonly)
#[serde(rename="sellerContacts")]
pub seller_contacts: Option<Vec<ContactInformation>>,
/// The shared targeting visible to buyers and sellers. Each shared targeting entity is AND'd together. (updatable)
#[serde(rename="sharedTargetings")]
pub shared_targetings: Option<Vec<SharedTargeting>>,
/// The syndication product associated with the deal. (readonly, except on create)
#[serde(rename="syndicationProduct")]
pub syndication_product: Option<String>,
/// The negotiable terms of the deal. (updatable)
pub terms: Option<DealTerms>,
/// no description provided
#[serde(rename="webPropertyCode")]
pub web_property_code: Option<String>,
}
impl client::Part for MarketplaceDeal {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MarketplaceDealParty {
/// The buyer/seller associated with the deal. One of buyer/seller is specified for a deal-party.
pub buyer: Option<Buyer>,
/// The buyer/seller associated with the deal. One of buyer/seller is specified for a deal party.
pub seller: Option<Seller>,
}
impl client::Part for MarketplaceDealParty {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MarketplaceLabel {
/// The accountId of the party that created the label.
#[serde(rename="accountId")]
pub account_id: Option<String>,
/// The creation time (in ms since epoch) for the label.
#[serde(rename="createTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub create_time_ms: Option<i64>,
/// Information about the party that created the label.
#[serde(rename="deprecatedMarketplaceDealParty")]
pub deprecated_marketplace_deal_party: Option<MarketplaceDealParty>,
/// The label to use.
pub label: Option<String>,
}
impl client::Part for MarketplaceLabel {}
/// A proposal is associated with a bunch of notes which may optionally be associated with a deal and/or revision number.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MarketplaceNote {
/// The role of the person (buyer/seller) creating the note. (readonly)
#[serde(rename="creatorRole")]
pub creator_role: Option<String>,
/// Notes can optionally be associated with a deal. (readonly, except on create)
#[serde(rename="dealId")]
pub deal_id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "adexchangebuyer#marketplaceNote".
pub kind: Option<String>,
/// The actual note to attach. (readonly, except on create)
pub note: Option<String>,
/// The unique id for the note. (readonly)
#[serde(rename="noteId")]
pub note_id: Option<String>,
/// The proposalId that a note is attached to. (readonly)
#[serde(rename="proposalId")]
pub proposal_id: Option<String>,
/// If the note is associated with a proposal revision number, then store that here. (readonly, except on create)
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
/// The timestamp (ms since epoch) that this note was created. (readonly)
#[serde(rename="timestampMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub timestamp_ms: Option<i64>,
}
impl client::Part for MarketplaceNote {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct MobileApplication {
/// no description provided
#[serde(rename="appStore")]
pub app_store: Option<String>,
/// no description provided
#[serde(rename="externalAppId")]
pub external_app_id: Option<String>,
}
impl client::Part for MobileApplication {}
/// The configuration data for an Ad Exchange performance report list.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PerformanceReport {
/// The number of bid responses with an ad.
#[serde(rename="bidRate")]
pub bid_rate: Option<f64>,
/// The number of bid requests sent to your bidder.
#[serde(rename="bidRequestRate")]
pub bid_request_rate: Option<f64>,
/// Rate of various prefiltering statuses per match. Please refer to the callout-status-codes.txt file for different statuses.
#[serde(rename="calloutStatusRate")]
pub callout_status_rate: Option<Vec<json::Value>>,
/// Average QPS for cookie matcher operations.
#[serde(rename="cookieMatcherStatusRate")]
pub cookie_matcher_status_rate: Option<Vec<json::Value>>,
/// Rate of ads with a given status. Please refer to the creative-status-codes.txt file for different statuses.
#[serde(rename="creativeStatusRate")]
pub creative_status_rate: Option<Vec<json::Value>>,
/// The number of bid responses that were filtered due to a policy violation or other errors.
#[serde(rename="filteredBidRate")]
pub filtered_bid_rate: Option<f64>,
/// Average QPS for hosted match operations.
#[serde(rename="hostedMatchStatusRate")]
pub hosted_match_status_rate: Option<Vec<json::Value>>,
/// The number of potential queries based on your pretargeting settings.
#[serde(rename="inventoryMatchRate")]
pub inventory_match_rate: Option<f64>,
/// Resource type.
pub kind: Option<String>,
/// The 50th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report.
#[serde(rename="latency50thPercentile")]
pub latency50th_percentile: Option<f64>,
/// The 85th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report.
#[serde(rename="latency85thPercentile")]
pub latency85th_percentile: Option<f64>,
/// The 95th percentile round trip latency(ms) as perceived from Google servers for the duration period covered by the report.
#[serde(rename="latency95thPercentile")]
pub latency95th_percentile: Option<f64>,
/// Rate of various quota account statuses per quota check.
#[serde(rename="noQuotaInRegion")]
pub no_quota_in_region: Option<f64>,
/// Rate of various quota account statuses per quota check.
#[serde(rename="outOfQuota")]
pub out_of_quota: Option<f64>,
/// Average QPS for pixel match requests from clients.
#[serde(rename="pixelMatchRequests")]
pub pixel_match_requests: Option<f64>,
/// Average QPS for pixel match responses from clients.
#[serde(rename="pixelMatchResponses")]
pub pixel_match_responses: Option<f64>,
/// The configured quota limits for this account.
#[serde(rename="quotaConfiguredLimit")]
pub quota_configured_limit: Option<f64>,
/// The throttled quota limits for this account.
#[serde(rename="quotaThrottledLimit")]
pub quota_throttled_limit: Option<f64>,
/// The trading location of this data.
pub region: Option<String>,
/// The number of properly formed bid responses received by our servers within the deadline.
#[serde(rename="successfulRequestRate")]
pub successful_request_rate: Option<f64>,
/// The unix timestamp of the starting time of this performance data.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub timestamp: Option<i64>,
/// The number of bid responses that were unsuccessful due to timeouts, incorrect formatting, etc.
#[serde(rename="unsuccessfulRequestRate")]
pub unsuccessful_request_rate: Option<f64>,
}
impl client::Part for PerformanceReport {}
/// The configuration data for an Ad Exchange performance report list.
///
/// # 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 performance report](PerformanceReportListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PerformanceReportList {
/// Resource type.
pub kind: Option<String>,
/// A list of performance reports relevant for the account.
#[serde(rename="performanceReport")]
pub performance_report: Option<Vec<PerformanceReport>>,
}
impl client::ResponseResult for PerformanceReportList {}
/// There is no detailed description.
///
/// # 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 pretargeting config](PretargetingConfigGetCall) (response)
/// * [insert pretargeting config](PretargetingConfigInsertCall) (request|response)
/// * [patch pretargeting config](PretargetingConfigPatchCall) (request|response)
/// * [update pretargeting config](PretargetingConfigUpdateCall) (request|response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfig {
/// The id for billing purposes, provided for reference. Leave this field blank for insert requests; the id will be generated automatically.
#[serde(rename="billingId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub billing_id: Option<i64>,
/// The config id; generated automatically. Leave this field blank for insert requests.
#[serde(rename="configId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub config_id: Option<i64>,
/// The name of the config. Must be unique. Required for all requests.
#[serde(rename="configName")]
pub config_name: Option<String>,
/// List must contain exactly one of PRETARGETING_CREATIVE_TYPE_HTML or PRETARGETING_CREATIVE_TYPE_VIDEO.
#[serde(rename="creativeType")]
pub creative_type: Option<Vec<String>>,
/// Requests which allow one of these (width, height) pairs will match. All pairs must be supported ad dimensions.
pub dimensions: Option<Vec<PretargetingConfigDimensions>>,
/// Requests with any of these content labels will not match. Values are from content-labels.txt in the downloadable files section.
#[serde(rename="excludedContentLabels")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub excluded_content_labels: Option<Vec<i64>>,
/// Requests containing any of these geo criteria ids will not match.
#[serde(rename="excludedGeoCriteriaIds")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub excluded_geo_criteria_ids: Option<Vec<i64>>,
/// Requests containing any of these placements will not match.
#[serde(rename="excludedPlacements")]
pub excluded_placements: Option<Vec<PretargetingConfigExcludedPlacements>>,
/// Requests containing any of these users list ids will not match.
#[serde(rename="excludedUserLists")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub excluded_user_lists: Option<Vec<i64>>,
/// Requests containing any of these vertical ids will not match. Values are from the publisher-verticals.txt file in the downloadable files section.
#[serde(rename="excludedVerticals")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub excluded_verticals: Option<Vec<i64>>,
/// Requests containing any of these geo criteria ids will match.
#[serde(rename="geoCriteriaIds")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub geo_criteria_ids: Option<Vec<i64>>,
/// Whether this config is active. Required for all requests.
#[serde(rename="isActive")]
pub is_active: Option<bool>,
/// The kind of the resource, i.e. "adexchangebuyer#pretargetingConfig".
pub kind: Option<String>,
/// Request containing any of these language codes will match.
pub languages: Option<Vec<String>>,
/// The maximum QPS allocated to this pretargeting configuration, used for pretargeting-level QPS limits. By default, this is not set, which indicates that there is no QPS limit at the configuration level (a global or account-level limit may still be imposed).
#[serde(rename="maximumQps")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub maximum_qps: Option<i64>,
/// Requests where the predicted viewability is below the specified decile will not match. E.g. if the buyer sets this value to 5, requests from slots where the predicted viewability is below 50% will not match. If the predicted viewability is unknown this field will be ignored.
#[serde(rename="minimumViewabilityDecile")]
pub minimum_viewability_decile: Option<i32>,
/// Requests containing any of these mobile carrier ids will match. Values are from mobile-carriers.csv in the downloadable files section.
#[serde(rename="mobileCarriers")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub mobile_carriers: Option<Vec<i64>>,
/// Requests containing any of these mobile device ids will match. Values are from mobile-devices.csv in the downloadable files section.
#[serde(rename="mobileDevices")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub mobile_devices: Option<Vec<i64>>,
/// Requests containing any of these mobile operating system version ids will match. Values are from mobile-os.csv in the downloadable files section.
#[serde(rename="mobileOperatingSystemVersions")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub mobile_operating_system_versions: Option<Vec<i64>>,
/// Requests containing any of these placements will match.
pub placements: Option<Vec<PretargetingConfigPlacements>>,
/// Requests matching any of these platforms will match. Possible values are PRETARGETING_PLATFORM_MOBILE, PRETARGETING_PLATFORM_DESKTOP, and PRETARGETING_PLATFORM_TABLET.
pub platforms: Option<Vec<String>>,
/// Creative attributes should be declared here if all creatives corresponding to this pretargeting configuration have that creative attribute. Values are from pretargetable-creative-attributes.txt in the downloadable files section.
#[serde(rename="supportedCreativeAttributes")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub supported_creative_attributes: Option<Vec<i64>>,
/// Requests containing the specified type of user data will match. Possible values are HOSTED_MATCH_DATA, which means the request is cookie-targetable and has a match in the buyer's hosted match table, and COOKIE_OR_IDFA, which means the request has either a targetable cookie or an iOS IDFA.
#[serde(rename="userIdentifierDataRequired")]
pub user_identifier_data_required: Option<Vec<String>>,
/// Requests containing any of these user list ids will match.
#[serde(rename="userLists")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub user_lists: Option<Vec<i64>>,
/// Requests that allow any of these vendor ids will match. Values are from vendors.txt in the downloadable files section.
#[serde(rename="vendorTypes")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub vendor_types: Option<Vec<i64>>,
/// Requests containing any of these vertical ids will match.
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub verticals: Option<Vec<i64>>,
/// Video requests satisfying any of these player size constraints will match.
#[serde(rename="videoPlayerSizes")]
pub video_player_sizes: Option<Vec<PretargetingConfigVideoPlayerSizes>>,
}
impl client::RequestValue for PretargetingConfig {}
impl client::ResponseResult for PretargetingConfig {}
/// There is no detailed description.
///
/// # 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 pretargeting config](PretargetingConfigListCall) (response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfigList {
/// A list of pretargeting configs
pub items: Option<Vec<PretargetingConfig>>,
/// Resource type.
pub kind: Option<String>,
}
impl client::ResponseResult for PretargetingConfigList {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Price {
/// The price value in micros.
#[serde(rename="amountMicros")]
pub amount_micros: Option<f64>,
/// The currency code for the price.
#[serde(rename="currencyCode")]
pub currency_code: Option<String>,
/// In case of CPD deals, the expected CPM in micros.
#[serde(rename="expectedCpmMicros")]
pub expected_cpm_micros: Option<f64>,
/// The pricing type for the deal/product.
#[serde(rename="pricingType")]
pub pricing_type: Option<String>,
}
impl client::Part for Price {}
/// Used to specify pricing rules for buyers. Each PricePerBuyer in a product can become [0,1] deals. To check if there is a PricePerBuyer for a particular buyer we look for the most specific matching rule - we first look for a rule matching the buyer and otherwise look for a matching rule where no buyer is set.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PricePerBuyer {
/// Optional access type for this buyer.
#[serde(rename="auctionTier")]
pub auction_tier: Option<String>,
/// Reference to the buyer that will get billed.
#[serde(rename="billedBuyer")]
pub billed_buyer: Option<Buyer>,
/// The buyer who will pay this price. If unset, all buyers can pay this price (if the advertisers match, and there's no more specific rule matching the buyer).
pub buyer: Option<Buyer>,
/// The specified price
pub price: Option<Price>,
}
impl client::Part for PricePerBuyer {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PrivateData {
/// no description provided
#[serde(rename="referenceId")]
pub reference_id: Option<String>,
/// no description provided
#[serde(rename="referencePayload")]
#[serde_as(as = "Option<::client::serde::urlsafe_base64::Wrapper>")]
pub reference_payload: Option<Vec<u8>>,
}
impl client::Part for PrivateData {}
/// A product is segment of inventory that a seller wishes to sell. It is associated with certain terms and targeting information which helps buyer know more about the inventory. Each field in a product can have one of the following setting:
///
/// (readonly) - It is an error to try and set this field. (buyer-readonly) - Only the seller can set this field. (seller-readonly) - Only the buyer can set this field. (updatable) - The field is updatable at all times by either buyer or the seller.
///
/// # 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 products](ProductGetCall) (response)
/// * [search products](ProductSearchCall) (none)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Product {
/// The billed buyer corresponding to the buyer that created the offer. (readonly, except on create)
#[serde(rename="billedBuyer")]
pub billed_buyer: Option<Buyer>,
/// The buyer that created the offer if this is a buyer initiated offer (readonly, except on create)
pub buyer: Option<Buyer>,
/// Creation time in ms. since epoch (readonly)
#[serde(rename="creationTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub creation_time_ms: Option<i64>,
/// Optional contact information for the creator of this product. (buyer-readonly)
#[serde(rename="creatorContacts")]
pub creator_contacts: Option<Vec<ContactInformation>>,
/// The role that created the offer. Set to BUYER for buyer initiated offers.
#[serde(rename="creatorRole")]
pub creator_role: Option<String>,
/// The set of fields around delivery control that are interesting for a buyer to see but are non-negotiable. These are set by the publisher. This message is assigned an id of 100 since some day we would want to model this as a protobuf extension.
#[serde(rename="deliveryControl")]
pub delivery_control: Option<DeliveryControl>,
/// The proposed end time for the deal (ms since epoch) (buyer-readonly)
#[serde(rename="flightEndTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub flight_end_time_ms: Option<i64>,
/// Inventory availability dates. (times are in ms since epoch) The granularity is generally in the order of seconds. (buyer-readonly)
#[serde(rename="flightStartTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub flight_start_time_ms: Option<i64>,
/// If the creator has already signed off on the product, then the buyer can finalize the deal by accepting the product as is. When copying to a proposal, if any of the terms are changed, then auto_finalize is automatically set to false.
#[serde(rename="hasCreatorSignedOff")]
pub has_creator_signed_off: Option<bool>,
/// What exchange will provide this inventory (readonly, except on create).
#[serde(rename="inventorySource")]
pub inventory_source: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "adexchangebuyer#product".
pub kind: Option<String>,
/// Optional List of labels for the product (optional, buyer-readonly).
pub labels: Option<Vec<MarketplaceLabel>>,
/// Time of last update in ms. since epoch (readonly)
#[serde(rename="lastUpdateTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub last_update_time_ms: Option<i64>,
/// Optional legacy offer id if this offer is a preferred deal offer.
#[serde(rename="legacyOfferId")]
pub legacy_offer_id: Option<String>,
/// Marketplace publisher profile Id. This Id differs from the regular publisher_profile_id in that 1. This is a new id, the old Id will be deprecated in 2017. 2. This id uniquely identifies a publisher profile by itself.
#[serde(rename="marketplacePublisherProfileId")]
pub marketplace_publisher_profile_id: Option<String>,
/// The name for this product as set by the seller. (buyer-readonly)
pub name: Option<String>,
/// Optional private auction id if this offer is a private auction offer.
#[serde(rename="privateAuctionId")]
pub private_auction_id: Option<String>,
/// The unique id for the product (readonly)
#[serde(rename="productId")]
pub product_id: Option<String>,
/// Id of the publisher profile for a given seller. A (seller.account_id, publisher_profile_id) pair uniquely identifies a publisher profile. Buyers can call the PublisherProfiles::List endpoint to get a list of publisher profiles for a given seller.
#[serde(rename="publisherProfileId")]
pub publisher_profile_id: Option<String>,
/// Publisher self-provided forecast information.
#[serde(rename="publisherProvidedForecast")]
pub publisher_provided_forecast: Option<PublisherProvidedForecast>,
/// The revision number of the product. (readonly)
#[serde(rename="revisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub revision_number: Option<i64>,
/// Information about the seller that created this product (readonly, except on create)
pub seller: Option<Seller>,
/// Targeting that is shared between the buyer and the seller. Each targeting criteria has a specified key and for each key there is a list of inclusion value or exclusion values. (buyer-readonly)
#[serde(rename="sharedTargetings")]
pub shared_targetings: Option<Vec<SharedTargeting>>,
/// The state of the product. (buyer-readonly)
pub state: Option<String>,
/// The syndication product associated with the deal. (readonly, except on create)
#[serde(rename="syndicationProduct")]
pub syndication_product: Option<String>,
/// The negotiable terms of the deal (buyer-readonly)
pub terms: Option<DealTerms>,
/// The web property code for the seller. This field is meant to be copied over as is when creating deals.
#[serde(rename="webPropertyCode")]
pub web_property_code: Option<String>,
}
impl client::Resource for Product {}
impl client::ResponseResult for Product {}
/// Represents a proposal in the marketplace. A proposal is the unit of negotiation between a seller and a buyer and contains deals which are served. Each field in a proposal can have one of the following setting:
///
/// (readonly) - It is an error to try and set this field. (buyer-readonly) - Only the seller can set this field. (seller-readonly) - Only the buyer can set this field. (updatable) - The field is updatable at all times by either buyer or the seller.
///
/// # 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 proposals](ProposalGetCall) (response)
/// * [insert proposals](ProposalInsertCall) (none)
/// * [patch proposals](ProposalPatchCall) (request|response)
/// * [search proposals](ProposalSearchCall) (none)
/// * [setupcomplete proposals](ProposalSetupcompleteCall) (none)
/// * [update proposals](ProposalUpdateCall) (request|response)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Proposal {
/// Reference to the buyer that will get billed for this proposal. (readonly)
#[serde(rename="billedBuyer")]
pub billed_buyer: Option<Buyer>,
/// Reference to the buyer on the proposal. (readonly, except on create)
pub buyer: Option<Buyer>,
/// Optional contact information of the buyer. (seller-readonly)
#[serde(rename="buyerContacts")]
pub buyer_contacts: Option<Vec<ContactInformation>>,
/// Private data for buyer. (hidden from seller).
#[serde(rename="buyerPrivateData")]
pub buyer_private_data: Option<PrivateData>,
/// IDs of DBM advertisers permission to this proposal.
#[serde(rename="dbmAdvertiserIds")]
pub dbm_advertiser_ids: Option<Vec<String>>,
/// When an proposal is in an accepted state, indicates whether the buyer has signed off. Once both sides have signed off on a deal, the proposal can be finalized by the seller. (seller-readonly)
#[serde(rename="hasBuyerSignedOff")]
pub has_buyer_signed_off: Option<bool>,
/// When an proposal is in an accepted state, indicates whether the buyer has signed off Once both sides have signed off on a deal, the proposal can be finalized by the seller. (buyer-readonly)
#[serde(rename="hasSellerSignedOff")]
pub has_seller_signed_off: Option<bool>,
/// What exchange will provide this inventory (readonly, except on create).
#[serde(rename="inventorySource")]
pub inventory_source: Option<String>,
/// True if the proposal is being renegotiated (readonly).
#[serde(rename="isRenegotiating")]
pub is_renegotiating: Option<bool>,
/// True, if the buyside inventory setup is complete for this proposal. (readonly, except via OrderSetupCompleted action) Deprecated in favor of deal level setup complete flag.
#[serde(rename="isSetupComplete")]
pub is_setup_complete: Option<bool>,
/// Identifies what kind of resource this is. Value: the fixed string "adexchangebuyer#proposal".
pub kind: Option<String>,
/// List of labels associated with the proposal. (readonly)
pub labels: Option<Vec<MarketplaceLabel>>,
/// The role of the last user that either updated the proposal or left a comment. (readonly)
#[serde(rename="lastUpdaterOrCommentorRole")]
pub last_updater_or_commentor_role: Option<String>,
/// The name for the proposal (updatable)
pub name: Option<String>,
/// Optional negotiation id if this proposal is a preferred deal proposal.
#[serde(rename="negotiationId")]
pub negotiation_id: Option<String>,
/// Indicates whether the buyer/seller created the proposal.(readonly)
#[serde(rename="originatorRole")]
pub originator_role: Option<String>,
/// Optional private auction id if this proposal is a private auction proposal.
#[serde(rename="privateAuctionId")]
pub private_auction_id: Option<String>,
/// The unique id of the proposal. (readonly).
#[serde(rename="proposalId")]
pub proposal_id: Option<String>,
/// The current state of the proposal. (readonly)
#[serde(rename="proposalState")]
pub proposal_state: Option<String>,
/// The revision number for the proposal (readonly).
#[serde(rename="revisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub revision_number: Option<i64>,
/// The time (ms since epoch) when the proposal was last revised (readonly).
#[serde(rename="revisionTimeMs")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub revision_time_ms: Option<i64>,
/// Reference to the seller on the proposal. (readonly, except on create)
pub seller: Option<Seller>,
/// Optional contact information of the seller (buyer-readonly).
#[serde(rename="sellerContacts")]
pub seller_contacts: Option<Vec<ContactInformation>>,
}
impl client::RequestValue for Proposal {}
impl client::Resource for Proposal {}
impl client::ResponseResult for Proposal {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PublisherProfileApiProto {
/// Publisher provided info on its audience.
pub audience: Option<String>,
/// A pitch statement for the buyer
#[serde(rename="buyerPitchStatement")]
pub buyer_pitch_statement: Option<String>,
/// Direct contact for the publisher profile.
#[serde(rename="directContact")]
pub direct_contact: Option<String>,
/// Exchange where this publisher profile is from. E.g. AdX, Rubicon etc...
pub exchange: Option<String>,
/// Link to publisher's Google+ page.
#[serde(rename="googlePlusLink")]
pub google_plus_link: Option<String>,
/// True, if this is the parent profile, which represents all domains owned by the publisher.
#[serde(rename="isParent")]
pub is_parent: Option<bool>,
/// True, if this profile is published. Deprecated for state.
#[serde(rename="isPublished")]
pub is_published: Option<bool>,
/// Identifies what kind of resource this is. Value: the fixed string "adexchangebuyer#publisherProfileApiProto".
pub kind: Option<String>,
/// The url to the logo for the publisher.
#[serde(rename="logoUrl")]
pub logo_url: Option<String>,
/// The url for additional marketing and sales materials.
#[serde(rename="mediaKitLink")]
pub media_kit_link: Option<String>,
/// no description provided
pub name: Option<String>,
/// Publisher provided overview.
pub overview: Option<String>,
/// The pair of (seller.account_id, profile_id) uniquely identifies a publisher profile for a given publisher.
#[serde(rename="profileId")]
pub profile_id: Option<i32>,
/// Programmatic contact for the publisher profile.
#[serde(rename="programmaticContact")]
pub programmatic_contact: Option<String>,
/// The list of app IDs represented in this pubisher profile. Empty if this is a parent profile. Deprecated in favor of publisher_app.
#[serde(rename="publisherAppIds")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub publisher_app_ids: Option<Vec<i64>>,
/// The list of apps represented in this pubisher profile. Empty if this is a parent profile.
#[serde(rename="publisherApps")]
pub publisher_apps: Option<Vec<MobileApplication>>,
/// The list of domains represented in this publisher profile. Empty if this is a parent profile.
#[serde(rename="publisherDomains")]
pub publisher_domains: Option<Vec<String>>,
/// Unique Id for publisher profile.
#[serde(rename="publisherProfileId")]
pub publisher_profile_id: Option<String>,
/// Publisher provided forecasting information.
#[serde(rename="publisherProvidedForecast")]
pub publisher_provided_forecast: Option<PublisherProvidedForecast>,
/// Link to publisher rate card
#[serde(rename="rateCardInfoLink")]
pub rate_card_info_link: Option<String>,
/// Link for a sample content page.
#[serde(rename="samplePageLink")]
pub sample_page_link: Option<String>,
/// Seller of the publisher profile.
pub seller: Option<Seller>,
/// State of the publisher profile.
pub state: Option<String>,
/// Publisher provided key metrics and rankings.
#[serde(rename="topHeadlines")]
pub top_headlines: Option<Vec<String>>,
}
impl client::Part for PublisherProfileApiProto {}
/// This message carries publisher provided forecasting information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PublisherProvidedForecast {
/// Publisher provided dimensions. E.g. geo, sizes etc...
pub dimensions: Option<Vec<Dimension>>,
/// Publisher provided weekly impressions.
#[serde(rename="weeklyImpressions")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub weekly_impressions: Option<i64>,
/// Publisher provided weekly uniques.
#[serde(rename="weeklyUniques")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub weekly_uniques: Option<i64>,
}
impl client::Part for PublisherProvidedForecast {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Seller {
/// The unique id for the seller. The seller fills in this field. The seller account id is then available to buyer in the product.
#[serde(rename="accountId")]
pub account_id: Option<String>,
/// Optional sub-account id for the seller.
#[serde(rename="subAccountId")]
pub sub_account_id: Option<String>,
}
impl client::Part for Seller {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct SharedTargeting {
/// The list of values to exclude from targeting. Each value is AND'd together.
pub exclusions: Option<Vec<TargetingValue>>,
/// The list of value to include as part of the targeting. Each value is OR'd together.
pub inclusions: Option<Vec<TargetingValue>>,
/// The key representing the shared targeting criterion.
pub key: Option<String>,
}
impl client::Part for SharedTargeting {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValue {
/// The creative size value to exclude/include.
#[serde(rename="creativeSizeValue")]
pub creative_size_value: Option<TargetingValueCreativeSize>,
/// The daypart targeting to include / exclude. Filled in when the key is GOOG_DAYPART_TARGETING.
#[serde(rename="dayPartTargetingValue")]
pub day_part_targeting_value: Option<TargetingValueDayPartTargeting>,
/// no description provided
#[serde(rename="demogAgeCriteriaValue")]
pub demog_age_criteria_value: Option<TargetingValueDemogAgeCriteria>,
/// no description provided
#[serde(rename="demogGenderCriteriaValue")]
pub demog_gender_criteria_value: Option<TargetingValueDemogGenderCriteria>,
/// The long value to exclude/include.
#[serde(rename="longValue")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub long_value: Option<i64>,
/// no description provided
#[serde(rename="requestPlatformTargetingValue")]
pub request_platform_targeting_value: Option<TargetingValueRequestPlatformTargeting>,
/// The string value to exclude/include.
#[serde(rename="stringValue")]
pub string_value: Option<String>,
}
impl client::Part for TargetingValue {}
/// Next Id: 7
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueCreativeSize {
/// The formats allowed by the publisher.
#[serde(rename="allowedFormats")]
pub allowed_formats: Option<Vec<String>>,
/// For video size type, the list of companion sizes.
#[serde(rename="companionSizes")]
pub companion_sizes: Option<Vec<TargetingValueSize>>,
/// The Creative size type.
#[serde(rename="creativeSizeType")]
pub creative_size_type: Option<String>,
/// The native template for native ad.
#[serde(rename="nativeTemplate")]
pub native_template: Option<String>,
/// For regular or video creative size type, specifies the size of the creative.
pub size: Option<TargetingValueSize>,
/// The skippable ad type for video size.
#[serde(rename="skippableAdType")]
pub skippable_ad_type: Option<String>,
}
impl client::Part for TargetingValueCreativeSize {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueDayPartTargeting {
/// no description provided
#[serde(rename="dayParts")]
pub day_parts: Option<Vec<TargetingValueDayPartTargetingDayPart>>,
/// no description provided
#[serde(rename="timeZoneType")]
pub time_zone_type: Option<String>,
}
impl client::Part for TargetingValueDayPartTargeting {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueDayPartTargetingDayPart {
/// no description provided
#[serde(rename="dayOfWeek")]
pub day_of_week: Option<String>,
/// no description provided
#[serde(rename="endHour")]
pub end_hour: Option<i32>,
/// no description provided
#[serde(rename="endMinute")]
pub end_minute: Option<i32>,
/// no description provided
#[serde(rename="startHour")]
pub start_hour: Option<i32>,
/// no description provided
#[serde(rename="startMinute")]
pub start_minute: Option<i32>,
}
impl client::Part for TargetingValueDayPartTargetingDayPart {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueDemogAgeCriteria {
/// no description provided
#[serde(rename="demogAgeCriteriaIds")]
pub demog_age_criteria_ids: Option<Vec<String>>,
}
impl client::Part for TargetingValueDemogAgeCriteria {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueDemogGenderCriteria {
/// no description provided
#[serde(rename="demogGenderCriteriaIds")]
pub demog_gender_criteria_ids: Option<Vec<String>>,
}
impl client::Part for TargetingValueDemogGenderCriteria {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueRequestPlatformTargeting {
/// no description provided
#[serde(rename="requestPlatforms")]
pub request_platforms: Option<Vec<String>>,
}
impl client::Part for TargetingValueRequestPlatformTargeting {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct TargetingValueSize {
/// The height of the creative.
pub height: Option<i32>,
/// The width of the creative.
pub width: Option<i32>,
}
impl client::Part for TargetingValueSize {}
/// There is no detailed description.
///
/// # 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*).
///
/// * [updateproposal marketplaceprivateauction](MarketplaceprivateauctionUpdateproposalCall) (request)
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UpdatePrivateAuctionProposalRequest {
/// The externalDealId of the deal to be updated.
#[serde(rename="externalDealId")]
pub external_deal_id: Option<String>,
/// Optional note to be added.
pub note: Option<MarketplaceNote>,
/// The current revision number of the proposal to be updated.
#[serde(rename="proposalRevisionNumber")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub proposal_revision_number: Option<i64>,
/// The proposed action on the private auction proposal.
#[serde(rename="updateAction")]
pub update_action: Option<String>,
}
impl client::RequestValue for UpdatePrivateAuctionProposalRequest {}
/// Your bidder locations that have distinct URLs.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AccountBidderLocation {
/// The protocol that the bidder endpoint is using. OpenRTB protocols with prefix PROTOCOL_OPENRTB_PROTOBUF use proto buffer, otherwise use JSON. Allowed values:
/// - PROTOCOL_ADX
/// - PROTOCOL_OPENRTB_2_2
/// - PROTOCOL_OPENRTB_2_3
/// - PROTOCOL_OPENRTB_2_4
/// - PROTOCOL_OPENRTB_2_5
/// - PROTOCOL_OPENRTB_PROTOBUF_2_3
/// - PROTOCOL_OPENRTB_PROTOBUF_2_4
/// - PROTOCOL_OPENRTB_PROTOBUF_2_5
#[serde(rename="bidProtocol")]
pub bid_protocol: Option<String>,
/// The maximum queries per second the Ad Exchange will send.
#[serde(rename="maximumQps")]
pub maximum_qps: Option<i32>,
/// The geographical region the Ad Exchange should send requests from. Only used by some quota systems, but always setting the value is recommended. Allowed values:
/// - ASIA
/// - EUROPE
/// - US_EAST
/// - US_WEST
pub region: Option<String>,
/// The URL to which the Ad Exchange will send bid requests.
pub url: Option<String>,
}
impl client::NestedType for AccountBidderLocation {}
impl client::Part for AccountBidderLocation {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeAdTechnologyProviders {
/// The detected ad technology provider IDs for this creative. See https://storage.googleapis.com/adx-rtb-dictionaries/providers.csv for mapping of provider ID to provided name, a privacy policy URL, and a list of domains which can be attributed to the provider. If this creative contains provider IDs that are outside of those listed in the `BidRequest.adslot.consented_providers_settings.consented_providers` field on the Authorized Buyers Real-Time Bidding protocol or the `BidRequest.user.ext.consented_providers_settings.consented_providers` field on the OpenRTB protocol, a bid submitted for a European Economic Area (EEA) user with this creative is not compliant with the GDPR policies as mentioned in the "Third-party Ad Technology Vendors" section of Authorized Buyers Program Guidelines.
#[serde(rename="detectedProviderIds")]
#[serde_as(as = "Option<Vec<::client::serde_with::DisplayFromStr>>")]
pub detected_provider_ids: Option<Vec<i64>>,
/// Whether the creative contains an unidentified ad technology provider. If true, a bid submitted for a European Economic Area (EEA) user with this creative is not compliant with the GDPR policies as mentioned in the "Third-party Ad Technology Vendors" section of Authorized Buyers Program Guidelines.
#[serde(rename="hasUnidentifiedProvider")]
pub has_unidentified_provider: Option<bool>,
}
impl client::NestedType for CreativeAdTechnologyProviders {}
impl client::Part for CreativeAdTechnologyProviders {}
/// Shows any corrections that were applied to this creative. Read-only. This field should not be set in requests.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeCorrections {
/// All known serving contexts containing serving status information.
pub contexts: Option<Vec<CreativeCorrectionsContexts>>,
/// Additional details about the correction.
pub details: Option<Vec<String>>,
/// The type of correction that was applied to the creative.
pub reason: Option<String>,
}
impl client::NestedType for CreativeCorrections {}
impl client::Part for CreativeCorrections {}
/// All known serving contexts containing serving status information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeCorrectionsContexts {
/// Only set when contextType=AUCTION_TYPE. Represents the auction types this correction applies to.
#[serde(rename="auctionType")]
pub auction_type: Option<Vec<String>>,
/// The type of context (e.g., location, platform, auction type, SSL-ness).
#[serde(rename="contextType")]
pub context_type: Option<String>,
/// Only set when contextType=LOCATION. Represents the geo criterias this correction applies to.
#[serde(rename="geoCriteriaId")]
pub geo_criteria_id: Option<Vec<i32>>,
/// Only set when contextType=PLATFORM. Represents the platforms this correction applies to.
pub platform: Option<Vec<String>>,
}
impl client::NestedType for CreativeCorrectionsContexts {}
impl client::Part for CreativeCorrectionsContexts {}
/// The filtering reasons for the creative. Read-only. This field should not be set in requests.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeFilteringReasons {
/// The date in ISO 8601 format for the data. The data is collected from 00:00:00 to 23:59:59 in PST.
pub date: Option<String>,
/// The filtering reasons.
pub reasons: Option<Vec<CreativeFilteringReasonsReasons>>,
}
impl client::NestedType for CreativeFilteringReasons {}
impl client::Part for CreativeFilteringReasons {}
/// The filtering reasons.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeFilteringReasonsReasons {
/// The number of times the creative was filtered for the status. The count is aggregated across all publishers on the exchange.
#[serde(rename="filteringCount")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub filtering_count: Option<i64>,
/// The filtering status code as defined in creative-status-codes.txt.
#[serde(rename="filteringStatus")]
pub filtering_status: Option<i32>,
}
impl client::NestedType for CreativeFilteringReasonsReasons {}
impl client::Part for CreativeFilteringReasonsReasons {}
/// If nativeAd is set, HTMLSnippet, videoVastXML, and the videoURL outside of nativeAd should not be set. (The videoURL inside nativeAd can be set.)
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeNativeAd {
/// no description provided
pub advertiser: Option<String>,
/// The app icon, for app download ads.
#[serde(rename="appIcon")]
pub app_icon: Option<CreativeNativeAdAppIcon>,
/// A long description of the ad.
pub body: Option<String>,
/// A label for the button that the user is supposed to click.
#[serde(rename="callToAction")]
pub call_to_action: Option<String>,
/// The URL that the browser/SDK will load when the user clicks the ad.
#[serde(rename="clickLinkUrl")]
pub click_link_url: Option<String>,
/// The URL to use for click tracking.
#[serde(rename="clickTrackingUrl")]
pub click_tracking_url: Option<String>,
/// A short title for the ad.
pub headline: Option<String>,
/// A large image.
pub image: Option<CreativeNativeAdImage>,
/// The URLs are called when the impression is rendered.
#[serde(rename="impressionTrackingUrl")]
pub impression_tracking_url: Option<Vec<String>>,
/// A smaller image, for the advertiser logo.
pub logo: Option<CreativeNativeAdLogo>,
/// The price of the promoted app including the currency info.
pub price: Option<String>,
/// The app rating in the app store. Must be in the range [0-5].
#[serde(rename="starRating")]
pub star_rating: Option<f64>,
/// The URL of the XML VAST for a native ad. Note this is a separate field from resource.video_url.
#[serde(rename="videoURL")]
pub video_url: Option<String>,
}
impl client::NestedType for CreativeNativeAd {}
impl client::Part for CreativeNativeAd {}
/// The app icon, for app download ads.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeNativeAdAppIcon {
/// no description provided
pub height: Option<i32>,
/// no description provided
pub url: Option<String>,
/// no description provided
pub width: Option<i32>,
}
impl client::NestedType for CreativeNativeAdAppIcon {}
impl client::Part for CreativeNativeAdAppIcon {}
/// A large image.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeNativeAdImage {
/// no description provided
pub height: Option<i32>,
/// no description provided
pub url: Option<String>,
/// no description provided
pub width: Option<i32>,
}
impl client::NestedType for CreativeNativeAdImage {}
impl client::Part for CreativeNativeAdImage {}
/// A smaller image, for the advertiser logo.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeNativeAdLogo {
/// no description provided
pub height: Option<i32>,
/// no description provided
pub url: Option<String>,
/// no description provided
pub width: Option<i32>,
}
impl client::NestedType for CreativeNativeAdLogo {}
impl client::Part for CreativeNativeAdLogo {}
/// The granular status of this ad in specific contexts. A context here relates to where something ultimately serves (for example, a physical location, a platform, an HTTPS vs HTTP request, or the type of auction). Read-only. This field should not be set in requests. See the examples in the Creatives guide for more details.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeServingRestrictions {
/// All known contexts/restrictions.
pub contexts: Option<Vec<CreativeServingRestrictionsContexts>>,
/// The reasons for disapproval within this restriction, if any. Note that not all disapproval reasons may be categorized, so it is possible for the creative to have a status of DISAPPROVED or CONDITIONALLY_APPROVED with an empty list for disapproval_reasons. In this case, please reach out to your TAM to help debug the issue.
#[serde(rename="disapprovalReasons")]
pub disapproval_reasons: Option<Vec<CreativeServingRestrictionsDisapprovalReasons>>,
/// Why the creative is ineligible to serve in this context (e.g., it has been explicitly disapproved or is pending review).
pub reason: Option<String>,
}
impl client::NestedType for CreativeServingRestrictions {}
impl client::Part for CreativeServingRestrictions {}
/// All known contexts/restrictions.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeServingRestrictionsContexts {
/// Only set when contextType=AUCTION_TYPE. Represents the auction types this restriction applies to.
#[serde(rename="auctionType")]
pub auction_type: Option<Vec<String>>,
/// The type of context (e.g., location, platform, auction type, SSL-ness).
#[serde(rename="contextType")]
pub context_type: Option<String>,
/// Only set when contextType=LOCATION. Represents the geo criterias this restriction applies to. Impressions are considered to match a context if either the user location or publisher location matches a given geoCriteriaId.
#[serde(rename="geoCriteriaId")]
pub geo_criteria_id: Option<Vec<i32>>,
/// Only set when contextType=PLATFORM. Represents the platforms this restriction applies to.
pub platform: Option<Vec<String>>,
}
impl client::NestedType for CreativeServingRestrictionsContexts {}
impl client::Part for CreativeServingRestrictionsContexts {}
/// The reasons for disapproval within this restriction, if any. Note that not all disapproval reasons may be categorized, so it is possible for the creative to have a status of DISAPPROVED or CONDITIONALLY_APPROVED with an empty list for disapproval_reasons. In this case, please reach out to your TAM to help debug the issue.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeServingRestrictionsDisapprovalReasons {
/// Additional details about the reason for disapproval.
pub details: Option<Vec<String>>,
/// The categorized reason for disapproval.
pub reason: Option<String>,
}
impl client::NestedType for CreativeServingRestrictionsDisapprovalReasons {}
impl client::Part for CreativeServingRestrictionsDisapprovalReasons {}
/// A list of external deal ids and ARC approval status.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CreativeDealIdsDealStatuses {
/// ARC approval status.
#[serde(rename="arcStatus")]
pub arc_status: Option<String>,
/// External deal ID.
#[serde(rename="dealId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub deal_id: Option<i64>,
/// Publisher ID.
#[serde(rename="webPropertyId")]
pub web_property_id: Option<i32>,
}
impl client::NestedType for CreativeDealIdsDealStatuses {}
impl client::Part for CreativeDealIdsDealStatuses {}
/// Requests which allow one of these (width, height) pairs will match. All pairs must be supported ad dimensions.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfigDimensions {
/// Height in pixels.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub height: Option<i64>,
/// Width in pixels.
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub width: Option<i64>,
}
impl client::NestedType for PretargetingConfigDimensions {}
impl client::Part for PretargetingConfigDimensions {}
/// Requests containing any of these placements will not match.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfigExcludedPlacements {
/// The value of the placement. Interpretation depends on the placement type, e.g. URL for a site placement, channel name for a channel placement, app id for a mobile app placement.
pub token: Option<String>,
/// The type of the placement.
#[serde(rename="type")]
pub type_: Option<String>,
}
impl client::NestedType for PretargetingConfigExcludedPlacements {}
impl client::Part for PretargetingConfigExcludedPlacements {}
/// Requests containing any of these placements will match.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfigPlacements {
/// The value of the placement. Interpretation depends on the placement type, e.g. URL for a site placement, channel name for a channel placement, app id for a mobile app placement.
pub token: Option<String>,
/// The type of the placement.
#[serde(rename="type")]
pub type_: Option<String>,
}
impl client::NestedType for PretargetingConfigPlacements {}
impl client::Part for PretargetingConfigPlacements {}
/// Video requests satisfying any of these player size constraints will match.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PretargetingConfigVideoPlayerSizes {
/// The type of aspect ratio. Leave this field blank to match all aspect ratios.
#[serde(rename="aspectRatio")]
pub aspect_ratio: Option<String>,
/// The minimum player height in pixels. Leave this field blank to match any player height.
#[serde(rename="minHeight")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub min_height: Option<i64>,
/// The minimum player width in pixels. Leave this field blank to match any player width.
#[serde(rename="minWidth")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub min_width: Option<i64>,
}
impl client::NestedType for PretargetingConfigVideoPlayerSizes {}
impl client::Part for PretargetingConfigVideoPlayerSizes {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *account* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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 AdExchangeBuyer<S>,
}
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
///
/// * `id` - The account id
pub fn get(&self, id: i32) -> AccountGetCall<'a, S> {
AccountGetCall {
hub: self.hub,
_id: id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves the authenticated user's list of accounts.
pub fn list(&self) -> AccountListCall<'a, S> {
AccountListCall {
hub: self.hub,
_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.
/// * `id` - The account id
pub fn patch(&self, request: Account, id: i32) -> AccountPatchCall<'a, S> {
AccountPatchCall {
hub: self.hub,
_request: request,
_id: id,
_confirm_unsafe_account_change: 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.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `id` - The account id
pub fn update(&self, request: Account, id: i32) -> AccountUpdateCall<'a, S> {
AccountUpdateCall {
hub: self.hub,
_request: request,
_id: id,
_confirm_unsafe_account_change: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *billingInfo* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.billing_info();
/// # }
/// ```
pub struct BillingInfoMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for BillingInfoMethods<'a, S> {}
impl<'a, S> BillingInfoMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Returns the billing information for one account specified by account ID.
///
/// # Arguments
///
/// * `accountId` - The account id.
pub fn get(&self, account_id: i32) -> BillingInfoGetCall<'a, S> {
BillingInfoGetCall {
hub: self.hub,
_account_id: account_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves a list of billing information for all accounts of the authenticated user.
pub fn list(&self) -> BillingInfoListCall<'a, S> {
BillingInfoListCall {
hub: self.hub,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *budget* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.budget();
/// # }
/// ```
pub struct BudgetMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for BudgetMethods<'a, S> {}
impl<'a, S> BudgetMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Returns the budget information for the adgroup specified by the accountId and billingId.
///
/// # Arguments
///
/// * `accountId` - The account id to get the budget information for.
/// * `billingId` - The billing id to get the budget information for.
pub fn get(&self, account_id: i64, billing_id: i64) -> BudgetGetCall<'a, S> {
BudgetGetCall {
hub: self.hub,
_account_id: account_id,
_billing_id: billing_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates the budget amount for the budget of the adgroup specified by the accountId and billingId, with the budget amount in the request. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `accountId` - The account id associated with the budget being updated.
/// * `billingId` - The billing id associated with the budget being updated.
pub fn patch(&self, request: Budget, account_id: i64, billing_id: i64) -> BudgetPatchCall<'a, S> {
BudgetPatchCall {
hub: self.hub,
_request: request,
_account_id: account_id,
_billing_id: billing_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates the budget amount for the budget of the adgroup specified by the accountId and billingId, with the budget amount in the request.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `accountId` - The account id associated with the budget being updated.
/// * `billingId` - The billing id associated with the budget being updated.
pub fn update(&self, request: Budget, account_id: i64, billing_id: i64) -> BudgetUpdateCall<'a, S> {
BudgetUpdateCall {
hub: self.hub,
_request: request,
_account_id: account_id,
_billing_id: billing_id,
_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 [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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 `add_deal(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_deals(...)` and `remove_deal(...)`
/// // to build up your call.
/// let rb = hub.creatives();
/// # }
/// ```
pub struct CreativeMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
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:
///
/// Add a deal id association for the creative.
///
/// # Arguments
///
/// * `accountId` - The id for the account that will serve this creative.
/// * `buyerCreativeId` - The buyer-specific id for this creative.
/// * `dealId` - The id of the deal id to associate with this creative.
pub fn add_deal(&self, account_id: i32, buyer_creative_id: &str, deal_id: i64) -> CreativeAddDealCall<'a, S> {
CreativeAddDealCall {
hub: self.hub,
_account_id: account_id,
_buyer_creative_id: buyer_creative_id.to_string(),
_deal_id: deal_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets the status for a single creative. A creative will be available 30-40 minutes after submission.
///
/// # Arguments
///
/// * `accountId` - The id for the account that will serve this creative.
/// * `buyerCreativeId` - The buyer-specific id for this creative.
pub fn get(&self, account_id: i32, buyer_creative_id: &str) -> CreativeGetCall<'a, S> {
CreativeGetCall {
hub: self.hub,
_account_id: account_id,
_buyer_creative_id: buyer_creative_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Submit a new creative.
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn insert(&self, request: Creative) -> CreativeInsertCall<'a, S> {
CreativeInsertCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves a list of the authenticated user's active creatives. A creative will be available 30-40 minutes after submission.
pub fn list(&self) -> CreativeListCall<'a, S> {
CreativeListCall {
hub: self.hub,
_page_token: Default::default(),
_open_auction_status_filter: Default::default(),
_max_results: Default::default(),
_deals_status_filter: Default::default(),
_buyer_creative_id: Default::default(),
_account_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Lists the external deal ids associated with the creative.
///
/// # Arguments
///
/// * `accountId` - The id for the account that will serve this creative.
/// * `buyerCreativeId` - The buyer-specific id for this creative.
pub fn list_deals(&self, account_id: i32, buyer_creative_id: &str) -> CreativeListDealCall<'a, S> {
CreativeListDealCall {
hub: self.hub,
_account_id: account_id,
_buyer_creative_id: buyer_creative_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Remove a deal id associated with the creative.
///
/// # Arguments
///
/// * `accountId` - The id for the account that will serve this creative.
/// * `buyerCreativeId` - The buyer-specific id for this creative.
/// * `dealId` - The id of the deal id to disassociate with this creative.
pub fn remove_deal(&self, account_id: i32, buyer_creative_id: &str, deal_id: i64) -> CreativeRemoveDealCall<'a, S> {
CreativeRemoveDealCall {
hub: self.hub,
_account_id: account_id,
_buyer_creative_id: buyer_creative_id.to_string(),
_deal_id: deal_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *marketplacedeal* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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(...)`, `list(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.marketplacedeals();
/// # }
/// ```
pub struct MarketplacedealMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for MarketplacedealMethods<'a, S> {}
impl<'a, S> MarketplacedealMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Delete the specified deals from the proposal
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - The proposalId to delete deals from.
pub fn delete(&self, request: DeleteOrderDealsRequest, proposal_id: &str) -> MarketplacedealDeleteCall<'a, S> {
MarketplacedealDeleteCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add new deals for the specified proposal
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - proposalId for which deals need to be added.
pub fn insert(&self, request: AddOrderDealsRequest, proposal_id: &str) -> MarketplacedealInsertCall<'a, S> {
MarketplacedealInsertCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all the deals for a given proposal
///
/// # Arguments
///
/// * `proposalId` - The proposalId to get deals for. To search across all proposals specify order_id = '-' as part of the URL.
pub fn list(&self, proposal_id: &str) -> MarketplacedealListCall<'a, S> {
MarketplacedealListCall {
hub: self.hub,
_proposal_id: proposal_id.to_string(),
_pql_query: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Replaces all the deals in the proposal with the passed in deals
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - The proposalId to edit deals on.
pub fn update(&self, request: EditAllOrderDealsRequest, proposal_id: &str) -> MarketplacedealUpdateCall<'a, S> {
MarketplacedealUpdateCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *marketplacenote* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.marketplacenotes();
/// # }
/// ```
pub struct MarketplacenoteMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for MarketplacenoteMethods<'a, S> {}
impl<'a, S> MarketplacenoteMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Add notes to the proposal
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - The proposalId to add notes for.
pub fn insert(&self, request: AddOrderNotesRequest, proposal_id: &str) -> MarketplacenoteInsertCall<'a, S> {
MarketplacenoteInsertCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get all the notes associated with a proposal
///
/// # Arguments
///
/// * `proposalId` - The proposalId to get notes for. To search across all proposals specify order_id = '-' as part of the URL.
pub fn list(&self, proposal_id: &str) -> MarketplacenoteListCall<'a, S> {
MarketplacenoteListCall {
hub: self.hub,
_proposal_id: proposal_id.to_string(),
_pql_query: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *marketplaceprivateauction* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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 `updateproposal(...)`
/// // to build up your call.
/// let rb = hub.marketplaceprivateauction();
/// # }
/// ```
pub struct MarketplaceprivateauctionMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for MarketplaceprivateauctionMethods<'a, S> {}
impl<'a, S> MarketplaceprivateauctionMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Update a given private auction proposal
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `privateAuctionId` - The private auction id to be updated.
pub fn updateproposal(&self, request: UpdatePrivateAuctionProposalRequest, private_auction_id: &str) -> MarketplaceprivateauctionUpdateproposalCall<'a, S> {
MarketplaceprivateauctionUpdateproposalCall {
hub: self.hub,
_request: request,
_private_auction_id: private_auction_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *performanceReport* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.performance_report();
/// # }
/// ```
pub struct PerformanceReportMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for PerformanceReportMethods<'a, S> {}
impl<'a, S> PerformanceReportMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Retrieves the authenticated user's list of performance metrics.
///
/// # Arguments
///
/// * `accountId` - The account id to get the reports.
/// * `endDateTime` - The end time of the report in ISO 8601 timestamp format using UTC.
/// * `startDateTime` - The start time of the report in ISO 8601 timestamp format using UTC.
pub fn list(&self, account_id: i64, end_date_time: &str, start_date_time: &str) -> PerformanceReportListCall<'a, S> {
PerformanceReportListCall {
hub: self.hub,
_account_id: account_id,
_end_date_time: end_date_time.to_string(),
_start_date_time: start_date_time.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 *pretargetingConfig* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.pretargeting_config();
/// # }
/// ```
pub struct PretargetingConfigMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for PretargetingConfigMethods<'a, S> {}
impl<'a, S> PretargetingConfigMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Deletes an existing pretargeting config.
///
/// # Arguments
///
/// * `accountId` - The account id to delete the pretargeting config for.
/// * `configId` - The specific id of the configuration to delete.
pub fn delete(&self, account_id: i64, config_id: i64) -> PretargetingConfigDeleteCall<'a, S> {
PretargetingConfigDeleteCall {
hub: self.hub,
_account_id: account_id,
_config_id: config_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets a specific pretargeting configuration
///
/// # Arguments
///
/// * `accountId` - The account id to get the pretargeting config for.
/// * `configId` - The specific id of the configuration to retrieve.
pub fn get(&self, account_id: i64, config_id: i64) -> PretargetingConfigGetCall<'a, S> {
PretargetingConfigGetCall {
hub: self.hub,
_account_id: account_id,
_config_id: config_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Inserts a new pretargeting configuration.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `accountId` - The account id to insert the pretargeting config for.
pub fn insert(&self, request: PretargetingConfig, account_id: i64) -> PretargetingConfigInsertCall<'a, S> {
PretargetingConfigInsertCall {
hub: self.hub,
_request: request,
_account_id: account_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves a list of the authenticated user's pretargeting configurations.
///
/// # Arguments
///
/// * `accountId` - The account id to get the pretargeting configs for.
pub fn list(&self, account_id: i64) -> PretargetingConfigListCall<'a, S> {
PretargetingConfigListCall {
hub: self.hub,
_account_id: account_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates an existing pretargeting config. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `accountId` - The account id to update the pretargeting config for.
/// * `configId` - The specific id of the configuration to update.
pub fn patch(&self, request: PretargetingConfig, account_id: i64, config_id: i64) -> PretargetingConfigPatchCall<'a, S> {
PretargetingConfigPatchCall {
hub: self.hub,
_request: request,
_account_id: account_id,
_config_id: config_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Updates an existing pretargeting config.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `accountId` - The account id to update the pretargeting config for.
/// * `configId` - The specific id of the configuration to update.
pub fn update(&self, request: PretargetingConfig, account_id: i64, config_id: i64) -> PretargetingConfigUpdateCall<'a, S> {
PretargetingConfigUpdateCall {
hub: self.hub,
_request: request,
_account_id: account_id,
_config_id: config_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *product* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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 `search(...)`
/// // to build up your call.
/// let rb = hub.products();
/// # }
/// ```
pub struct ProductMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for ProductMethods<'a, S> {}
impl<'a, S> ProductMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Gets the requested product by id.
///
/// # Arguments
///
/// * `productId` - The id for the product to get the head revision for.
pub fn get(&self, product_id: &str) -> ProductGetCall<'a, S> {
ProductGetCall {
hub: self.hub,
_product_id: product_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets the requested product.
pub fn search(&self) -> ProductSearchCall<'a, S> {
ProductSearchCall {
hub: self.hub,
_pql_query: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *proposal* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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(...)`, `patch(...)`, `search(...)`, `setupcomplete(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.proposals();
/// # }
/// ```
pub struct ProposalMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for ProposalMethods<'a, S> {}
impl<'a, S> ProposalMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Get a proposal given its id
///
/// # Arguments
///
/// * `proposalId` - Id of the proposal to retrieve.
pub fn get(&self, proposal_id: &str) -> ProposalGetCall<'a, S> {
ProposalGetCall {
hub: self.hub,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Create the given list of proposals
///
/// # Arguments
///
/// * `request` - No description provided.
pub fn insert(&self, request: CreateOrdersRequest) -> ProposalInsertCall<'a, S> {
ProposalInsertCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the given proposal. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - The proposal id to update.
/// * `revisionNumber` - The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision.
/// * `updateAction` - The proposed action to take on the proposal. This field is required and it must be set when updating a proposal.
pub fn patch(&self, request: Proposal, proposal_id: &str, revision_number: i64, update_action: &str) -> ProposalPatchCall<'a, S> {
ProposalPatchCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_revision_number: revision_number,
_update_action: update_action.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Search for proposals using pql query
pub fn search(&self) -> ProposalSearchCall<'a, S> {
ProposalSearchCall {
hub: self.hub,
_pql_query: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the given proposal to indicate that setup has been completed.
///
/// # Arguments
///
/// * `proposalId` - The proposal id for which the setup is complete
pub fn setupcomplete(&self, proposal_id: &str) -> ProposalSetupcompleteCall<'a, S> {
ProposalSetupcompleteCall {
hub: self.hub,
_proposal_id: proposal_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the given proposal
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `proposalId` - The proposal id to update.
/// * `revisionNumber` - The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision.
/// * `updateAction` - The proposed action to take on the proposal. This field is required and it must be set when updating a proposal.
pub fn update(&self, request: Proposal, proposal_id: &str, revision_number: i64, update_action: &str) -> ProposalUpdateCall<'a, S> {
ProposalUpdateCall {
hub: self.hub,
_request: request,
_proposal_id: proposal_id.to_string(),
_revision_number: revision_number,
_update_action: update_action.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *pubprofile* resources.
/// It is not used directly, but through the [`AdExchangeBuyer`] hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate hyper_rustls;
/// extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
///
/// # async fn dox() {
/// use std::default::Default;
/// use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// let secret: oauth2::ApplicationSecret = Default::default();
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
/// secret,
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// ).build().await.unwrap();
/// let mut hub = AdExchangeBuyer::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.pubprofiles();
/// # }
/// ```
pub struct PubprofileMethods<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
}
impl<'a, S> client::MethodsBuilder for PubprofileMethods<'a, S> {}
impl<'a, S> PubprofileMethods<'a, S> {
/// Create a builder to help you perform the following task:
///
/// Gets the requested publisher profile(s) by publisher accountId.
///
/// # Arguments
///
/// * `accountId` - The accountId of the publisher to get profiles for.
pub fn list(&self, account_id: i32) -> PubprofileListCall<'a, S> {
PubprofileListCall {
hub: self.hub,
_account_id: account_id,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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(-17)
/// .doit().await;
/// # }
/// ```
pub struct AccountGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_id: i32,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for AccountGetCall<'a, S> {}
impl<'a, S> AccountGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Account)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.accounts.get",
http_method: hyper::Method::GET });
for &field in ["alt", "id"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("id", self._id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "accounts/{id}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{id}", "id")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["id"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 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: i32) -> AccountGetCall<'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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> AccountGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> AccountGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> AccountGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Retrieves the authenticated user's list of accounts.
///
/// 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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()
/// .doit().await;
/// # }
/// ```
pub struct AccountListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for AccountListCall<'a, S> {}
impl<'a, S> AccountListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, AccountsList)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.accounts.list",
http_method: hyper::Method::GET });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "accounts";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> AccountListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> AccountListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> AccountListCall<'a, S> {
self._scopes.clear();
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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Account;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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, -55)
/// .confirm_unsafe_account_change(false)
/// .doit().await;
/// # }
/// ```
pub struct AccountPatchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Account,
_id: i32,
_confirm_unsafe_account_change: Option<bool>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for AccountPatchCall<'a, S> {}
impl<'a, S> AccountPatchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Account)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.accounts.patch",
http_method: hyper::Method::PATCH });
for &field in ["alt", "id", "confirmUnsafeAccountChange"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("id", self._id.to_string());
if let Some(value) = self._confirm_unsafe_account_change.as_ref() {
params.push("confirmUnsafeAccountChange", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "accounts/{id}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{id}", "id")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["id"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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
}
/// The 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: i32) -> AccountPatchCall<'a, S> {
self._id = new_value;
self
}
/// Confirmation for erasing bidder and cookie matching urls.
///
/// Sets the *confirm unsafe account change* query property to the given value.
pub fn confirm_unsafe_account_change(mut self, new_value: bool) -> AccountPatchCall<'a, S> {
self._confirm_unsafe_account_change = 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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> AccountPatchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> AccountPatchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountPatchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> AccountPatchCall<'a, S> {
self._scopes.clear();
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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Account;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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, -47)
/// .confirm_unsafe_account_change(true)
/// .doit().await;
/// # }
/// ```
pub struct AccountUpdateCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Account,
_id: i32,
_confirm_unsafe_account_change: Option<bool>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for AccountUpdateCall<'a, S> {}
impl<'a, S> AccountUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Account)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.accounts.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "id", "confirmUnsafeAccountChange"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("id", self._id.to_string());
if let Some(value) = self._confirm_unsafe_account_change.as_ref() {
params.push("confirmUnsafeAccountChange", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "accounts/{id}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{id}", "id")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["id"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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
}
/// The 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: i32) -> AccountUpdateCall<'a, S> {
self._id = new_value;
self
}
/// Confirmation for erasing bidder and cookie matching urls.
///
/// Sets the *confirm unsafe account change* query property to the given value.
pub fn confirm_unsafe_account_change(mut self, new_value: bool) -> AccountUpdateCall<'a, S> {
self._confirm_unsafe_account_change = 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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> AccountUpdateCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> AccountUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> AccountUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> AccountUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
/// Returns the billing information for one account specified by account ID.
///
/// A builder for the *get* method supported by a *billingInfo* resource.
/// It is not used directly, but through a [`BillingInfoMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.billing_info().get(-93)
/// .doit().await;
/// # }
/// ```
pub struct BillingInfoGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BillingInfoGetCall<'a, S> {}
impl<'a, S> BillingInfoGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, BillingInfo)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.billingInfo.get",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "billinginfo/{accountId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> BillingInfoGetCall<'a, S> {
self._account_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.
///
/// ````text
/// 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) -> BillingInfoGetCall<'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<T>(mut self, name: T, value: T) -> BillingInfoGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> BillingInfoGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingInfoGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> BillingInfoGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Retrieves a list of billing information for all accounts of the authenticated user.
///
/// A builder for the *list* method supported by a *billingInfo* resource.
/// It is not used directly, but through a [`BillingInfoMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.billing_info().list()
/// .doit().await;
/// # }
/// ```
pub struct BillingInfoListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BillingInfoListCall<'a, S> {}
impl<'a, S> BillingInfoListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, BillingInfoList)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.billingInfo.list",
http_method: hyper::Method::GET });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "billinginfo";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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.
///
/// ````text
/// 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) -> BillingInfoListCall<'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<T>(mut self, name: T, value: T) -> BillingInfoListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> BillingInfoListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> BillingInfoListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> BillingInfoListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Returns the budget information for the adgroup specified by the accountId and billingId.
///
/// A builder for the *get* method supported by a *budget* resource.
/// It is not used directly, but through a [`BudgetMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.budget().get(-37, -12)
/// .doit().await;
/// # }
/// ```
pub struct BudgetGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i64,
_billing_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BudgetGetCall<'a, S> {}
impl<'a, S> BudgetGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Budget)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.budget.get",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId", "billingId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("billingId", self._billing_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "billinginfo/{accountId}/{billingId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{billingId}", "billingId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["billingId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id to get the budget information for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> BudgetGetCall<'a, S> {
self._account_id = new_value;
self
}
/// The billing id to get the budget information for.
///
/// Sets the *billing id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn billing_id(mut self, new_value: i64) -> BudgetGetCall<'a, S> {
self._billing_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.
///
/// ````text
/// 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) -> BudgetGetCall<'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<T>(mut self, name: T, value: T) -> BudgetGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> BudgetGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> BudgetGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> BudgetGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Updates the budget amount for the budget of the adgroup specified by the accountId and billingId, with the budget amount in the request. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *budget* resource.
/// It is not used directly, but through a [`BudgetMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Budget;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = Budget::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.budget().patch(req, -16, -57)
/// .doit().await;
/// # }
/// ```
pub struct BudgetPatchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Budget,
_account_id: i64,
_billing_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BudgetPatchCall<'a, S> {}
impl<'a, S> BudgetPatchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Budget)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.budget.patch",
http_method: hyper::Method::PATCH });
for &field in ["alt", "accountId", "billingId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("billingId", self._billing_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "billinginfo/{accountId}/{billingId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{billingId}", "billingId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["billingId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: Budget) -> BudgetPatchCall<'a, S> {
self._request = new_value;
self
}
/// The account id associated with the budget being updated.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> BudgetPatchCall<'a, S> {
self._account_id = new_value;
self
}
/// The billing id associated with the budget being updated.
///
/// Sets the *billing id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn billing_id(mut self, new_value: i64) -> BudgetPatchCall<'a, S> {
self._billing_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.
///
/// ````text
/// 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) -> BudgetPatchCall<'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<T>(mut self, name: T, value: T) -> BudgetPatchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> BudgetPatchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> BudgetPatchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> BudgetPatchCall<'a, S> {
self._scopes.clear();
self
}
}
/// Updates the budget amount for the budget of the adgroup specified by the accountId and billingId, with the budget amount in the request.
///
/// A builder for the *update* method supported by a *budget* resource.
/// It is not used directly, but through a [`BudgetMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Budget;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = Budget::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.budget().update(req, -50, -50)
/// .doit().await;
/// # }
/// ```
pub struct BudgetUpdateCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Budget,
_account_id: i64,
_billing_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BudgetUpdateCall<'a, S> {}
impl<'a, S> BudgetUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Budget)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.budget.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "accountId", "billingId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("billingId", self._billing_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "billinginfo/{accountId}/{billingId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{billingId}", "billingId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["billingId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: Budget) -> BudgetUpdateCall<'a, S> {
self._request = new_value;
self
}
/// The account id associated with the budget being updated.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> BudgetUpdateCall<'a, S> {
self._account_id = new_value;
self
}
/// The billing id associated with the budget being updated.
///
/// Sets the *billing id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn billing_id(mut self, new_value: i64) -> BudgetUpdateCall<'a, S> {
self._billing_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.
///
/// ````text
/// 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) -> BudgetUpdateCall<'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<T>(mut self, name: T, value: T) -> BudgetUpdateCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> BudgetUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> BudgetUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> BudgetUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
/// Add a deal id association for the creative.
///
/// A builder for the *addDeal* 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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().add_deal(-7, "buyerCreativeId", -17)
/// .doit().await;
/// # }
/// ```
pub struct CreativeAddDealCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_buyer_creative_id: String,
_deal_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeAddDealCall<'a, S> {}
impl<'a, S> CreativeAddDealCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.addDeal",
http_method: hyper::Method::POST });
for &field in ["accountId", "buyerCreativeId", "dealId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("buyerCreativeId", self._buyer_creative_id);
params.push("dealId", self._deal_id.to_string());
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "creatives/{accountId}/{buyerCreativeId}/addDeal/{dealId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{buyerCreativeId}", "buyerCreativeId"), ("{dealId}", "dealId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["dealId", "buyerCreativeId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 id for the account that will serve this creative.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> CreativeAddDealCall<'a, S> {
self._account_id = new_value;
self
}
/// The buyer-specific id for this creative.
///
/// Sets the *buyer creative id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn buyer_creative_id(mut self, new_value: &str) -> CreativeAddDealCall<'a, S> {
self._buyer_creative_id = new_value.to_string();
self
}
/// The id of the deal id to associate with this creative.
///
/// Sets the *deal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn deal_id(mut self, new_value: i64) -> CreativeAddDealCall<'a, S> {
self._deal_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.
///
/// ````text
/// 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) -> CreativeAddDealCall<'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<T>(mut self, name: T, value: T) -> CreativeAddDealCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeAddDealCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeAddDealCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeAddDealCall<'a, S> {
self._scopes.clear();
self
}
}
/// Gets the status for a single creative. A creative will be available 30-40 minutes after submission.
///
/// 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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(-99, "buyerCreativeId")
/// .doit().await;
/// # }
/// ```
pub struct CreativeGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_buyer_creative_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeGetCall<'a, S> {}
impl<'a, S> CreativeGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Creative)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.get",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId", "buyerCreativeId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("buyerCreativeId", self._buyer_creative_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "creatives/{accountId}/{buyerCreativeId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{buyerCreativeId}", "buyerCreativeId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["buyerCreativeId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 id for the account that will serve this creative.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> CreativeGetCall<'a, S> {
self._account_id = new_value;
self
}
/// The buyer-specific id for this creative.
///
/// Sets the *buyer creative id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn buyer_creative_id(mut self, new_value: &str) -> CreativeGetCall<'a, S> {
self._buyer_creative_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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> CreativeGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Submit 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Creative;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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)
/// .doit().await;
/// # }
/// ```
pub struct CreativeInsertCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Creative,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeInsertCall<'a, S> {}
impl<'a, S> CreativeInsertCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Creative)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.insert",
http_method: hyper::Method::POST });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "creatives";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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
}
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> CreativeInsertCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeInsertCall<'a, S> {
self._scopes.clear();
self
}
}
/// Retrieves a list of the authenticated user's active creatives. A creative will be available 30-40 minutes after submission.
///
/// 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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()
/// .page_token("eos")
/// .open_auction_status_filter("labore")
/// .max_results(58)
/// .deals_status_filter("duo")
/// .add_buyer_creative_id("sed")
/// .add_account_id(-61)
/// .doit().await;
/// # }
/// ```
pub struct CreativeListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_page_token: Option<String>,
_open_auction_status_filter: Option<String>,
_max_results: Option<u32>,
_deals_status_filter: Option<String>,
_buyer_creative_id: Vec<String>,
_account_id: Vec<i32>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeListCall<'a, S> {}
impl<'a, S> CreativeListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, CreativesList)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.list",
http_method: hyper::Method::GET });
for &field in ["alt", "pageToken", "openAuctionStatusFilter", "maxResults", "dealsStatusFilter", "buyerCreativeId", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._open_auction_status_filter.as_ref() {
params.push("openAuctionStatusFilter", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
if let Some(value) = self._deals_status_filter.as_ref() {
params.push("dealsStatusFilter", value);
}
if self._buyer_creative_id.len() > 0 {
for f in self._buyer_creative_id.iter() {
params.push("buyerCreativeId", f);
}
}
if self._account_id.len() > 0 {
for f in self._account_id.iter() {
params.push("accountId", f.to_string());
}
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "creatives";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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)
}
}
}
}
/// A continuation token, used to page through ad clients. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response. Optional.
///
/// 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
}
/// When specified, only creatives having the given open auction status are returned.
///
/// Sets the *open auction status filter* query property to the given value.
pub fn open_auction_status_filter(mut self, new_value: &str) -> CreativeListCall<'a, S> {
self._open_auction_status_filter = Some(new_value.to_string());
self
}
/// Maximum number of entries returned on one result page. If not set, the default is 100. Optional.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> CreativeListCall<'a, S> {
self._max_results = Some(new_value);
self
}
/// When specified, only creatives having the given deals status are returned.
///
/// Sets the *deals status filter* query property to the given value.
pub fn deals_status_filter(mut self, new_value: &str) -> CreativeListCall<'a, S> {
self._deals_status_filter = Some(new_value.to_string());
self
}
/// When specified, only creatives for the given buyer creative ids are returned.
///
/// Append the given value to the *buyer creative id* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_buyer_creative_id(mut self, new_value: &str) -> CreativeListCall<'a, S> {
self._buyer_creative_id.push(new_value.to_string());
self
}
/// When specified, only creatives for the given account ids are returned.
///
/// Append the given value to the *account id* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
pub fn add_account_id(mut self, new_value: i32) -> CreativeListCall<'a, S> {
self._account_id.push(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.
///
/// ````text
/// 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<T>(mut self, name: T, value: T) -> CreativeListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Lists the external deal ids associated with the creative.
///
/// A builder for the *listDeals* 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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_deals(-15, "buyerCreativeId")
/// .doit().await;
/// # }
/// ```
pub struct CreativeListDealCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_buyer_creative_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeListDealCall<'a, S> {}
impl<'a, S> CreativeListDealCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, CreativeDealIds)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.listDeals",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId", "buyerCreativeId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("buyerCreativeId", self._buyer_creative_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "creatives/{accountId}/{buyerCreativeId}/listDeals";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{buyerCreativeId}", "buyerCreativeId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["buyerCreativeId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 id for the account that will serve this creative.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> CreativeListDealCall<'a, S> {
self._account_id = new_value;
self
}
/// The buyer-specific id for this creative.
///
/// Sets the *buyer creative id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn buyer_creative_id(mut self, new_value: &str) -> CreativeListDealCall<'a, S> {
self._buyer_creative_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.
///
/// ````text
/// 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) -> CreativeListDealCall<'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<T>(mut self, name: T, value: T) -> CreativeListDealCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeListDealCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeListDealCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeListDealCall<'a, S> {
self._scopes.clear();
self
}
}
/// Remove a deal id associated with the creative.
///
/// A builder for the *removeDeal* 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_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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().remove_deal(-24, "buyerCreativeId", -24)
/// .doit().await;
/// # }
/// ```
pub struct CreativeRemoveDealCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_buyer_creative_id: String,
_deal_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for CreativeRemoveDealCall<'a, S> {}
impl<'a, S> CreativeRemoveDealCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.creatives.removeDeal",
http_method: hyper::Method::POST });
for &field in ["accountId", "buyerCreativeId", "dealId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("buyerCreativeId", self._buyer_creative_id);
params.push("dealId", self._deal_id.to_string());
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "creatives/{accountId}/{buyerCreativeId}/removeDeal/{dealId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{buyerCreativeId}", "buyerCreativeId"), ("{dealId}", "dealId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["dealId", "buyerCreativeId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 id for the account that will serve this creative.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> CreativeRemoveDealCall<'a, S> {
self._account_id = new_value;
self
}
/// The buyer-specific id for this creative.
///
/// Sets the *buyer creative id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn buyer_creative_id(mut self, new_value: &str) -> CreativeRemoveDealCall<'a, S> {
self._buyer_creative_id = new_value.to_string();
self
}
/// The id of the deal id to disassociate with this creative.
///
/// Sets the *deal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn deal_id(mut self, new_value: i64) -> CreativeRemoveDealCall<'a, S> {
self._deal_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.
///
/// ````text
/// 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) -> CreativeRemoveDealCall<'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<T>(mut self, name: T, value: T) -> CreativeRemoveDealCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> CreativeRemoveDealCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> CreativeRemoveDealCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> CreativeRemoveDealCall<'a, S> {
self._scopes.clear();
self
}
}
/// Delete the specified deals from the proposal
///
/// A builder for the *delete* method supported by a *marketplacedeal* resource.
/// It is not used directly, but through a [`MarketplacedealMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::DeleteOrderDealsRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = DeleteOrderDealsRequest::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.marketplacedeals().delete(req, "proposalId")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacedealDeleteCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: DeleteOrderDealsRequest,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacedealDeleteCall<'a, S> {}
impl<'a, S> MarketplacedealDeleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, DeleteOrderDealsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacedeals.delete",
http_method: hyper::Method::POST });
for &field in ["alt", "proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/deals/delete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: DeleteOrderDealsRequest) -> MarketplacedealDeleteCall<'a, S> {
self._request = new_value;
self
}
/// The proposalId to delete deals from.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacedealDeleteCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> MarketplacedealDeleteCall<'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<T>(mut self, name: T, value: T) -> MarketplacedealDeleteCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacedealDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacedealDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacedealDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
/// Add new deals for the specified proposal
///
/// A builder for the *insert* method supported by a *marketplacedeal* resource.
/// It is not used directly, but through a [`MarketplacedealMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::AddOrderDealsRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = AddOrderDealsRequest::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.marketplacedeals().insert(req, "proposalId")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacedealInsertCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: AddOrderDealsRequest,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacedealInsertCall<'a, S> {}
impl<'a, S> MarketplacedealInsertCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, AddOrderDealsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacedeals.insert",
http_method: hyper::Method::POST });
for &field in ["alt", "proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/deals/insert";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: AddOrderDealsRequest) -> MarketplacedealInsertCall<'a, S> {
self._request = new_value;
self
}
/// proposalId for which deals need to be added.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacedealInsertCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> MarketplacedealInsertCall<'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<T>(mut self, name: T, value: T) -> MarketplacedealInsertCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacedealInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacedealInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacedealInsertCall<'a, S> {
self._scopes.clear();
self
}
}
/// List all the deals for a given proposal
///
/// A builder for the *list* method supported by a *marketplacedeal* resource.
/// It is not used directly, but through a [`MarketplacedealMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.marketplacedeals().list("proposalId")
/// .pql_query("sed")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacedealListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_proposal_id: String,
_pql_query: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacedealListCall<'a, S> {}
impl<'a, S> MarketplacedealListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetOrderDealsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacedeals.list",
http_method: hyper::Method::GET });
for &field in ["alt", "proposalId", "pqlQuery"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
if let Some(value) = self._pql_query.as_ref() {
params.push("pqlQuery", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/deals";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 proposalId to get deals for. To search across all proposals specify order_id = '-' as part of the URL.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacedealListCall<'a, S> {
self._proposal_id = new_value.to_string();
self
}
/// Query string to retrieve specific deals.
///
/// Sets the *pql query* query property to the given value.
pub fn pql_query(mut self, new_value: &str) -> MarketplacedealListCall<'a, S> {
self._pql_query = 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.
///
/// ````text
/// 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) -> MarketplacedealListCall<'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<T>(mut self, name: T, value: T) -> MarketplacedealListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacedealListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacedealListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacedealListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Replaces all the deals in the proposal with the passed in deals
///
/// A builder for the *update* method supported by a *marketplacedeal* resource.
/// It is not used directly, but through a [`MarketplacedealMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::EditAllOrderDealsRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = EditAllOrderDealsRequest::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.marketplacedeals().update(req, "proposalId")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacedealUpdateCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: EditAllOrderDealsRequest,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacedealUpdateCall<'a, S> {}
impl<'a, S> MarketplacedealUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, EditAllOrderDealsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacedeals.update",
http_method: hyper::Method::POST });
for &field in ["alt", "proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/deals/update";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: EditAllOrderDealsRequest) -> MarketplacedealUpdateCall<'a, S> {
self._request = new_value;
self
}
/// The proposalId to edit deals on.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacedealUpdateCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> MarketplacedealUpdateCall<'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<T>(mut self, name: T, value: T) -> MarketplacedealUpdateCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacedealUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacedealUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacedealUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
/// Add notes to the proposal
///
/// A builder for the *insert* method supported by a *marketplacenote* resource.
/// It is not used directly, but through a [`MarketplacenoteMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::AddOrderNotesRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = AddOrderNotesRequest::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.marketplacenotes().insert(req, "proposalId")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacenoteInsertCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: AddOrderNotesRequest,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacenoteInsertCall<'a, S> {}
impl<'a, S> MarketplacenoteInsertCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, AddOrderNotesResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacenotes.insert",
http_method: hyper::Method::POST });
for &field in ["alt", "proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/notes/insert";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: AddOrderNotesRequest) -> MarketplacenoteInsertCall<'a, S> {
self._request = new_value;
self
}
/// The proposalId to add notes for.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacenoteInsertCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> MarketplacenoteInsertCall<'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<T>(mut self, name: T, value: T) -> MarketplacenoteInsertCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacenoteInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacenoteInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacenoteInsertCall<'a, S> {
self._scopes.clear();
self
}
}
/// Get all the notes associated with a proposal
///
/// A builder for the *list* method supported by a *marketplacenote* resource.
/// It is not used directly, but through a [`MarketplacenoteMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.marketplacenotes().list("proposalId")
/// .pql_query("voluptua.")
/// .doit().await;
/// # }
/// ```
pub struct MarketplacenoteListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_proposal_id: String,
_pql_query: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplacenoteListCall<'a, S> {}
impl<'a, S> MarketplacenoteListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetOrderNotesResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplacenotes.list",
http_method: hyper::Method::GET });
for &field in ["alt", "proposalId", "pqlQuery"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
if let Some(value) = self._pql_query.as_ref() {
params.push("pqlQuery", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/notes";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 proposalId to get notes for. To search across all proposals specify order_id = '-' as part of the URL.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> MarketplacenoteListCall<'a, S> {
self._proposal_id = new_value.to_string();
self
}
/// Query string to retrieve specific notes. To search the text contents of notes, please use syntax like "WHERE note.note = "foo" or "WHERE note.note LIKE "%bar%"
///
/// Sets the *pql query* query property to the given value.
pub fn pql_query(mut self, new_value: &str) -> MarketplacenoteListCall<'a, S> {
self._pql_query = 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.
///
/// ````text
/// 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) -> MarketplacenoteListCall<'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<T>(mut self, name: T, value: T) -> MarketplacenoteListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplacenoteListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplacenoteListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplacenoteListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Update a given private auction proposal
///
/// A builder for the *updateproposal* method supported by a *marketplaceprivateauction* resource.
/// It is not used directly, but through a [`MarketplaceprivateauctionMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::UpdatePrivateAuctionProposalRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = UpdatePrivateAuctionProposalRequest::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.marketplaceprivateauction().updateproposal(req, "privateAuctionId")
/// .doit().await;
/// # }
/// ```
pub struct MarketplaceprivateauctionUpdateproposalCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: UpdatePrivateAuctionProposalRequest,
_private_auction_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MarketplaceprivateauctionUpdateproposalCall<'a, S> {}
impl<'a, S> MarketplaceprivateauctionUpdateproposalCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.marketplaceprivateauction.updateproposal",
http_method: hyper::Method::POST });
for &field in ["privateAuctionId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("privateAuctionId", self._private_auction_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "privateauction/{privateAuctionId}/updateproposal";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{privateAuctionId}", "privateAuctionId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["privateAuctionId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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)
}
}
}
}
///
/// 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: UpdatePrivateAuctionProposalRequest) -> MarketplaceprivateauctionUpdateproposalCall<'a, S> {
self._request = new_value;
self
}
/// The private auction id to be updated.
///
/// Sets the *private auction id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn private_auction_id(mut self, new_value: &str) -> MarketplaceprivateauctionUpdateproposalCall<'a, S> {
self._private_auction_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.
///
/// ````text
/// 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) -> MarketplaceprivateauctionUpdateproposalCall<'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<T>(mut self, name: T, value: T) -> MarketplaceprivateauctionUpdateproposalCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> MarketplaceprivateauctionUpdateproposalCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> MarketplaceprivateauctionUpdateproposalCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> MarketplaceprivateauctionUpdateproposalCall<'a, S> {
self._scopes.clear();
self
}
}
/// Retrieves the authenticated user's list of performance metrics.
///
/// A builder for the *list* method supported by a *performanceReport* resource.
/// It is not used directly, but through a [`PerformanceReportMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.performance_report().list(-96, "endDateTime", "startDateTime")
/// .page_token("et")
/// .max_results(79)
/// .doit().await;
/// # }
/// ```
pub struct PerformanceReportListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i64,
_end_date_time: String,
_start_date_time: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PerformanceReportListCall<'a, S> {}
impl<'a, S> PerformanceReportListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PerformanceReportList)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.performanceReport.list",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId", "endDateTime", "startDateTime", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("endDateTime", self._end_date_time);
params.push("startDateTime", self._start_date_time);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "performancereport";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id to get the reports.
///
/// Sets the *account 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 account_id(mut self, new_value: i64) -> PerformanceReportListCall<'a, S> {
self._account_id = new_value;
self
}
/// The end time of the report in ISO 8601 timestamp format using UTC.
///
/// Sets the *end date time* 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 end_date_time(mut self, new_value: &str) -> PerformanceReportListCall<'a, S> {
self._end_date_time = new_value.to_string();
self
}
/// The start time of the report in ISO 8601 timestamp format using UTC.
///
/// Sets the *start date time* 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 start_date_time(mut self, new_value: &str) -> PerformanceReportListCall<'a, S> {
self._start_date_time = new_value.to_string();
self
}
/// A continuation token, used to page through performance reports. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response. Optional.
///
/// Sets the *page token* query property to the given value.
pub fn page_token(mut self, new_value: &str) -> PerformanceReportListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
/// Maximum number of entries returned on one result page. If not set, the default is 100. Optional.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> PerformanceReportListCall<'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.
///
/// ````text
/// 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) -> PerformanceReportListCall<'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<T>(mut self, name: T, value: T) -> PerformanceReportListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PerformanceReportListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PerformanceReportListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PerformanceReportListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Deletes an existing pretargeting config.
///
/// A builder for the *delete* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.pretargeting_config().delete(-95, -15)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigDeleteCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i64,
_config_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigDeleteCall<'a, S> {}
impl<'a, S> PretargetingConfigDeleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.delete",
http_method: hyper::Method::DELETE });
for &field in ["accountId", "configId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("configId", self._config_id.to_string());
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}/{configId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{configId}", "configId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["configId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id to delete the pretargeting config for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigDeleteCall<'a, S> {
self._account_id = new_value;
self
}
/// The specific id of the configuration to delete.
///
/// Sets the *config id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn config_id(mut self, new_value: i64) -> PretargetingConfigDeleteCall<'a, S> {
self._config_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.
///
/// ````text
/// 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) -> PretargetingConfigDeleteCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigDeleteCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
/// Gets a specific pretargeting configuration
///
/// A builder for the *get* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.pretargeting_config().get(-99, -20)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i64,
_config_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigGetCall<'a, S> {}
impl<'a, S> PretargetingConfigGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PretargetingConfig)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.get",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId", "configId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("configId", self._config_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}/{configId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{configId}", "configId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["configId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id to get the pretargeting config for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigGetCall<'a, S> {
self._account_id = new_value;
self
}
/// The specific id of the configuration to retrieve.
///
/// Sets the *config id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn config_id(mut self, new_value: i64) -> PretargetingConfigGetCall<'a, S> {
self._config_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.
///
/// ````text
/// 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) -> PretargetingConfigGetCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Inserts a new pretargeting configuration.
///
/// A builder for the *insert* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::PretargetingConfig;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = PretargetingConfig::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.pretargeting_config().insert(req, -76)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigInsertCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: PretargetingConfig,
_account_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigInsertCall<'a, S> {}
impl<'a, S> PretargetingConfigInsertCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PretargetingConfig)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.insert",
http_method: hyper::Method::POST });
for &field in ["alt", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: PretargetingConfig) -> PretargetingConfigInsertCall<'a, S> {
self._request = new_value;
self
}
/// The account id to insert the pretargeting config for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigInsertCall<'a, S> {
self._account_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.
///
/// ````text
/// 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) -> PretargetingConfigInsertCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigInsertCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigInsertCall<'a, S> {
self._scopes.clear();
self
}
}
/// Retrieves a list of the authenticated user's pretargeting configurations.
///
/// A builder for the *list* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.pretargeting_config().list(-76)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigListCall<'a, S> {}
impl<'a, S> PretargetingConfigListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PretargetingConfigList)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.list",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 account id to get the pretargeting configs for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigListCall<'a, S> {
self._account_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.
///
/// ````text
/// 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) -> PretargetingConfigListCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigListCall<'a, S> {
self._scopes.clear();
self
}
}
/// Updates an existing pretargeting config. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::PretargetingConfig;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = PretargetingConfig::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.pretargeting_config().patch(req, -88, -65)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigPatchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: PretargetingConfig,
_account_id: i64,
_config_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigPatchCall<'a, S> {}
impl<'a, S> PretargetingConfigPatchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PretargetingConfig)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.patch",
http_method: hyper::Method::PATCH });
for &field in ["alt", "accountId", "configId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("configId", self._config_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}/{configId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{configId}", "configId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["configId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: PretargetingConfig) -> PretargetingConfigPatchCall<'a, S> {
self._request = new_value;
self
}
/// The account id to update the pretargeting config for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigPatchCall<'a, S> {
self._account_id = new_value;
self
}
/// The specific id of the configuration to update.
///
/// Sets the *config id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn config_id(mut self, new_value: i64) -> PretargetingConfigPatchCall<'a, S> {
self._config_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.
///
/// ````text
/// 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) -> PretargetingConfigPatchCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigPatchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigPatchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigPatchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigPatchCall<'a, S> {
self._scopes.clear();
self
}
}
/// Updates an existing pretargeting config.
///
/// A builder for the *update* method supported by a *pretargetingConfig* resource.
/// It is not used directly, but through a [`PretargetingConfigMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::PretargetingConfig;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = PretargetingConfig::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.pretargeting_config().update(req, -76, -44)
/// .doit().await;
/// # }
/// ```
pub struct PretargetingConfigUpdateCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: PretargetingConfig,
_account_id: i64,
_config_id: i64,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PretargetingConfigUpdateCall<'a, S> {}
impl<'a, S> PretargetingConfigUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, PretargetingConfig)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pretargetingConfig.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "accountId", "configId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.push("configId", self._config_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "pretargetingconfigs/{accountId}/{configId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{configId}", "configId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["configId", "accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: PretargetingConfig) -> PretargetingConfigUpdateCall<'a, S> {
self._request = new_value;
self
}
/// The account id to update the pretargeting config for.
///
/// Sets the *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 account_id(mut self, new_value: i64) -> PretargetingConfigUpdateCall<'a, S> {
self._account_id = new_value;
self
}
/// The specific id of the configuration to update.
///
/// Sets the *config id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn config_id(mut self, new_value: i64) -> PretargetingConfigUpdateCall<'a, S> {
self._config_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.
///
/// ````text
/// 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) -> PretargetingConfigUpdateCall<'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<T>(mut self, name: T, value: T) -> PretargetingConfigUpdateCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PretargetingConfigUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PretargetingConfigUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PretargetingConfigUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
/// Gets the requested product by id.
///
/// A builder for the *get* method supported by a *product* resource.
/// It is not used directly, but through a [`ProductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.products().get("productId")
/// .doit().await;
/// # }
/// ```
pub struct ProductGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_product_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProductGetCall<'a, S> {}
impl<'a, S> ProductGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Product)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.products.get",
http_method: hyper::Method::GET });
for &field in ["alt", "productId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("productId", self._product_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "products/{productId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{productId}", "productId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 id for the product to get the head revision for.
///
/// Sets the *product id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn product_id(mut self, new_value: &str) -> ProductGetCall<'a, S> {
self._product_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.
///
/// ````text
/// 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) -> ProductGetCall<'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<T>(mut self, name: T, value: T) -> ProductGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProductGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProductGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProductGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Gets the requested product.
///
/// A builder for the *search* method supported by a *product* resource.
/// It is not used directly, but through a [`ProductMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.products().search()
/// .pql_query("diam")
/// .doit().await;
/// # }
/// ```
pub struct ProductSearchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_pql_query: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProductSearchCall<'a, S> {}
impl<'a, S> ProductSearchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetOffersResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.products.search",
http_method: hyper::Method::GET });
for &field in ["alt", "pqlQuery"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
if let Some(value) = self._pql_query.as_ref() {
params.push("pqlQuery", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "products/search";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 pql query used to query for products.
///
/// Sets the *pql query* query property to the given value.
pub fn pql_query(mut self, new_value: &str) -> ProductSearchCall<'a, S> {
self._pql_query = 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.
///
/// ````text
/// 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) -> ProductSearchCall<'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<T>(mut self, name: T, value: T) -> ProductSearchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProductSearchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProductSearchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProductSearchCall<'a, S> {
self._scopes.clear();
self
}
}
/// Get a proposal given its id
///
/// A builder for the *get* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.proposals().get("proposalId")
/// .doit().await;
/// # }
/// ```
pub struct ProposalGetCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalGetCall<'a, S> {}
impl<'a, S> ProposalGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Proposal)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.get",
http_method: hyper::Method::GET });
for &field in ["alt", "proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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)
}
}
}
}
/// Id of the proposal to retrieve.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> ProposalGetCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> ProposalGetCall<'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<T>(mut self, name: T, value: T) -> ProposalGetCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalGetCall<'a, S> {
self._scopes.clear();
self
}
}
/// Create the given list of proposals
///
/// A builder for the *insert* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::CreateOrdersRequest;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = CreateOrdersRequest::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.proposals().insert(req)
/// .doit().await;
/// # }
/// ```
pub struct ProposalInsertCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: CreateOrdersRequest,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalInsertCall<'a, S> {}
impl<'a, S> ProposalInsertCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, CreateOrdersResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.insert",
http_method: hyper::Method::POST });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/insert";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: CreateOrdersRequest) -> ProposalInsertCall<'a, S> {
self._request = 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.
///
/// ````text
/// 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) -> ProposalInsertCall<'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<T>(mut self, name: T, value: T) -> ProposalInsertCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalInsertCall<'a, S> {
self._scopes.clear();
self
}
}
/// Update the given proposal. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Proposal;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = Proposal::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.proposals().patch(req, "proposalId", -23, "updateAction")
/// .doit().await;
/// # }
/// ```
pub struct ProposalPatchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Proposal,
_proposal_id: String,
_revision_number: i64,
_update_action: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalPatchCall<'a, S> {}
impl<'a, S> ProposalPatchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Proposal)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.patch",
http_method: hyper::Method::PATCH });
for &field in ["alt", "proposalId", "revisionNumber", "updateAction"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.push("revisionNumber", self._revision_number.to_string());
params.push("updateAction", self._update_action);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/{revisionNumber}/{updateAction}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId"), ("{revisionNumber}", "revisionNumber"), ("{updateAction}", "updateAction")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["updateAction", "revisionNumber", "proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: Proposal) -> ProposalPatchCall<'a, S> {
self._request = new_value;
self
}
/// The proposal id to update.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> ProposalPatchCall<'a, S> {
self._proposal_id = new_value.to_string();
self
}
/// The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision.
///
/// Sets the *revision number* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn revision_number(mut self, new_value: i64) -> ProposalPatchCall<'a, S> {
self._revision_number = new_value;
self
}
/// The proposed action to take on the proposal. This field is required and it must be set when updating a proposal.
///
/// Sets the *update action* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn update_action(mut self, new_value: &str) -> ProposalPatchCall<'a, S> {
self._update_action = 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.
///
/// ````text
/// 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) -> ProposalPatchCall<'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<T>(mut self, name: T, value: T) -> ProposalPatchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalPatchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalPatchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalPatchCall<'a, S> {
self._scopes.clear();
self
}
}
/// Search for proposals using pql query
///
/// A builder for the *search* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.proposals().search()
/// .pql_query("consetetur")
/// .doit().await;
/// # }
/// ```
pub struct ProposalSearchCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_pql_query: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalSearchCall<'a, S> {}
impl<'a, S> ProposalSearchCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetOrdersResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.search",
http_method: hyper::Method::GET });
for &field in ["alt", "pqlQuery"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
if let Some(value) = self._pql_query.as_ref() {
params.push("pqlQuery", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/search";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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)
}
}
}
}
/// Query string to retrieve specific proposals.
///
/// Sets the *pql query* query property to the given value.
pub fn pql_query(mut self, new_value: &str) -> ProposalSearchCall<'a, S> {
self._pql_query = 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.
///
/// ````text
/// 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) -> ProposalSearchCall<'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<T>(mut self, name: T, value: T) -> ProposalSearchCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalSearchCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalSearchCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalSearchCall<'a, S> {
self._scopes.clear();
self
}
}
/// Update the given proposal to indicate that setup has been completed.
///
/// A builder for the *setupcomplete* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.proposals().setupcomplete("proposalId")
/// .doit().await;
/// # }
/// ```
pub struct ProposalSetupcompleteCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_proposal_id: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalSetupcompleteCall<'a, S> {}
impl<'a, S> ProposalSetupcompleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.setupcomplete",
http_method: hyper::Method::POST });
for &field in ["proposalId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/setupcomplete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 proposal id for which the setup is complete
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> ProposalSetupcompleteCall<'a, S> {
self._proposal_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.
///
/// ````text
/// 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) -> ProposalSetupcompleteCall<'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<T>(mut self, name: T, value: T) -> ProposalSetupcompleteCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalSetupcompleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalSetupcompleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalSetupcompleteCall<'a, S> {
self._scopes.clear();
self
}
}
/// Update the given proposal
///
/// A builder for the *update* method supported by a *proposal* resource.
/// It is not used directly, but through a [`ProposalMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// use adexchangebuyer1d4::api::Proposal;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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 = Proposal::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.proposals().update(req, "proposalId", -31, "updateAction")
/// .doit().await;
/// # }
/// ```
pub struct ProposalUpdateCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_request: Proposal,
_proposal_id: String,
_revision_number: i64,
_update_action: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for ProposalUpdateCall<'a, S> {}
impl<'a, S> ProposalUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Proposal)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.proposals.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "proposalId", "revisionNumber", "updateAction"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("proposalId", self._proposal_id);
params.push("revisionNumber", self._revision_number.to_string());
params.push("updateAction", self._update_action);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "proposals/{proposalId}/{revisionNumber}/{updateAction}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{proposalId}", "proposalId"), ("{revisionNumber}", "revisionNumber"), ("{updateAction}", "updateAction")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["updateAction", "revisionNumber", "proposalId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
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.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, 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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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: Proposal) -> ProposalUpdateCall<'a, S> {
self._request = new_value;
self
}
/// The proposal id to update.
///
/// Sets the *proposal id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn proposal_id(mut self, new_value: &str) -> ProposalUpdateCall<'a, S> {
self._proposal_id = new_value.to_string();
self
}
/// The last known revision number to update. If the head revision in the marketplace database has since changed, an error will be thrown. The caller should then fetch the latest proposal at head revision and retry the update at that revision.
///
/// Sets the *revision number* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn revision_number(mut self, new_value: i64) -> ProposalUpdateCall<'a, S> {
self._revision_number = new_value;
self
}
/// The proposed action to take on the proposal. This field is required and it must be set when updating a proposal.
///
/// Sets the *update action* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
pub fn update_action(mut self, new_value: &str) -> ProposalUpdateCall<'a, S> {
self._update_action = 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.
///
/// ````text
/// 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) -> ProposalUpdateCall<'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<T>(mut self, name: T, value: T) -> ProposalUpdateCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> ProposalUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProposalUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> ProposalUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
/// Gets the requested publisher profile(s) by publisher accountId.
///
/// A builder for the *list* method supported by a *pubprofile* resource.
/// It is not used directly, but through a [`PubprofileMethods`] instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate hyper_rustls;
/// # extern crate google_adexchangebuyer1d4 as adexchangebuyer1d4;
/// # async fn dox() {
/// # use std::default::Default;
/// # use adexchangebuyer1d4::{AdExchangeBuyer, oauth2, hyper, hyper_rustls, chrono, FieldMask};
///
/// # let secret: oauth2::ApplicationSecret = Default::default();
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
/// # secret,
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # ).build().await.unwrap();
/// # let mut hub = AdExchangeBuyer::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.pubprofiles().list(-2)
/// .doit().await;
/// # }
/// ```
pub struct PubprofileListCall<'a, S>
where S: 'a {
hub: &'a AdExchangeBuyer<S>,
_account_id: i32,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for PubprofileListCall<'a, S> {}
impl<'a, S> PubprofileListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetPublisherProfilesByAccountIdResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "adexchangebuyer.pubprofiles.list",
http_method: hyper::Method::GET });
for &field in ["alt", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.push("accountId", self._account_id.to_string());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "publisher/{accountId}/profiles";
if self._scopes.is_empty() {
self._scopes.insert(Scope::AdexchangeBuyer.as_ref().to_string());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["accountId"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
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.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
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).await;
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::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
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 accountId of the publisher to get profiles for.
///
/// Sets the *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 account_id(mut self, new_value: i32) -> PubprofileListCall<'a, S> {
self._account_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.
///
/// ````text
/// 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) -> PubprofileListCall<'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<T>(mut self, name: T, value: T) -> PubprofileListCall<'a, S>
where T: AsRef<str> {
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 of the default [`Scope`] variant
/// [`Scope::AdexchangeBuyer`].
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// 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<St>(mut self, scope: St) -> PubprofileListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
/// Identifies the authorization scope(s) for the method you are building.
///
/// See [`Self::add_scope()`] for details.
pub fn add_scopes<I, St>(mut self, scopes: I) -> PubprofileListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
/// Removes all scopes, and no default scope will be used either.
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
/// for details).
pub fn clear_scopes(mut self) -> PubprofileListCall<'a, S> {
self._scopes.clear();
self
}
}