mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
* macro 'alias' was renamed to 'rename' * fixed `cargo test` on main project The latter pointed me to the serde issue, which would have made everything fail when actually used to communicate with google servers.
3645 lines
159 KiB
Rust
3645 lines
159 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *doubleclicksearch* crate version *0.1.4+20150303*, where *20150303* is the exact revision of the *doubleclicksearch:v2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.4*.
|
|
//!
|
|
//! Everything else about the *doubleclicksearch* *v2* API can be found at the
|
|
//! [official documentation site](https://developers.google.com/doubleclick-search/).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/doubleclicksearch2).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.Doubleclicksearch.html) ...
|
|
//!
|
|
//! * [conversion](struct.Conversion.html)
|
|
//! * [*get*](struct.ConversionGetCall.html), [*insert*](struct.ConversionInsertCall.html), [*patch*](struct.ConversionPatchCall.html), [*update*](struct.ConversionUpdateCall.html) and [*update availability*](struct.ConversionUpdateAvailabilityCall.html)
|
|
//! * [reports](struct.Report.html)
|
|
//! * [*generate*](struct.ReportGenerateCall.html), [*get*](struct.ReportGetCall.html), [*get file*](struct.ReportGetFileCall.html) and [*request*](struct.ReportRequestCall.html)
|
|
//! * [saved columns](struct.SavedColumn.html)
|
|
//! * [*list*](struct.SavedColumnListCall.html)
|
|
//!
|
|
//!
|
|
//! Download supported by ...
|
|
//!
|
|
//! * [*get file reports*](struct.ReportGetFileCall.html)
|
|
//!
|
|
//!
|
|
//!
|
|
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
|
|
//!
|
|
//! # Structure of this Library
|
|
//!
|
|
//! The API is structured into the following primary items:
|
|
//!
|
|
//! * **[Hub](struct.Doubleclicksearch.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
|
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.reports().generate(...).doit()
|
|
//! let r = hub.reports().get_file(...).doit()
|
|
//! let r = hub.reports().get(...).doit()
|
|
//! let r = hub.reports().request(...).doit()
|
|
//! ```
|
|
//!
|
|
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
|
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
|
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
|
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
|
//!
|
|
//! # Usage
|
|
//!
|
|
//! ## Setting up your Project
|
|
//!
|
|
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
|
//!
|
|
//! ```toml
|
|
//! [dependencies]
|
|
//! google-doubleclicksearch2 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate yup_oauth2 as oauth2;
|
|
//! extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
//! use doubleclicksearch2::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use doubleclicksearch2::Doubleclicksearch;
|
|
//!
|
|
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
//! // `client_secret`, among other things.
|
|
//! let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
//! hyper::Client::new(),
|
|
//! <MemoryStorage as Default>::default(), None);
|
|
//! let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
//! // You can configure optional parameters by calling the respective setters at will, and
|
|
//! // execute the final call using `doit()`.
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let result = hub.reports().get_file("reportId", -42)
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Err(e) => match e {
|
|
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
//! Error::MissingToken => println!("OAuth2: Missing Token"),
|
|
//! Error::Cancelled => println!("Operation canceled by user"),
|
|
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
//! },
|
|
//! Ok(_) => println!("Success (value doesn't print)"),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downloads
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
|
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
|
//! are valid.
|
|
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are borrowed
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
#![feature(std_misc)]
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
// Required for serde annotations
|
|
#![feature(custom_derive, custom_attribute, plugin, slice_patterns)]
|
|
#![plugin(serde_macros)]
|
|
|
|
#[macro_use]
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate yup_oauth2 as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use std::marker::PhantomData;
|
|
use serde::json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::thread::sleep_ms;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
|
|
|
|
|
|
// ##############
|
|
// 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 {
|
|
/// View and manage your advertising data in DoubleClick Search
|
|
Full,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::Full => "https://www.googleapis.com/auth/doubleclicksearch",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::Full
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all Doubleclicksearch related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: 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 = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.reports().get_file("reportId", -18)
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
/// Error::MissingToken => println!("OAuth2: Missing Token"),
|
|
/// Error::Cancelled => println!("Operation canceled by user"),
|
|
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
/// },
|
|
/// Ok(_) => println!("Success (value doesn't print)"),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct Doubleclicksearch<C, NC, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
|
|
_m: PhantomData<NC>
|
|
}
|
|
|
|
impl<'a, C, NC, A> Hub for Doubleclicksearch<C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> Doubleclicksearch<C, NC, A>
|
|
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> Doubleclicksearch<C, NC, A> {
|
|
Doubleclicksearch {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/0.1.4".to_string(),
|
|
_m: PhantomData
|
|
}
|
|
}
|
|
|
|
pub fn conversion(&'a self) -> ConversionMethods<'a, C, NC, A> {
|
|
ConversionMethods { hub: &self }
|
|
}
|
|
pub fn reports(&'a self) -> ReportMethods<'a, C, NC, A> {
|
|
ReportMethods { hub: &self }
|
|
}
|
|
pub fn saved_columns(&'a self) -> SavedColumnMethods<'a, C, NC, A> {
|
|
SavedColumnMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/0.1.4`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
let prev = self._user_agent.clone();
|
|
self._user_agent = agent_name;
|
|
prev
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// A message containing the custome dimension.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomDimension {
|
|
/// Custom dimension name.
|
|
pub name: String,
|
|
/// Custom dimension value.
|
|
pub value: String,
|
|
}
|
|
|
|
impl Part for CustomDimension {}
|
|
|
|
|
|
/// A message containing the custome metric.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CustomMetric {
|
|
/// Custom metric name.
|
|
pub name: String,
|
|
/// Custom metric numeric value.
|
|
pub value: f64,
|
|
}
|
|
|
|
impl Part for CustomMetric {}
|
|
|
|
|
|
/// A conversion containing data relevant to DoubleClick Search.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Conversion {
|
|
/// Custom dimensions for the conversion, which can be used to filter data in a report.
|
|
#[serde(rename="customDimension")]
|
|
pub custom_dimension: Vec<CustomDimension>,
|
|
/// DS ad group ID.
|
|
#[serde(rename="adGroupId")]
|
|
pub ad_group_id: String,
|
|
/// The numeric segmentation identifier (for example, DoubleClick Search Floodlight activity ID).
|
|
#[serde(rename="segmentationId")]
|
|
pub segmentation_id: String,
|
|
/// Attribution model name. This field is ignored.
|
|
#[serde(rename="attributionModel")]
|
|
pub attribution_model: String,
|
|
/// DS campaign ID.
|
|
#[serde(rename="campaignId")]
|
|
pub campaign_id: String,
|
|
/// The revenue amount of this TRANSACTION conversion, in micros.
|
|
#[serde(rename="revenueMicros")]
|
|
pub revenue_micros: String,
|
|
/// DS advertiser ID.
|
|
#[serde(rename="advertiserId")]
|
|
pub advertiser_id: String,
|
|
/// The quantity of this conversion, in millis.
|
|
#[serde(rename="quantityMillis")]
|
|
pub quantity_millis: String,
|
|
/// The number of conversions, formatted in millis (conversions multiplied by 1000). This field is ignored.
|
|
#[serde(rename="countMillis")]
|
|
pub count_millis: String,
|
|
/// DS criterion (keyword) ID.
|
|
#[serde(rename="criterionId")]
|
|
pub criterion_id: String,
|
|
/// The time at which the conversion took place, in epoch millis UTC.
|
|
#[serde(rename="conversionTimestamp")]
|
|
pub conversion_timestamp: String,
|
|
/// The advertiser-provided order id for the conversion.
|
|
#[serde(rename="floodlightOrderId")]
|
|
pub floodlight_order_id: String,
|
|
/// The segmentation type of this conversion (for example, FLOODLIGHT).
|
|
#[serde(rename="segmentationType")]
|
|
pub segmentation_type: String,
|
|
/// DS click ID for the conversion.
|
|
#[serde(rename="clickId")]
|
|
pub click_id: String,
|
|
/// Custom metrics for the conversion.
|
|
#[serde(rename="customMetric")]
|
|
pub custom_metric: Vec<CustomMetric>,
|
|
/// DS conversion ID.
|
|
#[serde(rename="dsConversionId")]
|
|
pub ds_conversion_id: String,
|
|
/// DS engine account ID.
|
|
#[serde(rename="engineAccountId")]
|
|
pub engine_account_id: String,
|
|
/// The time at which the conversion was last modified, in epoch millis UTC.
|
|
#[serde(rename="conversionModifiedTimestamp")]
|
|
pub conversion_modified_timestamp: String,
|
|
/// The currency code for the conversion's revenue. Should be in ISO 4217 alphabetic (3-char) format.
|
|
#[serde(rename="currencyCode")]
|
|
pub currency_code: String,
|
|
/// The friendly segmentation identifier (for example, DoubleClick Search Floodlight activity name).
|
|
#[serde(rename="segmentationName")]
|
|
pub segmentation_name: String,
|
|
/// The state of the conversion, that is, either ACTIVE or REMOVED. Note: state DELETED is deprecated.
|
|
pub state: String,
|
|
/// DS ad ID.
|
|
#[serde(rename="adId")]
|
|
pub ad_id: String,
|
|
/// DS agency ID.
|
|
#[serde(rename="agencyId")]
|
|
pub agency_id: String,
|
|
/// Advertiser-provided ID for the conversion, also known as the order ID.
|
|
#[serde(rename="conversionId")]
|
|
pub conversion_id: String,
|
|
/// The type of the conversion, that is, either ACTION or TRANSACTION. An ACTION conversion is an action by the user that has no monetarily quantifiable value, while a TRANSACTION conversion is an action that does have a monetarily quantifiable value. Examples are email list signups (ACTION) versus ecommerce purchases (TRANSACTION).
|
|
#[serde(rename="type")]
|
|
pub type_: String,
|
|
}
|
|
|
|
impl Part for Conversion {}
|
|
|
|
|
|
/// A row in a DoubleClick Search report.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ReportRow(HashMap<String, String>);
|
|
|
|
impl Part for ReportRow {}
|
|
|
|
|
|
/// Asynchronous report only. Contains a list of generated report files once the report has succesfully completed.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct ReportFiles {
|
|
/// Use this url to download the report file.
|
|
pub url: String,
|
|
/// The size of this report file in bytes.
|
|
#[serde(rename="byteCount")]
|
|
pub byte_count: i64,
|
|
}
|
|
|
|
impl NestedType for ReportFiles {}
|
|
impl Part for ReportFiles {}
|
|
|
|
|
|
/// The reportScope is a set of IDs that are used to determine which subset of entities will be returned in the report. The full lineage of IDs from the lowest scoped level desired up through agency is required.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportRequestReportScope {
|
|
/// DS advertiser ID.
|
|
#[serde(rename="advertiserId")]
|
|
pub advertiser_id: String,
|
|
/// DS ad group ID.
|
|
#[serde(rename="adGroupId")]
|
|
pub ad_group_id: String,
|
|
/// DS keyword ID.
|
|
#[serde(rename="keywordId")]
|
|
pub keyword_id: String,
|
|
/// DS ad ID.
|
|
#[serde(rename="adId")]
|
|
pub ad_id: String,
|
|
/// DS agency ID.
|
|
#[serde(rename="agencyId")]
|
|
pub agency_id: String,
|
|
/// DS engine account ID.
|
|
#[serde(rename="engineAccountId")]
|
|
pub engine_account_id: String,
|
|
/// DS campaign ID.
|
|
#[serde(rename="campaignId")]
|
|
pub campaign_id: String,
|
|
}
|
|
|
|
impl NestedType for ReportRequestReportScope {}
|
|
impl Part for ReportRequestReportScope {}
|
|
|
|
|
|
/// A list of filters to be applied to the report.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportRequestFilters {
|
|
/// Column to perform the filter on. This can be a DoubleClick Search column or a saved column.
|
|
pub column: ReportApiColumnSpec,
|
|
/// Operator to use in the filter. See the filter reference for a list of available operators.
|
|
pub operator: String,
|
|
/// A list of values to filter the column value against.
|
|
pub values: Vec<String>,
|
|
}
|
|
|
|
impl NestedType for ReportRequestFilters {}
|
|
impl Part for ReportRequestFilters {}
|
|
|
|
|
|
/// Synchronous report only. A list of columns and directions defining sorting to be performed on the report rows.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportRequestOrderBy {
|
|
/// Column to perform the sort on. This can be a DoubleClick Search-defined column or a saved column.
|
|
pub column: ReportApiColumnSpec,
|
|
/// The sort direction, which is either ascending or descending.
|
|
#[serde(rename="sortOrder")]
|
|
pub sort_order: String,
|
|
}
|
|
|
|
impl NestedType for ReportRequestOrderBy {}
|
|
impl Part for ReportRequestOrderBy {}
|
|
|
|
|
|
/// A request object used to create a DoubleClick Search report.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportApiColumnSpec {
|
|
/// Synchronous report only. Set to true to group by this column. Defaults to false.
|
|
#[serde(rename="groupByColumn")]
|
|
pub group_by_column: bool,
|
|
/// Inclusive day in YYYY-MM-DD format. When provided, this overrides the overall time range of the report for this column only. Must be provided together with startDate.
|
|
#[serde(rename="endDate")]
|
|
pub end_date: String,
|
|
/// Name of a saved column to include in the report. The report must be scoped at advertiser or lower, and this saved column must already be created in the DoubleClick Search UI.
|
|
#[serde(rename="savedColumnName")]
|
|
pub saved_column_name: String,
|
|
/// Segments a report by a custom dimension. The report must be scoped to an advertiser or lower, and the custom dimension must already be set up in DoubleClick Search. The custom dimension name, which appears in DoubleClick Search, is case sensitive.
|
|
/// If used in a conversion report, returns the value of the specified custom dimension for the given conversion, if set. This column does not segment the conversion report.
|
|
#[serde(rename="customDimensionName")]
|
|
pub custom_dimension_name: String,
|
|
/// Text used to identify this column in the report output; defaults to columnName or savedColumnName when not specified. This can be used to prevent collisions between DoubleClick Search columns and saved columns with the same name.
|
|
#[serde(rename="headerText")]
|
|
pub header_text: String,
|
|
/// Name of a DoubleClick Search column to include in the report.
|
|
#[serde(rename="columnName")]
|
|
pub column_name: String,
|
|
/// The platform that is used to provide data for the custom dimension. Acceptable values are "Floodlight".
|
|
#[serde(rename="platformSource")]
|
|
pub platform_source: String,
|
|
/// Inclusive date in YYYY-MM-DD format. When provided, this overrides the overall time range of the report for this column only. Must be provided together with endDate.
|
|
#[serde(rename="startDate")]
|
|
pub start_date: String,
|
|
/// Name of a custom metric to include in the report. The report must be scoped to an advertiser or lower, and the custom metric must already be set up in DoubleClick Search. The custom metric name, which appears in DoubleClick Search, is case sensitive.
|
|
#[serde(rename="customMetricName")]
|
|
pub custom_metric_name: String,
|
|
}
|
|
|
|
impl Part for ReportApiColumnSpec {}
|
|
|
|
|
|
/// A message containing availability data relevant to DoubleClick Search.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Availability {
|
|
/// DS advertiser ID.
|
|
#[serde(rename="advertiserId")]
|
|
pub advertiser_id: String,
|
|
/// The numeric segmentation identifier (for example, DoubleClick Search Floodlight activity ID).
|
|
#[serde(rename="segmentationId")]
|
|
pub segmentation_id: String,
|
|
/// The segmentation type that this availability is for (its default value is FLOODLIGHT).
|
|
#[serde(rename="segmentationType")]
|
|
pub segmentation_type: String,
|
|
/// DS agency ID.
|
|
#[serde(rename="agencyId")]
|
|
pub agency_id: String,
|
|
/// The friendly segmentation identifier (for example, DoubleClick Search Floodlight activity name).
|
|
#[serde(rename="segmentationName")]
|
|
pub segmentation_name: String,
|
|
/// The time by which all conversions have been uploaded, in epoch millis UTC.
|
|
#[serde(rename="availabilityTimestamp")]
|
|
pub availability_timestamp: String,
|
|
}
|
|
|
|
impl Part for Availability {}
|
|
|
|
|
|
/// A request object used to create a DoubleClick Search report.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [generate reports](struct.ReportGenerateCall.html) (request)
|
|
/// * [request reports](struct.ReportRequestCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportRequest {
|
|
/// Synchronous report only. A list of columns and directions defining sorting to be performed on the report rows.
|
|
#[serde(rename="orderBy")]
|
|
pub order_by: Option<Vec<ReportRequestOrderBy>>,
|
|
/// The reportScope is a set of IDs that are used to determine which subset of entities will be returned in the report. The full lineage of IDs from the lowest scoped level desired up through agency is required.
|
|
#[serde(rename="reportScope")]
|
|
pub report_scope: Option<ReportRequestReportScope>,
|
|
/// Asynchronous report only. The maximum number of rows per report file. A large report is split into many files based on this field. Acceptable values are 1000000 to 100000000, inclusive.
|
|
#[serde(rename="maxRowsPerFile")]
|
|
pub max_rows_per_file: Option<i32>,
|
|
/// Specifies the currency in which monetary will be returned. Possible values are: usd, agency (valid if the report is scoped to agency or lower), advertiser (valid if the report is scoped to * advertiser or lower), or account (valid if the report is scoped to engine account or lower).
|
|
#[serde(rename="statisticsCurrency")]
|
|
pub statistics_currency: Option<String>,
|
|
/// If metrics are requested in a report, this argument will be used to restrict the metrics to a specific time range.
|
|
#[serde(rename="timeRange")]
|
|
pub time_range: Option<ReportRequestTimeRange>,
|
|
/// Synchronous report only. Zero-based index of the first row to return. Acceptable values are 0 to 50000, inclusive. Defaults to 0.
|
|
#[serde(rename="startRow")]
|
|
pub start_row: Option<i32>,
|
|
/// Synchronous report only. The maxinum number of rows to return; additional rows are dropped. Acceptable values are 0 to 10000, inclusive. Defaults to 10000.
|
|
#[serde(rename="rowCount")]
|
|
pub row_count: Option<i32>,
|
|
/// Determines the type of rows that are returned in the report. For example, if you specify reportType: keyword, each row in the report will contain data about a keyword. See the Types of Reports reference for the columns that are available for each type.
|
|
#[serde(rename="reportType")]
|
|
pub report_type: Option<String>,
|
|
/// The columns to include in the report. This includes both DoubleClick Search columns and saved columns. For DoubleClick Search columns, only the columnName parameter is required. For saved columns only the savedColumnName parameter is required. Both columnName and savedColumnName cannot be set in the same stanza.
|
|
pub columns: Option<Vec<ReportApiColumnSpec>>,
|
|
/// A list of filters to be applied to the report.
|
|
pub filters: Option<Vec<ReportRequestFilters>>,
|
|
/// Determines if removed entities should be included in the report. Defaults to false.
|
|
#[serde(rename="includeRemovedEntities")]
|
|
pub include_removed_entities: Option<bool>,
|
|
/// Determines if removed entities should be included in the report. Defaults to false. Deprecated, please use includeRemovedEntities instead.
|
|
#[serde(rename="includeDeletedEntities")]
|
|
pub include_deleted_entities: Option<bool>,
|
|
/// If true, the report would only be created if all the requested stat data are sourced from a single timezone. Defaults to false.
|
|
#[serde(rename="verifySingleTimeZone")]
|
|
pub verify_single_time_zone: Option<bool>,
|
|
/// Format that the report should be returned in. Currently csv or tsv is supported.
|
|
#[serde(rename="downloadFormat")]
|
|
pub download_format: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for ReportRequest {}
|
|
|
|
|
|
/// A DoubleClick Search report. This object contains the report request, some report metadata such as currency code, and the generated report rows or report files.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [generate reports](struct.ReportGenerateCall.html) (response)
|
|
/// * [get file reports](struct.ReportGetFileCall.html) (none)
|
|
/// * [get reports](struct.ReportGetCall.html) (response)
|
|
/// * [request reports](struct.ReportRequestCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Report {
|
|
/// Asynchronous report only. Contains a list of generated report files once the report has succesfully completed.
|
|
pub files: Vec<ReportFiles>,
|
|
/// Identifies this as a Report resource. Value: the fixed string doubleclicksearch#report.
|
|
pub kind: String,
|
|
/// Synchronous report only. Generated report rows.
|
|
pub rows: Vec<ReportRow>,
|
|
/// The request that created the report. Optional fields not specified in the original request are filled with default values.
|
|
pub request: ReportRequest,
|
|
/// Asynchronous report only. True if and only if the report has completed successfully and the report files are ready to be downloaded.
|
|
#[serde(rename="isReportReady")]
|
|
pub is_report_ready: bool,
|
|
/// The number of report rows generated by the report, not including headers.
|
|
#[serde(rename="rowCount")]
|
|
pub row_count: i32,
|
|
/// If all statistics of the report are sourced from the same time zone, this would be it. Otherwise the field is unset.
|
|
#[serde(rename="statisticsTimeZone")]
|
|
pub statistics_time_zone: String,
|
|
/// The currency code of all monetary values produced in the report, including values that are set by users (e.g., keyword bid settings) and metrics (e.g., cost and revenue). The currency code of a report is determined by the statisticsCurrency field of the report request.
|
|
#[serde(rename="statisticsCurrencyCode")]
|
|
pub statistics_currency_code: String,
|
|
/// Asynchronous report only. Id of the report.
|
|
pub id: String,
|
|
}
|
|
|
|
impl Resource for Report {}
|
|
impl ResponseResult for Report {}
|
|
|
|
|
|
/// If metrics are requested in a report, this argument will be used to restrict the metrics to a specific time range.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ReportRequestTimeRange {
|
|
/// Inclusive UTC timestamp in RFC format, e.g., 2013-07-16T10:16:23.555Z. See additional references on how changed metrics reports work.
|
|
#[serde(rename="changedMetricsSinceTimestamp")]
|
|
pub changed_metrics_since_timestamp: String,
|
|
/// Inclusive date in YYYY-MM-DD format.
|
|
#[serde(rename="endDate")]
|
|
pub end_date: String,
|
|
/// Inclusive UTC timestamp in RFC format, e.g., 2013-07-16T10:16:23.555Z. See additional references on how changed attribute reports work.
|
|
#[serde(rename="changedAttributesSinceTimestamp")]
|
|
pub changed_attributes_since_timestamp: String,
|
|
/// Inclusive date in YYYY-MM-DD format.
|
|
#[serde(rename="startDate")]
|
|
pub start_date: String,
|
|
}
|
|
|
|
impl NestedType for ReportRequestTimeRange {}
|
|
impl Part for ReportRequestTimeRange {}
|
|
|
|
|
|
/// A list of saved columns. Advertisers create saved columns to report on Floodlight activities, Google Analytics goals, or custom KPIs. To request reports with saved columns, you'll need the saved column names that are available from this 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 saved columns](struct.SavedColumnListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct SavedColumnList {
|
|
/// The saved columns being requested.
|
|
pub items: Vec<SavedColumn>,
|
|
/// Identifies this as a SavedColumnList resource. Value: the fixed string doubleclicksearch#savedColumnList.
|
|
pub kind: String,
|
|
}
|
|
|
|
impl ResponseResult for SavedColumnList {}
|
|
|
|
|
|
/// A saved column
|
|
///
|
|
/// # 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 saved columns](struct.SavedColumnListCall.html) (none)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct SavedColumn {
|
|
/// The name of the saved column.
|
|
#[serde(rename="savedColumnName")]
|
|
pub saved_column_name: Option<String>,
|
|
/// Identifies this as a SavedColumn resource. Value: the fixed string doubleclicksearch#savedColumn.
|
|
pub kind: Option<String>,
|
|
/// The type of data this saved column will produce.
|
|
#[serde(rename="type")]
|
|
pub type_: Option<String>,
|
|
}
|
|
|
|
impl Resource for SavedColumn {}
|
|
|
|
|
|
/// The request to update availability.
|
|
///
|
|
/// # 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 availability conversion](struct.ConversionUpdateAvailabilityCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize)]
|
|
pub struct UpdateAvailabilityRequest {
|
|
/// The availabilities being requested.
|
|
pub availabilities: Option<Vec<Availability>>,
|
|
}
|
|
|
|
impl RequestValue for UpdateAvailabilityRequest {}
|
|
|
|
|
|
/// The response to a update availability request.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [update availability conversion](struct.ConversionUpdateAvailabilityCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct UpdateAvailabilityResponse {
|
|
/// The availabilities being returned.
|
|
pub availabilities: Vec<Availability>,
|
|
}
|
|
|
|
impl ResponseResult for UpdateAvailabilityResponse {}
|
|
|
|
|
|
/// A list of conversions.
|
|
///
|
|
/// # 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 conversion](struct.ConversionInsertCall.html) (request|response)
|
|
/// * [get conversion](struct.ConversionGetCall.html) (response)
|
|
/// * [patch conversion](struct.ConversionPatchCall.html) (request|response)
|
|
/// * [update conversion](struct.ConversionUpdateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ConversionList {
|
|
/// The conversions being requested.
|
|
pub conversion: Option<Vec<Conversion>>,
|
|
/// Identifies this as a ConversionList resource. Value: the fixed string doubleclicksearch#conversionList.
|
|
pub kind: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for ConversionList {}
|
|
impl ResponseResult for ConversionList {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *conversion* resources.
|
|
/// It is not used directly, but through the `Doubleclicksearch` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`, `insert(...)`, `patch(...)`, `update(...)` and `update_availability(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.conversion();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for ConversionMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Inserts a batch of new conversions into DoubleClick Search.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn insert(&self, request: &ConversionList) -> ConversionInsertCall<'a, C, NC, A> {
|
|
ConversionInsertCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieves a list of conversions from a DoubleClick Search engine account.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `agencyId` - Numeric ID of the agency.
|
|
/// * `advertiserId` - Numeric ID of the advertiser.
|
|
/// * `engineAccountId` - Numeric ID of the engine account.
|
|
/// * `endDate` - Last date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
/// * `rowCount` - The number of conversions to return per call.
|
|
/// * `startDate` - First date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
/// * `startRow` - The 0-based starting index for retrieving conversions results.
|
|
pub fn get(&self, agency_id: &str, advertiser_id: &str, engine_account_id: &str, end_date: i32, row_count: i32, start_date: i32, start_row: u32) -> ConversionGetCall<'a, C, NC, A> {
|
|
ConversionGetCall {
|
|
hub: self.hub,
|
|
_agency_id: agency_id.to_string(),
|
|
_advertiser_id: advertiser_id.to_string(),
|
|
_engine_account_id: engine_account_id.to_string(),
|
|
_end_date: end_date,
|
|
_row_count: row_count,
|
|
_start_date: start_date,
|
|
_start_row: start_row,
|
|
_criterion_id: Default::default(),
|
|
_campaign_id: Default::default(),
|
|
_ad_id: Default::default(),
|
|
_ad_group_id: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates the availabilities of a batch of floodlight activities in DoubleClick Search.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn update_availability(&self, request: &UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, NC, A> {
|
|
ConversionUpdateAvailabilityCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates a batch of conversions in DoubleClick Search. This method supports patch semantics.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `advertiserId` - Numeric ID of the advertiser.
|
|
/// * `agencyId` - Numeric ID of the agency.
|
|
/// * `endDate` - Last date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
/// * `engineAccountId` - Numeric ID of the engine account.
|
|
/// * `rowCount` - The number of conversions to return per call.
|
|
/// * `startDate` - First date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
/// * `startRow` - The 0-based starting index for retrieving conversions results.
|
|
pub fn patch(&self, request: &ConversionList, advertiser_id: &str, agency_id: &str, end_date: i32, engine_account_id: &str, row_count: i32, start_date: i32, start_row: u32) -> ConversionPatchCall<'a, C, NC, A> {
|
|
ConversionPatchCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_advertiser_id: advertiser_id.to_string(),
|
|
_agency_id: agency_id.to_string(),
|
|
_end_date: end_date,
|
|
_engine_account_id: engine_account_id.to_string(),
|
|
_row_count: row_count,
|
|
_start_date: start_date,
|
|
_start_row: start_row,
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Updates a batch of conversions in DoubleClick Search.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn update(&self, request: &ConversionList) -> ConversionUpdateCall<'a, C, NC, A> {
|
|
ConversionUpdateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *savedColumn* resources.
|
|
/// It is not used directly, but through the `Doubleclicksearch` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.saved_columns();
|
|
/// # }
|
|
/// ```
|
|
pub struct SavedColumnMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for SavedColumnMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SavedColumnMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Retrieve the list of saved columns for a specified advertiser.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `agencyId` - DS ID of the agency.
|
|
/// * `advertiserId` - DS ID of the advertiser.
|
|
pub fn list(&self, agency_id: &str, advertiser_id: &str) -> SavedColumnListCall<'a, C, NC, A> {
|
|
SavedColumnListCall {
|
|
hub: self.hub,
|
|
_agency_id: agency_id.to_string(),
|
|
_advertiser_id: advertiser_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *report* resources.
|
|
/// It is not used directly, but through the `Doubleclicksearch` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `generate(...)`, `get(...)`, `get_file(...)` and `request(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.reports();
|
|
/// # }
|
|
/// ```
|
|
pub struct ReportMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> MethodsBuilder for ReportMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ReportMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Downloads a report file encoded in UTF-8.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `reportId` - ID of the report.
|
|
/// * `reportFragment` - The index of the report fragment to download.
|
|
pub fn get_file(&self, report_id: &str, report_fragment: i32) -> ReportGetFileCall<'a, C, NC, A> {
|
|
ReportGetFileCall {
|
|
hub: self.hub,
|
|
_report_id: report_id.to_string(),
|
|
_report_fragment: report_fragment,
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Generates and returns a report immediately.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn generate(&self, request: &ReportRequest) -> ReportGenerateCall<'a, C, NC, A> {
|
|
ReportGenerateCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Polls for the status of a report request.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `reportId` - ID of the report request being polled.
|
|
pub fn get(&self, report_id: &str) -> ReportGetCall<'a, C, NC, A> {
|
|
ReportGetCall {
|
|
hub: self.hub,
|
|
_report_id: report_id.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Inserts a report request into the reporting system.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
pub fn request(&self, request: &ReportRequest) -> ReportRequestCall<'a, C, NC, A> {
|
|
ReportRequestCall {
|
|
hub: self.hub,
|
|
_request: request.clone(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Inserts a batch of new conversions into DoubleClick Search.
|
|
///
|
|
/// A builder for the *insert* method supported by a *conversion* resource.
|
|
/// It is not used directly, but through a `ConversionMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::ConversionList;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: ConversionList = Default::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.conversion().insert(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: ConversionList,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ConversionInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ConversionList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.conversion.insert",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/conversion".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &ConversionList) -> ConversionInsertCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConversionInsertCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ConversionInsertCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ConversionInsertCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieves a list of conversions from a DoubleClick Search engine account.
|
|
///
|
|
/// A builder for the *get* method supported by a *conversion* resource.
|
|
/// It is not used directly, but through a `ConversionMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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.conversion().get("agencyId", "advertiserId", "engineAccountId", -70, -1, -81, 66)
|
|
/// .criterion_id("sea")
|
|
/// .campaign_id("nonumy")
|
|
/// .ad_id("dolores")
|
|
/// .ad_group_id("gubergren")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_agency_id: String,
|
|
_advertiser_id: String,
|
|
_engine_account_id: String,
|
|
_end_date: i32,
|
|
_row_count: i32,
|
|
_start_date: i32,
|
|
_start_row: u32,
|
|
_criterion_id: Option<String>,
|
|
_campaign_id: Option<String>,
|
|
_ad_id: Option<String>,
|
|
_ad_group_id: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ConversionGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ConversionList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.conversion.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((13 + self._additional_params.len()));
|
|
params.push(("agencyId", self._agency_id.to_string()));
|
|
params.push(("advertiserId", self._advertiser_id.to_string()));
|
|
params.push(("engineAccountId", self._engine_account_id.to_string()));
|
|
params.push(("endDate", self._end_date.to_string()));
|
|
params.push(("rowCount", self._row_count.to_string()));
|
|
params.push(("startDate", self._start_date.to_string()));
|
|
params.push(("startRow", self._start_row.to_string()));
|
|
if let Some(value) = self._criterion_id {
|
|
params.push(("criterionId", value.to_string()));
|
|
}
|
|
if let Some(value) = self._campaign_id {
|
|
params.push(("campaignId", value.to_string()));
|
|
}
|
|
if let Some(value) = self._ad_id {
|
|
params.push(("adId", value.to_string()));
|
|
}
|
|
if let Some(value) = self._ad_group_id {
|
|
params.push(("adGroupId", value.to_string()));
|
|
}
|
|
for &field in ["alt", "agencyId", "advertiserId", "engineAccountId", "endDate", "rowCount", "startDate", "startRow", "criterionId", "campaignId", "adId", "adGroupId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/agency/{agencyId}/advertiser/{advertiserId}/engine/{engineAccountId}/conversion".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{agencyId}", "agencyId"), ("{advertiserId}", "advertiserId"), ("{engineAccountId}", "engineAccountId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
|
|
for param_name in ["agencyId", "advertiserId", "engineAccountId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *agency id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// Numeric ID of the agency.
|
|
pub fn agency_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._agency_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *advertiser id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// Numeric ID of the advertiser.
|
|
pub fn advertiser_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._advertiser_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *engine 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.
|
|
///
|
|
/// Numeric ID of the engine account.
|
|
pub fn engine_account_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._engine_account_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *end date* 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.
|
|
///
|
|
/// Last date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
pub fn end_date(mut self, new_value: i32) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._end_date = new_value;
|
|
self
|
|
}
|
|
/// Sets the *row count* 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.
|
|
///
|
|
/// The number of conversions to return per call.
|
|
pub fn row_count(mut self, new_value: i32) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._row_count = new_value;
|
|
self
|
|
}
|
|
/// Sets the *start date* 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.
|
|
///
|
|
/// First date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
pub fn start_date(mut self, new_value: i32) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._start_date = new_value;
|
|
self
|
|
}
|
|
/// Sets the *start row* 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.
|
|
///
|
|
/// The 0-based starting index for retrieving conversions results.
|
|
pub fn start_row(mut self, new_value: u32) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._start_row = new_value;
|
|
self
|
|
}
|
|
/// Sets the *criterion id* query property to the given value.
|
|
///
|
|
///
|
|
/// Numeric ID of the criterion.
|
|
pub fn criterion_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._criterion_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *campaign id* query property to the given value.
|
|
///
|
|
///
|
|
/// Numeric ID of the campaign.
|
|
pub fn campaign_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._campaign_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *ad id* query property to the given value.
|
|
///
|
|
///
|
|
/// Numeric ID of the ad.
|
|
pub fn ad_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._ad_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *ad group id* query property to the given value.
|
|
///
|
|
///
|
|
/// Numeric ID of the ad group.
|
|
pub fn ad_group_id(mut self, new_value: &str) -> ConversionGetCall<'a, C, NC, A> {
|
|
self._ad_group_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConversionGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ConversionGetCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ConversionGetCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates the availabilities of a batch of floodlight activities in DoubleClick Search.
|
|
///
|
|
/// A builder for the *updateAvailability* method supported by a *conversion* resource.
|
|
/// It is not used directly, but through a `ConversionMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::UpdateAvailabilityRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: UpdateAvailabilityRequest = Default::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.conversion().update_availability(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionUpdateAvailabilityCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: UpdateAvailabilityRequest,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ConversionUpdateAvailabilityCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionUpdateAvailabilityCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, UpdateAvailabilityResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.conversion.updateAvailability",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/conversion/updateAvailability".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &UpdateAvailabilityRequest) -> ConversionUpdateAvailabilityCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConversionUpdateAvailabilityCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ConversionUpdateAvailabilityCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ConversionUpdateAvailabilityCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a batch of conversions in DoubleClick Search. This method supports patch semantics.
|
|
///
|
|
/// A builder for the *patch* method supported by a *conversion* resource.
|
|
/// It is not used directly, but through a `ConversionMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::ConversionList;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: ConversionList = Default::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.conversion().patch(&req, "advertiserId", "agencyId", -66, "engineAccountId", -21, -21, 67)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionPatchCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: ConversionList,
|
|
_advertiser_id: String,
|
|
_agency_id: String,
|
|
_end_date: i32,
|
|
_engine_account_id: String,
|
|
_row_count: i32,
|
|
_start_date: i32,
|
|
_start_row: u32,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ConversionPatchCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ConversionList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.conversion.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((10 + self._additional_params.len()));
|
|
params.push(("advertiserId", self._advertiser_id.to_string()));
|
|
params.push(("agencyId", self._agency_id.to_string()));
|
|
params.push(("endDate", self._end_date.to_string()));
|
|
params.push(("engineAccountId", self._engine_account_id.to_string()));
|
|
params.push(("rowCount", self._row_count.to_string()));
|
|
params.push(("startDate", self._start_date.to_string()));
|
|
params.push(("startRow", self._start_row.to_string()));
|
|
for &field in ["alt", "advertiserId", "agencyId", "endDate", "engineAccountId", "rowCount", "startDate", "startRow"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/conversion".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &ConversionList) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *advertiser id* query property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// Numeric ID of the advertiser.
|
|
pub fn advertiser_id(mut self, new_value: &str) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._advertiser_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *agency 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.
|
|
///
|
|
/// Numeric ID of the agency.
|
|
pub fn agency_id(mut self, new_value: &str) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._agency_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *end date* 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.
|
|
///
|
|
/// Last date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
pub fn end_date(mut self, new_value: i32) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._end_date = new_value;
|
|
self
|
|
}
|
|
/// Sets the *engine 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.
|
|
///
|
|
/// Numeric ID of the engine account.
|
|
pub fn engine_account_id(mut self, new_value: &str) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._engine_account_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *row count* 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.
|
|
///
|
|
/// The number of conversions to return per call.
|
|
pub fn row_count(mut self, new_value: i32) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._row_count = new_value;
|
|
self
|
|
}
|
|
/// Sets the *start date* 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.
|
|
///
|
|
/// First date (inclusive) on which to retrieve conversions. Format is yyyymmdd.
|
|
pub fn start_date(mut self, new_value: i32) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._start_date = new_value;
|
|
self
|
|
}
|
|
/// Sets the *start row* 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.
|
|
///
|
|
/// The 0-based starting index for retrieving conversions results.
|
|
pub fn start_row(mut self, new_value: u32) -> ConversionPatchCall<'a, C, NC, A> {
|
|
self._start_row = new_value;
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConversionPatchCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ConversionPatchCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ConversionPatchCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Updates a batch of conversions in DoubleClick Search.
|
|
///
|
|
/// A builder for the *update* method supported by a *conversion* resource.
|
|
/// It is not used directly, but through a `ConversionMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::ConversionList;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: ConversionList = Default::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.conversion().update(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ConversionUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: ConversionList,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ConversionUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ConversionUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ConversionList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.conversion.update",
|
|
http_method: hyper::method::Method::Put });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/conversion".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &ConversionList) -> ConversionUpdateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ConversionUpdateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ConversionUpdateCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ConversionUpdateCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Retrieve the list of saved columns for a specified advertiser.
|
|
///
|
|
/// A builder for the *list* method supported by a *savedColumn* resource.
|
|
/// It is not used directly, but through a `SavedColumnMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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.saved_columns().list("agencyId", "advertiserId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct SavedColumnListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_agency_id: String,
|
|
_advertiser_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for SavedColumnListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> SavedColumnListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, SavedColumnList)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.savedColumns.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("agencyId", self._agency_id.to_string()));
|
|
params.push(("advertiserId", self._advertiser_id.to_string()));
|
|
for &field in ["alt", "agencyId", "advertiserId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/agency/{agencyId}/advertiser/{advertiserId}/savedcolumns".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{agencyId}", "agencyId"), ("{advertiserId}", "advertiserId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["agencyId", "advertiserId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *agency id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// DS ID of the agency.
|
|
pub fn agency_id(mut self, new_value: &str) -> SavedColumnListCall<'a, C, NC, A> {
|
|
self._agency_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *advertiser id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// DS ID of the advertiser.
|
|
pub fn advertiser_id(mut self, new_value: &str) -> SavedColumnListCall<'a, C, NC, A> {
|
|
self._advertiser_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> SavedColumnListCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> SavedColumnListCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> SavedColumnListCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Downloads a report file encoded in UTF-8.
|
|
///
|
|
/// This method supports **media download**. To enable it, adjust the builder like this:
|
|
/// `.param("alt", "media")`.
|
|
///
|
|
/// A builder for the *getFile* method supported by a *report* resource.
|
|
/// It is not used directly, but through a `ReportMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.reports().get_file("reportId", -5)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ReportGetFileCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_report_id: String,
|
|
_report_fragment: i32,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ReportGetFileCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ReportGetFileCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<hyper::client::Response> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.reports.getFile",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("reportId", self._report_id.to_string()));
|
|
params.push(("reportFragment", self._report_fragment.to_string()));
|
|
for &field in ["reportId", "reportFragment"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/reports/{reportId}/files/{reportFragment}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{reportId}", "reportId"), ("{reportFragment}", "reportFragment")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
|
|
for param_name in ["reportId", "reportFragment"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = res;
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *report id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// ID of the report.
|
|
pub fn report_id(mut self, new_value: &str) -> ReportGetFileCall<'a, C, NC, A> {
|
|
self._report_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *report fragment* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// The index of the report fragment to download.
|
|
pub fn report_fragment(mut self, new_value: i32) -> ReportGetFileCall<'a, C, NC, A> {
|
|
self._report_fragment = new_value;
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportGetFileCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ReportGetFileCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ReportGetFileCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Generates and returns a report immediately.
|
|
///
|
|
/// A builder for the *generate* method supported by a *report* resource.
|
|
/// It is not used directly, but through a `ReportMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::ReportRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: ReportRequest = Default::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.reports().generate(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ReportGenerateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: ReportRequest,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ReportGenerateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ReportGenerateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.reports.generate",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/reports/generate".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &ReportRequest) -> ReportGenerateCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportGenerateCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ReportGenerateCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ReportGenerateCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Polls for the status of a report request.
|
|
///
|
|
/// A builder for the *get* method supported by a *report* resource.
|
|
/// It is not used directly, but through a `ReportMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.reports().get("reportId")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ReportGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_report_id: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ReportGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ReportGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.reports.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("reportId", self._report_id.to_string()));
|
|
for &field in ["alt", "reportId"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/reports/{reportId}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{reportId}", "reportId")].iter() {
|
|
let mut replace_with: Option<&str> = None;
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = Some(value);
|
|
break;
|
|
}
|
|
}
|
|
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["reportId"].iter() {
|
|
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
|
|
if name == param_name {
|
|
indices_for_removal.push(params.len() - index - 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone());
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the *report id* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
///
|
|
/// ID of the report request being polled.
|
|
pub fn report_id(mut self, new_value: &str) -> ReportGetCall<'a, C, NC, A> {
|
|
self._report_id = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportGetCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ReportGetCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ReportGetCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Inserts a report request into the reporting system.
|
|
///
|
|
/// A builder for the *request* method supported by a *report* resource.
|
|
/// It is not used directly, but through a `ReportMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_doubleclicksearch2 as doubleclicksearch2;
|
|
/// use doubleclicksearch2::ReportRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use doubleclicksearch2::Doubleclicksearch;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Doubleclicksearch::new(hyper::Client::new(), 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: ReportRequest = Default::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.reports().request(&req)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ReportRequestCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Doubleclicksearch<C, NC, A>,
|
|
_request: ReportRequest,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for ReportRequestCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> ReportRequestCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Report)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "doubleclicksearch.reports.request",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
for &field in ["alt"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = "https://www.googleapis.com/doubleclicksearch/v2/reports".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::Full.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
|
|
if token.is_none() {
|
|
token = dlg.token();
|
|
}
|
|
if token.is_none() {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken)
|
|
}
|
|
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
|
|
access_token: token.unwrap().access_token });
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref())
|
|
.header(UserAgent(self.hub._user_agent.clone()))
|
|
.header(auth_header.clone())
|
|
.header(ContentType(json_mime_type.clone()))
|
|
.header(ContentLength(request_size as u64))
|
|
.body(&mut request_value_reader);
|
|
|
|
dlg.pre_request();
|
|
req.send()
|
|
};
|
|
|
|
match req_result {
|
|
Err(err) => {
|
|
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
|
|
sleep_ms(d.num_milliseconds() as u32);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Err(Error::Failure(res))
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(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: &ReportRequest) -> ReportRequestCall<'a, C, NC, A> {
|
|
self._request = new_value.clone();
|
|
self
|
|
}
|
|
/// Sets the *delegate* property to the given value.
|
|
///
|
|
///
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportRequestCall<'a, C, NC, A> {
|
|
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 paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *alt* (query-string) - Data format for the response.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ReportRequestCall<'a, C, NC, A>
|
|
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 relying on the
|
|
/// automated algorithm which simply prefers read-only scopes over those who are not.
|
|
///
|
|
/// 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<T>(mut self, scope: T) -> ReportRequestCall<'a, C, NC, A>
|
|
where T: AsRef<str> {
|
|
self._scopes.insert(scope.as_ref().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|