Files
google-apis-rs/gen/adsensehost4d1/src/lib.rs
Sebastian Thiel 04f4c95688 fix(mbuild): upload size now taken properly
Previously, it would query the size from the wrong dict and obtain
the value 0 all the time. This would have made every upload fail with
`UploadSizeLimitExeeded`.
Now we obtain the actual size limit, and will ignore it if unset/0
for some reason.

Patch += 1
2015-03-22 22:39:36 +01:00

8269 lines
358 KiB
Rust

// DO NOT EDIT !
// This file was generated automatically from 'src/mako/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *AdSense Host* crate version *0.1.1+20150302*, where *20150302* is the exact revision of the *adsensehost:v4.1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
//!
//! Everything else about the *AdSense Host* *v4d1* API can be found at the
//! [official documentation site](https://developers.google.com/adsense/host/).
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/adsensehost4d1).
//! # Features
//!
//! Handle the following *Resources* with ease from the central [hub](struct.AdSenseHost.html) ...
//!
//! * [accounts](struct.Account.html)
//! * [*adclients get*](struct.AccountAdclientGetCall.html), [*adclients list*](struct.AccountAdclientListCall.html), [*adunits delete*](struct.AccountAdunitDeleteCall.html), [*adunits get*](struct.AccountAdunitGetCall.html), [*adunits get ad code*](struct.AccountAdunitGetAdCodeCall.html), [*adunits insert*](struct.AccountAdunitInsertCall.html), [*adunits list*](struct.AccountAdunitListCall.html), [*adunits patch*](struct.AccountAdunitPatchCall.html), [*adunits update*](struct.AccountAdunitUpdateCall.html), [*get*](struct.AccountGetCall.html), [*list*](struct.AccountListCall.html) and [*reports generate*](struct.AccountReportGenerateCall.html)
//! * adclients
//! * [*get*](struct.AdclientGetCall.html) and [*list*](struct.AdclientListCall.html)
//! * associationsessions
//! * [*start*](struct.AssociationsessionStartCall.html) and [*verify*](struct.AssociationsessionVerifyCall.html)
//! * customchannels
//! * [*delete*](struct.CustomchannelDeleteCall.html), [*get*](struct.CustomchannelGetCall.html), [*insert*](struct.CustomchannelInsertCall.html), [*list*](struct.CustomchannelListCall.html), [*patch*](struct.CustomchannelPatchCall.html) and [*update*](struct.CustomchannelUpdateCall.html)
//! * [reports](struct.Report.html)
//! * [*generate*](struct.ReportGenerateCall.html)
//! * urlchannels
//! * [*delete*](struct.UrlchannelDeleteCall.html), [*insert*](struct.UrlchannelInsertCall.html) and [*list*](struct.UrlchannelListCall.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.AdSenseHost.html)**
//! * a central object to maintain state and allow accessing all *Activities*
//! * **[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*
//!
//! Generally speaking, you can invoke *Activities* like this:
//!
//! ```Rust,ignore
//! let r = hub.resource().activity(...).doit()
//! ```
//!
//! Or specifically ...
//!
//! ```ignore
//! let r = hub.accounts().adunits_get(...).doit()
//! let r = hub.accounts().get(...).doit()
//! let r = hub.accounts().adunits_list(...).doit()
//! let r = hub.accounts().adunits_get_ad_code(...).doit()
//! let r = hub.accounts().reports_generate(...).doit()
//! let r = hub.accounts().adunits_delete(...).doit()
//! let r = hub.accounts().adunits_update(...).doit()
//! let r = hub.accounts().adunits_patch(...).doit()
//! let r = hub.accounts().adunits_insert(...).doit()
//! let r = hub.accounts().list(...).doit()
//! let r = hub.accounts().adclients_list(...).doit()
//! let r = hub.accounts().adclients_get(...).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-adsensehost4d1 = "*"
//! ```
//!
//! ## A complete example
//!
//! ```test_harness,no_run
//! extern crate hyper;
//! extern crate "yup-oauth2" as oauth2;
//! extern crate "google-adsensehost4d1" as adsensehost4d1;
//! use adsensehost4d1::Result;
//! # #[test] fn egal() {
//! use std::default::Default;
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
//! use adsensehost4d1::AdSenseHost;
//!
//! // 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 = AdSenseHost::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.accounts().reports_generate("accountId", "startDate", "endDate")
//! .start_index(92)
//! .add_sort("nonumy")
//! .add_metric("dolores")
//! .max_results(40)
//! .locale("sadipscing")
//! .add_filter("aliquyam")
//! .add_dimension("ea")
//! .doit();
//!
//! match result {
//! Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
//! Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
//! Result::MissingToken => println!("OAuth2: Missing Token"),
//! Result::Cancelled => println!("Operation cancelled by user"),
//! Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
//! Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
//! Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
//! Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
//! Result::Success(_) => 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 Downlods
//! 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 identifyable 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(core,io,thread_sleep)]
// 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)]
#![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;
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, ResourceMethodsBuilder, 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 AdSense host data and associated accounts
Full,
}
impl Str for Scope {
fn as_slice(&self) -> &str {
match *self {
Scope::Full => "https://www.googleapis.com/auth/adsensehost",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::Full
}
}
// ########
// HUB ###
// ######
/// Central instance to access all AdSenseHost related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::Result;
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// // 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 = AdSenseHost::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.accounts().reports_generate("accountId", "startDate", "endDate")
/// .start_index(67)
/// .add_sort("et")
/// .add_metric("diam")
/// .max_results(46)
/// .locale("Lorem")
/// .add_filter("et")
/// .add_dimension("duo")
/// .doit();
///
/// match result {
/// Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
/// Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
/// Result::MissingToken => println!("OAuth2: Missing Token"),
/// Result::Cancelled => println!("Operation cancelled by user"),
/// Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
/// Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
/// Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
/// Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
/// Result::Success(_) => println!("Success (value doesn't print)"),
/// }
/// # }
/// ```
pub struct AdSenseHost<C, NC, A> {
client: RefCell<C>,
auth: RefCell<A>,
_user_agent: String,
_m: PhantomData<NC>
}
impl<'a, C, NC, A> Hub for AdSenseHost<C, NC, A> {}
impl<'a, C, NC, A> AdSenseHost<C, NC, A>
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
pub fn new(client: C, authenticator: A) -> AdSenseHost<C, NC, A> {
AdSenseHost {
client: RefCell::new(client),
auth: RefCell::new(authenticator),
_user_agent: "google-api-rust-client/0.1.1".to_string(),
_m: PhantomData
}
}
pub fn accounts(&'a self) -> AccountMethods<'a, C, NC, A> {
AccountMethods { hub: &self }
}
pub fn adclients(&'a self) -> AdclientMethods<'a, C, NC, A> {
AdclientMethods { hub: &self }
}
pub fn associationsessions(&'a self) -> AssociationsessionMethods<'a, C, NC, A> {
AssociationsessionMethods { hub: &self }
}
pub fn customchannels(&'a self) -> CustomchannelMethods<'a, C, NC, A> {
CustomchannelMethods { hub: &self }
}
pub fn reports(&'a self) -> ReportMethods<'a, C, NC, A> {
ReportMethods { hub: &self }
}
pub fn urlchannels(&'a self) -> UrlchannelMethods<'a, C, NC, A> {
UrlchannelMethods { 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.1`.
///
/// 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 ###
// ##########
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list urlchannels](struct.UrlchannelListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct UrlChannels {
/// Continuation token used to page through URL channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// The URL channels returned in this list response.
pub items: Vec<UrlChannel>,
/// Kind of list this is, in this case adsensehost#urlChannels.
pub kind: String,
/// ETag of this response for caching purposes.
pub etag: String,
}
impl ResponseResult for UrlChannels {}
/// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct ReportHeaders {
/// The currency of this column. Only present if the header type is METRIC_CURRENCY.
pub currency: String,
/// The type of the header; one of DIMENSION, METRIC_TALLY, METRIC_RATIO, or METRIC_CURRENCY.
#[serde(alias="type")]
pub type_: String,
/// The name of the header.
pub name: String,
}
impl NestedType for ReportHeaders {}
impl Part for ReportHeaders {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [adunits get accounts](struct.AccountAdunitGetCall.html) (none)
/// * [get accounts](struct.AccountGetCall.html) (response)
/// * [adunits list accounts](struct.AccountAdunitListCall.html) (none)
/// * [adunits get ad code accounts](struct.AccountAdunitGetAdCodeCall.html) (none)
/// * [reports generate accounts](struct.AccountReportGenerateCall.html) (none)
/// * [adunits delete accounts](struct.AccountAdunitDeleteCall.html) (none)
/// * [adunits update accounts](struct.AccountAdunitUpdateCall.html) (none)
/// * [adunits patch accounts](struct.AccountAdunitPatchCall.html) (none)
/// * [adunits insert accounts](struct.AccountAdunitInsertCall.html) (none)
/// * [list accounts](struct.AccountListCall.html) (none)
/// * [adclients list accounts](struct.AccountAdclientListCall.html) (none)
/// * [adclients get accounts](struct.AccountAdclientGetCall.html) (none)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Account {
/// Approval status of this account. One of: PENDING, APPROVED, DISABLED.
pub status: String,
/// Kind of resource this is, in this case adsensehost#account.
pub kind: String,
/// Unique identifier of this account.
pub id: String,
/// Name of this account.
pub name: String,
}
impl Resource for Account {}
impl ResponseResult for Account {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [adunits list accounts](struct.AccountAdunitListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AdUnits {
/// Continuation token used to page through ad units. To retrieve the next page of results, set the next request's "pageToken" value to this.
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// The ad units returned in this list response.
pub items: Vec<AdUnit>,
/// Kind of list this is, in this case adsensehost#adUnits.
pub kind: String,
/// ETag of this response for caching purposes.
pub etag: String,
}
impl ResponseResult for AdUnits {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list adclients](struct.AdclientListCall.html) (response)
/// * [adclients list accounts](struct.AccountAdclientListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AdClients {
/// Continuation token used to page through ad clients. To retrieve the next page of results, set the next request's "pageToken" value to this.
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// The ad clients returned in this list response.
pub items: Vec<AdClient>,
/// Kind of list this is, in this case adsensehost#adClients.
pub kind: String,
/// ETag of this response for caching purposes.
pub etag: String,
}
impl ResponseResult for AdClients {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdStyle {
/// The style of the corners in the ad. Possible values are SQUARE, SLIGHTLY_ROUNDED and VERY_ROUNDED.
pub corners: String,
/// The colors included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
pub colors: AdStyleColors,
/// The font which is included in the style.
pub font: AdStyleFont,
/// Kind this is, in this case adsensehost#adStyle.
pub kind: String,
}
impl Part for AdStyle {}
/// The colors included in the style. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdStyleColors {
/// The color of the ad url.
pub url: String,
/// The color of the ad text.
pub text: String,
/// The color of the ad border.
pub border: String,
/// The color of the ad background.
pub background: String,
/// The color of the ad title.
pub title: String,
}
impl NestedType for AdStyleColors {}
impl Part for AdStyleColors {}
/// Settings specific to WAP mobile content ads (AFMC).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdUnitMobileContentAdsSettings {
/// The scripting language to use for this ad unit.
#[serde(alias="scriptingLanguage")]
pub scripting_language: String,
/// The markup language to use for this ad unit.
#[serde(alias="markupLanguage")]
pub markup_language: String,
/// Type of this ad unit.
#[serde(alias="type")]
pub type_: String,
/// Size of this ad unit.
pub size: String,
}
impl NestedType for AdUnitMobileContentAdsSettings {}
impl Part for AdUnitMobileContentAdsSettings {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [adunits get ad code accounts](struct.AccountAdunitGetAdCodeCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AdCode {
/// The ad code snippet.
#[serde(alias="adCode")]
pub ad_code: String,
/// Kind this is, in this case adsensehost#adCode.
pub kind: String,
}
impl ResponseResult for AdCode {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [adunits get accounts](struct.AccountAdunitGetCall.html) (response)
/// * [adunits patch accounts](struct.AccountAdunitPatchCall.html) (request|response)
/// * [adunits update accounts](struct.AccountAdunitUpdateCall.html) (request|response)
/// * [adunits delete accounts](struct.AccountAdunitDeleteCall.html) (response)
/// * [adunits insert accounts](struct.AccountAdunitInsertCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdUnit {
/// Status of this ad unit. Possible values are:
/// NEW: Indicates that the ad unit was created within the last seven days and does not yet have any activity associated with it.
///
/// ACTIVE: Indicates that there has been activity on this ad unit in the last seven days.
///
/// INACTIVE: Indicates that there has been no activity on this ad unit in the last seven days.
pub status: Option<String>,
/// Kind of resource this is, in this case adsensehost#adUnit.
pub kind: Option<String>,
/// Identity code of this ad unit, not necessarily unique across ad clients.
pub code: Option<String>,
/// Name of this ad unit.
pub name: Option<String>,
/// Settings specific to content ads (AFC) and highend mobile content ads (AFMC).
#[serde(alias="contentAdsSettings")]
pub content_ads_settings: Option<AdUnitContentAdsSettings>,
/// Unique identifier of this ad unit. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
pub id: Option<String>,
/// Settings specific to WAP mobile content ads (AFMC).
#[serde(alias="mobileContentAdsSettings")]
pub mobile_content_ads_settings: Option<AdUnitMobileContentAdsSettings>,
/// Custom style information specific to this ad unit.
#[serde(alias="customStyle")]
pub custom_style: Option<AdStyle>,
}
impl RequestValue for AdUnit {}
impl ResponseResult for AdUnit {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [delete urlchannels](struct.UrlchannelDeleteCall.html) (response)
/// * [insert urlchannels](struct.UrlchannelInsertCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UrlChannel {
/// Kind of resource this is, in this case adsensehost#urlChannel.
pub kind: Option<String>,
/// Unique identifier of this URL channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
pub id: Option<String>,
/// URL Pattern of this URL channel. Does not include "http://" or "https://". Example: www.example.com/home
#[serde(alias="urlPattern")]
pub url_pattern: Option<String>,
}
impl RequestValue for UrlChannel {}
impl Resource for UrlChannel {}
impl ResponseResult for UrlChannel {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [get adclients](struct.AdclientGetCall.html) (response)
/// * [adclients get accounts](struct.AccountAdclientGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AdClient {
/// This ad client's product code, which corresponds to the PRODUCT_CODE report dimension.
#[serde(alias="productCode")]
pub product_code: String,
/// Kind of resource this is, in this case adsensehost#adClient.
pub kind: String,
/// Unique identifier of this ad client.
pub id: String,
/// Whether this ad client is opted in to ARC.
#[serde(alias="arcOptIn")]
pub arc_opt_in: bool,
/// Whether this ad client supports being reported on.
#[serde(alias="supportsReporting")]
pub supports_reporting: bool,
}
impl Resource for AdClient {}
impl ResponseResult for AdClient {}
/// The backup option to be used in instances where no ad is available.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdUnitContentAdsSettingsBackupOption {
/// Color to use when type is set to COLOR. These are represented as six hexadecimal characters, similar to HTML color codes, but without the leading hash.
pub color: String,
/// URL to use when type is set to URL.
pub url: String,
/// Type of the backup option. Possible values are BLANK, COLOR and URL.
#[serde(alias="type")]
pub type_: String,
}
impl NestedType for AdUnitContentAdsSettingsBackupOption {}
impl Part for AdUnitContentAdsSettingsBackupOption {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [verify associationsessions](struct.AssociationsessionVerifyCall.html) (response)
/// * [start associationsessions](struct.AssociationsessionStartCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AssociationSession {
/// Status of the completed association, available once the association callback token has been verified. One of ACCEPTED, REJECTED, or ERROR.
pub status: String,
/// The products to associate with the user. Options: AFC, AFF, AFS, AFMC
#[serde(alias="productCodes")]
pub product_codes: Vec<String>,
/// Kind of resource this is, in this case adsensehost#associationSession.
pub kind: String,
/// The preferred locale of the user themselves when going through the AdSense association flow.
#[serde(alias="userLocale")]
pub user_locale: String,
/// The locale of the user's hosted website.
#[serde(alias="websiteLocale")]
pub website_locale: String,
/// Redirect URL of this association session. Used to redirect users into the AdSense association flow.
#[serde(alias="redirectUrl")]
pub redirect_url: String,
/// The URL of the user's hosted website.
#[serde(alias="websiteUrl")]
pub website_url: String,
/// Unique identifier of this association session.
pub id: String,
/// Hosted account id of the associated publisher after association. Present if status is ACCEPTED.
#[serde(alias="accountId")]
pub account_id: String,
}
impl Resource for AssociationSession {}
impl ResponseResult for AssociationSession {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list accounts](struct.AccountListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Accounts {
/// The accounts returned in this list response.
pub items: Vec<Account>,
/// Kind of list this is, in this case adsensehost#accounts.
pub kind: String,
/// ETag of this response for caching purposes.
pub etag: String,
}
impl ResponseResult for Accounts {}
/// Settings specific to content ads (AFC) and highend mobile content ads (AFMC).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdUnitContentAdsSettings {
/// Type of this ad unit. Possible values are TEXT, TEXT_IMAGE, IMAGE and LINK.
#[serde(alias="type")]
pub type_: String,
/// The backup option to be used in instances where no ad is available.
#[serde(alias="backupOption")]
pub backup_option: AdUnitContentAdsSettingsBackupOption,
/// Size of this ad unit. Size values are in the form SIZE_{width}_{height}.
pub size: String,
}
impl NestedType for AdUnitContentAdsSettings {}
impl Part for AdUnitContentAdsSettings {}
/// The font which is included in the style.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdStyleFont {
/// The family of the font. Possible values are: ACCOUNT_DEFAULT_FAMILY, ADSENSE_DEFAULT_FAMILY, ARIAL, TIMES and VERDANA.
pub family: String,
/// The size of the font. Possible values are: ACCOUNT_DEFAULT_SIZE, ADSENSE_DEFAULT_SIZE, SMALL, MEDIUM and LARGE.
pub size: String,
}
impl NestedType for AdStyleFont {}
impl Part for AdStyleFont {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [reports generate accounts](struct.AccountReportGenerateCall.html) (response)
/// * [generate reports](struct.ReportGenerateCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Report {
/// The header information of the columns requested in the report. This is a list of headers; one for each dimension in the request, followed by one for each metric in the request.
pub headers: Vec<ReportHeaders>,
/// Kind this is, in this case adsensehost#report.
pub kind: String,
/// The output rows of the report. Each row is a list of cells; one for each dimension in the request, followed by one for each metric in the request. The dimension cells contain strings, and the metric cells contain numbers.
pub rows: Vec<Vec<String>>,
/// The total number of rows matched by the report request. Fewer rows may be returned in the response due to being limited by the row count requested or the report row limit.
#[serde(alias="totalMatchedRows")]
pub total_matched_rows: String,
/// Any warnings associated with generation of the report.
pub warnings: Vec<String>,
/// The averages of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
pub averages: Vec<String>,
/// The totals of the report. This is the same length as any other row in the report; cells corresponding to dimension columns are empty.
pub totals: Vec<String>,
}
impl Resource for Report {}
impl ResponseResult for Report {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [get customchannels](struct.CustomchannelGetCall.html) (response)
/// * [update customchannels](struct.CustomchannelUpdateCall.html) (request|response)
/// * [delete customchannels](struct.CustomchannelDeleteCall.html) (response)
/// * [insert customchannels](struct.CustomchannelInsertCall.html) (request|response)
/// * [patch customchannels](struct.CustomchannelPatchCall.html) (request|response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct CustomChannel {
/// Kind of resource this is, in this case adsensehost#customChannel.
pub kind: Option<String>,
/// Code of this custom channel, not necessarily unique across ad clients.
pub code: Option<String>,
/// Unique identifier of this custom channel. This should be considered an opaque identifier; it is not safe to rely on it being in any particular format.
pub id: Option<String>,
/// Name of this custom channel.
pub name: Option<String>,
}
impl RequestValue for CustomChannel {}
impl Resource for CustomChannel {}
impl ResponseResult for CustomChannel {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [list customchannels](struct.CustomchannelListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct CustomChannels {
/// Continuation token used to page through custom channels. To retrieve the next page of results, set the next request's "pageToken" value to this.
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// The custom channels returned in this list response.
pub items: Vec<CustomChannel>,
/// Kind of list this is, in this case adsensehost#customChannels.
pub kind: String,
/// ETag of this response for caching purposes.
pub etag: String,
}
impl ResponseResult for CustomChannels {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *urlchannel* resources.
/// It is not used directly, but through the `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `insert(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.urlchannels();
/// # }
/// ```
pub struct UrlchannelMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder for UrlchannelMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> UrlchannelMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// Add a new URL channel to the host AdSense account.
pub fn insert(&self, request: &UrlChannel, ad_client_id: &str) -> UrlchannelInsertCall<'a, C, NC, A> {
UrlchannelInsertCall {
hub: self.hub,
_request: request.clone(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete a URL channel from the host AdSense account.
pub fn delete(&self, ad_client_id: &str, url_channel_id: &str) -> UrlchannelDeleteCall<'a, C, NC, A> {
UrlchannelDeleteCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_url_channel_id: url_channel_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all host URL channels in the host AdSense account.
pub fn list(&self, ad_client_id: &str) -> UrlchannelListCall<'a, C, NC, A> {
UrlchannelListCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *adclient* resources.
/// It is not used directly, but through the `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `get(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.adclients();
/// # }
/// ```
pub struct AdclientMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder for AdclientMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> AdclientMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// List all host ad clients in this AdSense account.
pub fn list(&self) -> AdclientListCall<'a, C, NC, A> {
AdclientListCall {
hub: self.hub,
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get information about one of the ad clients in the Host AdSense account.
pub fn get(&self, ad_client_id: &str) -> AdclientGetCall<'a, C, NC, A> {
AdclientGetCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *associationsession* resources.
/// It is not used directly, but through the `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `start(...)` and `verify(...)`
/// // to build up your call.
/// let rb = hub.associationsessions();
/// # }
/// ```
pub struct AssociationsessionMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder for AssociationsessionMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> AssociationsessionMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// Create an association session for initiating an association with an AdSense user.
pub fn start(&self, product_code: &Vec<String>, website_url: &str) -> AssociationsessionStartCall<'a, C, NC, A> {
AssociationsessionStartCall {
hub: self.hub,
_product_code: product_code.clone(),
_website_url: website_url.to_string(),
_website_locale: Default::default(),
_user_locale: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Verify an association session after the association callback returns from AdSense signup.
pub fn verify(&self, token: &str) -> AssociationsessionVerifyCall<'a, C, NC, A> {
AssociationsessionVerifyCall {
hub: self.hub,
_token: token.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 `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `generate(...)`
/// // 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 AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder 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:
///
/// Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
pub fn generate(&self, start_date: &str, end_date: &str) -> ReportGenerateCall<'a, C, NC, A> {
ReportGenerateCall {
hub: self.hub,
_start_date: start_date.to_string(),
_end_date: end_date.to_string(),
_start_index: Default::default(),
_sort: Default::default(),
_metric: Default::default(),
_max_results: Default::default(),
_locale: Default::default(),
_filter: Default::default(),
_dimension: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *account* resources.
/// It is not used directly, but through the `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `adclients_get(...)`, `adclients_list(...)`, `adunits_delete(...)`, `adunits_get(...)`, `adunits_get_ad_code(...)`, `adunits_insert(...)`, `adunits_list(...)`, `adunits_patch(...)`, `adunits_update(...)`, `get(...)`, `list(...)` and `reports_generate(...)`
/// // to build up your call.
/// let rb = hub.accounts();
/// # }
/// ```
pub struct AccountMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder for AccountMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// List all ad units in the specified publisher's AdSense account.
pub fn adunits_list(&self, account_id: &str, ad_client_id: &str) -> AccountAdunitListCall<'a, C, NC, A> {
AccountAdunitListCall {
hub: self.hub,
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_include_inactive: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List hosted accounts associated with this AdSense account by ad client id.
pub fn list(&self, filter_ad_client_id: &Vec<String>) -> AccountListCall<'a, C, NC, A> {
AccountListCall {
hub: self.hub,
_filter_ad_client_id: filter_ad_client_id.clone(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get ad code for the specified ad unit, attaching the specified host custom channels.
pub fn adunits_get_ad_code(&self, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitGetAdCodeCall<'a, C, NC, A> {
AccountAdunitGetAdCodeCall {
hub: self.hub,
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_ad_unit_id: ad_unit_id.to_string(),
_host_custom_channel_id: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
pub fn reports_generate(&self, account_id: &str, start_date: &str, end_date: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
AccountReportGenerateCall {
hub: self.hub,
_account_id: account_id.to_string(),
_start_date: start_date.to_string(),
_end_date: end_date.to_string(),
_start_index: Default::default(),
_sort: Default::default(),
_metric: Default::default(),
_max_results: Default::default(),
_locale: Default::default(),
_filter: Default::default(),
_dimension: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete the specified ad unit from the specified publisher AdSense account.
pub fn adunits_delete(&self, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitDeleteCall<'a, C, NC, A> {
AccountAdunitDeleteCall {
hub: self.hub,
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_ad_unit_id: ad_unit_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all hosted ad clients in the specified hosted account.
pub fn adclients_list(&self, account_id: &str) -> AccountAdclientListCall<'a, C, NC, A> {
AccountAdclientListCall {
hub: self.hub,
_account_id: account_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the supplied ad unit in the specified publisher AdSense account. This method supports patch semantics.
pub fn adunits_patch(&self, request: &AdUnit, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitPatchCall<'a, C, NC, A> {
AccountAdunitPatchCall {
hub: self.hub,
_request: request.clone(),
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_ad_unit_id: ad_unit_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get information about one of the ad clients in the specified publisher's AdSense account.
pub fn adclients_get(&self, account_id: &str, ad_client_id: &str) -> AccountAdclientGetCall<'a, C, NC, A> {
AccountAdclientGetCall {
hub: self.hub,
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get information about the selected associated AdSense account.
pub fn get(&self, account_id: &str) -> AccountGetCall<'a, C, NC, A> {
AccountGetCall {
hub: self.hub,
_account_id: account_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Insert the supplied ad unit into the specified publisher AdSense account.
pub fn adunits_insert(&self, request: &AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitInsertCall<'a, C, NC, A> {
AccountAdunitInsertCall {
hub: self.hub,
_request: request.clone(),
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Get the specified host ad unit in this AdSense account.
pub fn adunits_get(&self, account_id: &str, ad_client_id: &str, ad_unit_id: &str) -> AccountAdunitGetCall<'a, C, NC, A> {
AccountAdunitGetCall {
hub: self.hub,
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_ad_unit_id: ad_unit_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the supplied ad unit in the specified publisher AdSense account.
pub fn adunits_update(&self, request: &AdUnit, account_id: &str, ad_client_id: &str) -> AccountAdunitUpdateCall<'a, C, NC, A> {
AccountAdunitUpdateCall {
hub: self.hub,
_request: request.clone(),
_account_id: account_id.to_string(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *customchannel* resources.
/// It is not used directly, but through the `AdSenseHost` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate "yup-oauth2" as oauth2;
/// extern crate "google-adsensehost4d1" as adsensehost4d1;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use adsensehost4d1::AdSenseHost;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AdSenseHost::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.customchannels();
/// # }
/// ```
pub struct CustomchannelMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
}
impl<'a, C, NC, A> ResourceMethodsBuilder for CustomchannelMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// Get a specific custom channel from the host AdSense account.
pub fn get(&self, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelGetCall<'a, C, NC, A> {
CustomchannelGetCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_custom_channel_id: custom_channel_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Delete a specific custom channel from the host AdSense account.
pub fn delete(&self, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelDeleteCall<'a, C, NC, A> {
CustomchannelDeleteCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_custom_channel_id: custom_channel_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update a custom channel in the host AdSense account.
pub fn update(&self, request: &CustomChannel, ad_client_id: &str) -> CustomchannelUpdateCall<'a, C, NC, A> {
CustomchannelUpdateCall {
hub: self.hub,
_request: request.clone(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// List all host custom channels in this AdSense account.
pub fn list(&self, ad_client_id: &str) -> CustomchannelListCall<'a, C, NC, A> {
CustomchannelListCall {
hub: self.hub,
_ad_client_id: ad_client_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update a custom channel in the host AdSense account. This method supports patch semantics.
pub fn patch(&self, request: &CustomChannel, ad_client_id: &str, custom_channel_id: &str) -> CustomchannelPatchCall<'a, C, NC, A> {
CustomchannelPatchCall {
hub: self.hub,
_request: request.clone(),
_ad_client_id: ad_client_id.to_string(),
_custom_channel_id: custom_channel_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Add a new custom channel to the host AdSense account.
pub fn insert(&self, request: &CustomChannel, ad_client_id: &str) -> CustomchannelInsertCall<'a, C, NC, A> {
CustomchannelInsertCall {
hub: self.hub,
_request: request.clone(),
_ad_client_id: ad_client_id.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// Add a new URL channel to the host AdSense account.
///
/// A builder for the *insert* method supported by a *urlchannel* resource.
/// It is not used directly, but through a `UrlchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::UrlChannel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: UrlChannel = 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.urlchannels().insert(&req, "adClientId")
/// .doit();
/// # }
/// ```
pub struct UrlchannelInsertCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: UrlChannel,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for UrlchannelInsertCall<'a, C, NC, A> {}
impl<'a, C, NC, A> UrlchannelInsertCall<'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, UrlChannel)> {
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: "adsensehost.urlchannels.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/urlchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &UrlChannel) -> UrlchannelInsertCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client to which the new URL channel will be added.
pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelInsertCall<'a, C, NC, A> {
self._ad_client_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) -> UrlchannelInsertCall<'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) -> UrlchannelInsertCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> UrlchannelInsertCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Delete a URL channel from the host AdSense account.
///
/// A builder for the *delete* method supported by a *urlchannel* resource.
/// It is not used directly, but through a `UrlchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.urlchannels().delete("adClientId", "urlChannelId")
/// .doit();
/// # }
/// ```
pub struct UrlchannelDeleteCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_url_channel_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for UrlchannelDeleteCall<'a, C, NC, A> {}
impl<'a, C, NC, A> UrlchannelDeleteCall<'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, UrlChannel)> {
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: "adsensehost.urlchannels.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("urlChannelId", self._url_channel_id.to_string()));
for &field in ["alt", "adClientId", "urlChannelId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/urlchannels/{urlChannelId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId"), ("{urlChannelId}", "urlChannelId")].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 ["adClientId", "urlChannelId"].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_slice()))));
}
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 Result::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::Delete, url.as_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client from which to delete the URL channel.
pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelDeleteCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *url channel id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// URL channel to delete.
pub fn url_channel_id(mut self, new_value: &str) -> UrlchannelDeleteCall<'a, C, NC, A> {
self._url_channel_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) -> UrlchannelDeleteCall<'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) -> UrlchannelDeleteCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> UrlchannelDeleteCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List all host URL channels in the host AdSense account.
///
/// A builder for the *list* method supported by a *urlchannel* resource.
/// It is not used directly, but through a `UrlchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.urlchannels().list("adClientId")
/// .page_token("erat")
/// .max_results(6)
/// .doit();
/// # }
/// ```
pub struct UrlchannelListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for UrlchannelListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> UrlchannelListCall<'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, UrlChannels)> {
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: "adsensehost.urlchannels.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/urlchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client for which to list URL channels.
pub fn ad_client_id(mut self, new_value: &str) -> UrlchannelListCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
/// A continuation token, used to page through URL channels. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
pub fn page_token(mut self, new_value: &str) -> UrlchannelListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of URL channels to include in the response, used for paging.
pub fn max_results(mut self, new_value: u32) -> UrlchannelListCall<'a, C, NC, A> {
self._max_results = Some(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) -> UrlchannelListCall<'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) -> UrlchannelListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> UrlchannelListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List all host ad clients in this AdSense account.
///
/// A builder for the *list* method supported by a *adclient* resource.
/// It is not used directly, but through a `AdclientMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.adclients().list()
/// .page_token("dolor")
/// .max_results(62)
/// .doit();
/// # }
/// ```
pub struct AdclientListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AdclientListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AdclientListCall<'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, AdClients)> {
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: "adsensehost.adclients.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *page token* query property to the given value.
///
///
/// A continuation token, used to page through ad clients. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
pub fn page_token(mut self, new_value: &str) -> AdclientListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of ad clients to include in the response, used for paging.
pub fn max_results(mut self, new_value: u32) -> AdclientListCall<'a, C, NC, A> {
self._max_results = Some(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) -> AdclientListCall<'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) -> AdclientListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AdclientListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get information about one of the ad clients in the Host AdSense account.
///
/// A builder for the *get* method supported by a *adclient* resource.
/// It is not used directly, but through a `AdclientMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.adclients().get("adClientId")
/// .doit();
/// # }
/// ```
pub struct AdclientGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AdclientGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AdclientGetCall<'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, AdClient)> {
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: "adsensehost.adclients.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client to get.
pub fn ad_client_id(mut self, new_value: &str) -> AdclientGetCall<'a, C, NC, A> {
self._ad_client_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) -> AdclientGetCall<'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) -> AdclientGetCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AdclientGetCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Create an association session for initiating an association with an AdSense user.
///
/// A builder for the *start* method supported by a *associationsession* resource.
/// It is not used directly, but through a `AssociationsessionMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.associationsessions().start("productCode", "websiteUrl")
/// .website_locale("labore")
/// .user_locale("eirmod")
/// .doit();
/// # }
/// ```
pub struct AssociationsessionStartCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_product_code: Vec<String>,
_website_url: String,
_website_locale: Option<String>,
_user_locale: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AssociationsessionStartCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AssociationsessionStartCall<'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, AssociationSession)> {
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: "adsensehost.associationsessions.start",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
if self._product_code.len() > 0 {
let mut s = String::new();
for f in self._product_code.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("productCode", s));
}
params.push(("websiteUrl", self._website_url.to_string()));
if let Some(value) = self._website_locale {
params.push(("websiteLocale", value.to_string()));
}
if let Some(value) = self._user_locale {
params.push(("userLocale", value.to_string()));
}
for &field in ["alt", "productCode", "websiteUrl", "websiteLocale", "userLocale"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/associationsessions/start".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Append the given value to the *product code* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Products to associate with the user.
pub fn add_product_code(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C, NC, A> {
self._product_code.push(new_value.to_string());
self
}
/// Sets the *website url* 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 URL of the user's hosted website.
pub fn website_url(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C, NC, A> {
self._website_url = new_value.to_string();
self
}
/// Sets the *website locale* query property to the given value.
///
///
/// The locale of the user's hosted website.
pub fn website_locale(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C, NC, A> {
self._website_locale = Some(new_value.to_string());
self
}
/// Sets the *user locale* query property to the given value.
///
///
/// The preferred locale of the user.
pub fn user_locale(mut self, new_value: &str) -> AssociationsessionStartCall<'a, C, NC, A> {
self._user_locale = 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) -> AssociationsessionStartCall<'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) -> AssociationsessionStartCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AssociationsessionStartCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Verify an association session after the association callback returns from AdSense signup.
///
/// A builder for the *verify* method supported by a *associationsession* resource.
/// It is not used directly, but through a `AssociationsessionMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.associationsessions().verify("token")
/// .doit();
/// # }
/// ```
pub struct AssociationsessionVerifyCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_token: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AssociationsessionVerifyCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AssociationsessionVerifyCall<'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, AssociationSession)> {
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: "adsensehost.associationsessions.verify",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("token", self._token.to_string()));
for &field in ["alt", "token"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/associationsessions/verify".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *token* 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 token returned to the association callback URL.
pub fn token(mut self, new_value: &str) -> AssociationsessionVerifyCall<'a, C, NC, A> {
self._token = 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) -> AssociationsessionVerifyCall<'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) -> AssociationsessionVerifyCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AssociationsessionVerifyCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
///
/// A builder for the *generate* method supported by a *report* resource.
/// It is not used directly, but through a `ReportMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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().generate("startDate", "endDate")
/// .start_index(28)
/// .add_sort("Lorem")
/// .add_metric("sea")
/// .max_results(80)
/// .locale("duo")
/// .add_filter("et")
/// .add_dimension("eirmod")
/// .doit();
/// # }
/// ```
pub struct ReportGenerateCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_start_date: String,
_end_date: String,
_start_index: Option<u32>,
_sort: Vec<String>,
_metric: Vec<String>,
_max_results: Option<u32>,
_locale: Option<String>,
_filter: Vec<String>,
_dimension: Vec<String>,
_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: "adsensehost.reports.generate",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((11 + self._additional_params.len()));
params.push(("startDate", self._start_date.to_string()));
params.push(("endDate", self._end_date.to_string()));
if let Some(value) = self._start_index {
params.push(("startIndex", value.to_string()));
}
if self._sort.len() > 0 {
let mut s = String::new();
for f in self._sort.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("sort", s));
}
if self._metric.len() > 0 {
let mut s = String::new();
for f in self._metric.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("metric", s));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._locale {
params.push(("locale", value.to_string()));
}
if self._filter.len() > 0 {
let mut s = String::new();
for f in self._filter.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("filter", s));
}
if self._dimension.len() > 0 {
let mut s = String::new();
for f in self._dimension.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("dimension", s));
}
for &field in ["alt", "startDate", "endDate", "startIndex", "sort", "metric", "maxResults", "locale", "filter", "dimension"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/reports".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// 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.
///
/// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
pub fn start_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._start_date = 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.
///
/// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
pub fn end_date(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._end_date = new_value.to_string();
self
}
/// Sets the *start index* query property to the given value.
///
///
/// Index of the first row of report data to return.
pub fn start_index(mut self, new_value: u32) -> ReportGenerateCall<'a, C, NC, A> {
self._start_index = Some(new_value);
self
}
/// Append the given value to the *sort* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// The name of a dimension or metric to sort the resulting report on, optionally prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
pub fn add_sort(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._sort.push(new_value.to_string());
self
}
/// Append the given value to the *metric* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Numeric columns to include in the report.
pub fn add_metric(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._metric.push(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of rows of report data to return.
pub fn max_results(mut self, new_value: u32) -> ReportGenerateCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *locale* query property to the given value.
///
///
/// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
pub fn locale(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._locale = Some(new_value.to_string());
self
}
/// Append the given value to the *filter* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Filters to be run on the report.
pub fn add_filter(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._filter.push(new_value.to_string());
self
}
/// Append the given value to the *dimension* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Dimensions to base the report on.
pub fn add_dimension(mut self, new_value: &str) -> ReportGenerateCall<'a, C, NC, A> {
self._dimension.push(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) -> 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: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List all ad units in the specified publisher's AdSense account.
///
/// A builder for the *adunits.list* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adunits_list("accountId", "adClientId")
/// .page_token("amet")
/// .max_results(78)
/// .include_inactive(true)
/// .doit();
/// # }
/// ```
pub struct AccountAdunitListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_ad_client_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_include_inactive: Option<bool>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitListCall<'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, AdUnits)> {
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: "adsensehost.accounts.adunits.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((7 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._include_inactive {
params.push(("includeInactive", value.to_string()));
}
for &field in ["alt", "accountId", "adClientId", "pageToken", "maxResults", "includeInactive"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].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 ["accountId", "adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad client.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client for which to list ad units.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitListCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
/// A continuation token, used to page through ad units. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
pub fn page_token(mut self, new_value: &str) -> AccountAdunitListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of ad units to include in the response, used for paging.
pub fn max_results(mut self, new_value: u32) -> AccountAdunitListCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *include inactive* query property to the given value.
///
///
/// Whether to include inactive ad units. Default: true.
pub fn include_inactive(mut self, new_value: bool) -> AccountAdunitListCall<'a, C, NC, A> {
self._include_inactive = Some(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) -> AccountAdunitListCall<'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) -> AccountAdunitListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List hosted accounts associated with this AdSense account by ad client id.
///
/// A builder for the *list* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().list("filterAdClientId")
/// .doit();
/// # }
/// ```
pub struct AccountListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_filter_ad_client_id: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountListCall<'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, Accounts)> {
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: "adsensehost.accounts.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
if self._filter_ad_client_id.len() > 0 {
let mut s = String::new();
for f in self._filter_ad_client_id.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("filterAdClientId", s));
}
for &field in ["alt", "filterAdClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Append the given value to the *filter ad client id* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad clients to list accounts for.
pub fn add_filter_ad_client_id(mut self, new_value: &str) -> AccountListCall<'a, C, NC, A> {
self._filter_ad_client_id.push(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) -> AccountListCall<'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) -> AccountListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get ad code for the specified ad unit, attaching the specified host custom channels.
///
/// A builder for the *adunits.getAdCode* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adunits_get_ad_code("accountId", "adClientId", "adUnitId")
/// .add_host_custom_channel_id("dolor")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitGetAdCodeCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_ad_client_id: String,
_ad_unit_id: String,
_host_custom_channel_id: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitGetAdCodeCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitGetAdCodeCall<'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, AdCode)> {
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: "adsensehost.accounts.adunits.getAdCode",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("adUnitId", self._ad_unit_id.to_string()));
if self._host_custom_channel_id.len() > 0 {
let mut s = String::new();
for f in self._host_custom_channel_id.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("hostCustomChannelId", s));
}
for &field in ["alt", "accountId", "adClientId", "adUnitId", "hostCustomChannelId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}/adcode".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].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 ["accountId", "adClientId", "adUnitId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad client.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client with contains the ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *ad unit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad unit to get the code for.
pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C, NC, A> {
self._ad_unit_id = new_value.to_string();
self
}
/// Append the given value to the *host custom channel id* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Host custom channel to attach to the ad code.
pub fn add_host_custom_channel_id(mut self, new_value: &str) -> AccountAdunitGetAdCodeCall<'a, C, NC, A> {
self._host_custom_channel_id.push(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) -> AccountAdunitGetAdCodeCall<'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) -> AccountAdunitGetAdCodeCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitGetAdCodeCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Generate an AdSense report based on the report request sent in the query parameters. Returns the result as JSON; to retrieve output in CSV format specify "alt=csv" as a query parameter.
///
/// A builder for the *reports.generate* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().reports_generate("accountId", "startDate", "endDate")
/// .start_index(49)
/// .add_sort("voluptua.")
/// .add_metric("Lorem")
/// .max_results(90)
/// .locale("justo")
/// .add_filter("sit")
/// .add_dimension("vero")
/// .doit();
/// # }
/// ```
pub struct AccountReportGenerateCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_start_date: String,
_end_date: String,
_start_index: Option<u32>,
_sort: Vec<String>,
_metric: Vec<String>,
_max_results: Option<u32>,
_locale: Option<String>,
_filter: Vec<String>,
_dimension: Vec<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountReportGenerateCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountReportGenerateCall<'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: "adsensehost.accounts.reports.generate",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((12 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("startDate", self._start_date.to_string()));
params.push(("endDate", self._end_date.to_string()));
if let Some(value) = self._start_index {
params.push(("startIndex", value.to_string()));
}
if self._sort.len() > 0 {
let mut s = String::new();
for f in self._sort.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("sort", s));
}
if self._metric.len() > 0 {
let mut s = String::new();
for f in self._metric.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("metric", s));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
if let Some(value) = self._locale {
params.push(("locale", value.to_string()));
}
if self._filter.len() > 0 {
let mut s = String::new();
for f in self._filter.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("filter", s));
}
if self._dimension.len() > 0 {
let mut s = String::new();
for f in self._dimension.iter() {
s.push_str(&("/".to_string() + &f.to_string()));
}
params.push(("dimension", s));
}
for &field in ["alt", "accountId", "startDate", "endDate", "startIndex", "sort", "metric", "maxResults", "locale", "filter", "dimension"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/reports".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].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 ["accountId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Hosted account upon which to report.
pub fn account_id(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
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.
///
/// Start of the date range to report on in "YYYY-MM-DD" format, inclusive.
pub fn start_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._start_date = 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.
///
/// End of the date range to report on in "YYYY-MM-DD" format, inclusive.
pub fn end_date(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._end_date = new_value.to_string();
self
}
/// Sets the *start index* query property to the given value.
///
///
/// Index of the first row of report data to return.
pub fn start_index(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C, NC, A> {
self._start_index = Some(new_value);
self
}
/// Append the given value to the *sort* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// The name of a dimension or metric to sort the resulting report on, optionally prefixed with "+" to sort ascending or "-" to sort descending. If no prefix is specified, the column is sorted ascending.
pub fn add_sort(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._sort.push(new_value.to_string());
self
}
/// Append the given value to the *metric* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Numeric columns to include in the report.
pub fn add_metric(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._metric.push(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of rows of report data to return.
pub fn max_results(mut self, new_value: u32) -> AccountReportGenerateCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *locale* query property to the given value.
///
///
/// Optional locale to use for translating report output to a local language. Defaults to "en_US" if not specified.
pub fn locale(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._locale = Some(new_value.to_string());
self
}
/// Append the given value to the *filter* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Filters to be run on the report.
pub fn add_filter(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._filter.push(new_value.to_string());
self
}
/// Append the given value to the *dimension* query property.
/// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
///
///
/// Dimensions to base the report on.
pub fn add_dimension(mut self, new_value: &str) -> AccountReportGenerateCall<'a, C, NC, A> {
self._dimension.push(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) -> AccountReportGenerateCall<'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) -> AccountReportGenerateCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountReportGenerateCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Delete the specified ad unit from the specified publisher AdSense account.
///
/// A builder for the *adunits.delete* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adunits_delete("accountId", "adClientId", "adUnitId")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitDeleteCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_ad_client_id: String,
_ad_unit_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitDeleteCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitDeleteCall<'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, AdUnit)> {
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: "adsensehost.accounts.adunits.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("adUnitId", self._ad_unit_id.to_string()));
for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].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 ["accountId", "adClientId", "adUnitId"].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_slice()))));
}
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 Result::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::Delete, url.as_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad unit.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client for which to get ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *ad unit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad unit to delete.
pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitDeleteCall<'a, C, NC, A> {
self._ad_unit_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) -> AccountAdunitDeleteCall<'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) -> AccountAdunitDeleteCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitDeleteCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List all hosted ad clients in the specified hosted account.
///
/// A builder for the *adclients.list* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adclients_list("accountId")
/// .page_token("vero")
/// .max_results(6)
/// .doit();
/// # }
/// ```
pub struct AccountAdclientListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdclientListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdclientListCall<'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, AdClients)> {
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: "adsensehost.accounts.adclients.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "accountId", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].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 ["accountId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account for which to list ad clients.
pub fn account_id(mut self, new_value: &str) -> AccountAdclientListCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
/// A continuation token, used to page through ad clients. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
pub fn page_token(mut self, new_value: &str) -> AccountAdclientListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of ad clients to include in the response, used for paging.
pub fn max_results(mut self, new_value: u32) -> AccountAdclientListCall<'a, C, NC, A> {
self._max_results = Some(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) -> AccountAdclientListCall<'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) -> AccountAdclientListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdclientListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Update the supplied ad unit in the specified publisher AdSense account. This method supports patch semantics.
///
/// A builder for the *adunits.patch* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::AdUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: AdUnit = 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.accounts().adunits_patch(&req, "accountId", "adClientId", "adUnitId")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitPatchCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: AdUnit,
_account_id: String,
_ad_client_id: String,
_ad_unit_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitPatchCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitPatchCall<'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, AdUnit)> {
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: "adsensehost.accounts.adunits.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("adUnitId", self._ad_unit_id.to_string()));
for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].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 ["accountId", "adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &AdUnit) -> AccountAdunitPatchCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad client.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client which contains the ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *ad unit 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.
///
/// Ad unit to get.
pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitPatchCall<'a, C, NC, A> {
self._ad_unit_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) -> AccountAdunitPatchCall<'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) -> AccountAdunitPatchCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitPatchCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get information about one of the ad clients in the specified publisher's AdSense account.
///
/// A builder for the *adclients.get* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adclients_get("accountId", "adClientId")
/// .doit();
/// # }
/// ```
pub struct AccountAdclientGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdclientGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdclientGetCall<'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, AdClient)> {
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: "adsensehost.accounts.adclients.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "accountId", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].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 ["accountId", "adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad client.
pub fn account_id(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client to get.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdclientGetCall<'a, C, NC, A> {
self._ad_client_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) -> AccountAdclientGetCall<'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) -> AccountAdclientGetCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdclientGetCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get information about the selected associated AdSense account.
///
/// A builder for the *get* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().get("accountId")
/// .doit();
/// # }
/// ```
pub struct AccountGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountGetCall<'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, Account)> {
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: "adsensehost.accounts.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
for &field in ["alt", "accountId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId")].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 ["accountId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account to get information about.
pub fn account_id(mut self, new_value: &str) -> AccountGetCall<'a, C, NC, A> {
self._account_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) -> AccountGetCall<'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) -> AccountGetCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountGetCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Insert the supplied ad unit into the specified publisher AdSense account.
///
/// A builder for the *adunits.insert* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::AdUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: AdUnit = 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.accounts().adunits_insert(&req, "accountId", "adClientId")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitInsertCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: AdUnit,
_account_id: String,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitInsertCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitInsertCall<'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, AdUnit)> {
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: "adsensehost.accounts.adunits.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "accountId", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].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 ["accountId", "adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &AdUnit) -> AccountAdunitInsertCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which will contain the ad unit.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitInsertCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client into which to insert the ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitInsertCall<'a, C, NC, A> {
self._ad_client_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) -> AccountAdunitInsertCall<'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) -> AccountAdunitInsertCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitInsertCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get the specified host ad unit in this AdSense account.
///
/// A builder for the *adunits.get* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.accounts().adunits_get("accountId", "adClientId", "adUnitId")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_account_id: String,
_ad_client_id: String,
_ad_unit_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitGetCall<'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, AdUnit)> {
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: "adsensehost.accounts.adunits.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("adUnitId", self._ad_unit_id.to_string()));
for &field in ["alt", "accountId", "adClientId", "adUnitId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits/{adUnitId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId"), ("{adUnitId}", "adUnitId")].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 ["accountId", "adClientId", "adUnitId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad unit.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client for which to get ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *ad unit id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad unit to get.
pub fn ad_unit_id(mut self, new_value: &str) -> AccountAdunitGetCall<'a, C, NC, A> {
self._ad_unit_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) -> AccountAdunitGetCall<'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) -> AccountAdunitGetCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitGetCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Update the supplied ad unit in the specified publisher AdSense account.
///
/// A builder for the *adunits.update* method supported by a *account* resource.
/// It is not used directly, but through a `AccountMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::AdUnit;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: AdUnit = 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.accounts().adunits_update(&req, "accountId", "adClientId")
/// .doit();
/// # }
/// ```
pub struct AccountAdunitUpdateCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: AdUnit,
_account_id: String,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AccountAdunitUpdateCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AccountAdunitUpdateCall<'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, AdUnit)> {
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: "adsensehost.accounts.adunits.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("accountId", self._account_id.to_string()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "accountId", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/accounts/{accountId}/adclients/{adClientId}/adunits".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{accountId}", "accountId"), ("{adClientId}", "adClientId")].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 ["accountId", "adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &AdUnit) -> AccountAdunitUpdateCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *account id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Account which contains the ad client.
pub fn account_id(mut self, new_value: &str) -> AccountAdunitUpdateCall<'a, C, NC, A> {
self._account_id = new_value.to_string();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client which contains the ad unit.
pub fn ad_client_id(mut self, new_value: &str) -> AccountAdunitUpdateCall<'a, C, NC, A> {
self._ad_client_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) -> AccountAdunitUpdateCall<'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) -> AccountAdunitUpdateCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> AccountAdunitUpdateCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Get a specific custom channel from the host AdSense account.
///
/// A builder for the *get* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.customchannels().get("adClientId", "customChannelId")
/// .doit();
/// # }
/// ```
pub struct CustomchannelGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_custom_channel_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelGetCall<'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, CustomChannel)> {
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: "adsensehost.customchannels.get",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("customChannelId", self._custom_channel_id.to_string()));
for &field in ["alt", "adClientId", "customChannelId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels/{customChannelId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId"), ("{customChannelId}", "customChannelId")].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 ["adClientId", "customChannelId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client from which to get the custom channel.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *custom channel id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Custom channel to get.
pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelGetCall<'a, C, NC, A> {
self._custom_channel_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) -> CustomchannelGetCall<'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) -> CustomchannelGetCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelGetCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Delete a specific custom channel from the host AdSense account.
///
/// A builder for the *delete* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.customchannels().delete("adClientId", "customChannelId")
/// .doit();
/// # }
/// ```
pub struct CustomchannelDeleteCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_custom_channel_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelDeleteCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelDeleteCall<'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, CustomChannel)> {
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: "adsensehost.customchannels.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("customChannelId", self._custom_channel_id.to_string()));
for &field in ["alt", "adClientId", "customChannelId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels/{customChannelId}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId"), ("{customChannelId}", "customChannelId")].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 ["adClientId", "customChannelId"].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_slice()))));
}
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 Result::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::Delete, url.as_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client from which to delete the custom channel.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelDeleteCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *custom channel id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Custom channel to delete.
pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelDeleteCall<'a, C, NC, A> {
self._custom_channel_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) -> CustomchannelDeleteCall<'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) -> CustomchannelDeleteCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelDeleteCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Update a custom channel in the host AdSense account.
///
/// A builder for the *update* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::CustomChannel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: CustomChannel = 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.customchannels().update(&req, "adClientId")
/// .doit();
/// # }
/// ```
pub struct CustomchannelUpdateCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: CustomChannel,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelUpdateCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelUpdateCall<'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, CustomChannel)> {
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: "adsensehost.customchannels.update",
http_method: hyper::method::Method::Put });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &CustomChannel) -> CustomchannelUpdateCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client in which the custom channel will be updated.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelUpdateCall<'a, C, NC, A> {
self._ad_client_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) -> CustomchannelUpdateCall<'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) -> CustomchannelUpdateCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelUpdateCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// List all host custom channels in this AdSense account.
///
/// A builder for the *list* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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.customchannels().list("adClientId")
/// .page_token("rebum.")
/// .max_results(68)
/// .doit();
/// # }
/// ```
pub struct CustomchannelListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_ad_client_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelListCall<'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, CustomChannels)> {
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: "adsensehost.customchannels.list",
http_method: hyper::method::Method::Get });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
if let Some(value) = self._page_token {
params.push(("pageToken", value.to_string()));
}
if let Some(value) = self._max_results {
params.push(("maxResults", value.to_string()));
}
for &field in ["alt", "adClientId", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(result_value)
}
}
}
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client for which to list custom channels.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelListCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
/// A continuation token, used to page through custom channels. To retrieve the next page, set this parameter to the value of "nextPageToken" from the previous response.
pub fn page_token(mut self, new_value: &str) -> CustomchannelListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
/// The maximum number of custom channels to include in the response, used for paging.
pub fn max_results(mut self, new_value: u32) -> CustomchannelListCall<'a, C, NC, A> {
self._max_results = Some(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) -> CustomchannelListCall<'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) -> CustomchannelListCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelListCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Update a custom channel in the host AdSense account. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::CustomChannel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: CustomChannel = 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.customchannels().patch(&req, "adClientId", "customChannelId")
/// .doit();
/// # }
/// ```
pub struct CustomchannelPatchCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: CustomChannel,
_ad_client_id: String,
_custom_channel_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelPatchCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelPatchCall<'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, CustomChannel)> {
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: "adsensehost.customchannels.patch",
http_method: hyper::method::Method::Patch });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
params.push(("customChannelId", self._custom_channel_id.to_string()));
for &field in ["alt", "adClientId", "customChannelId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &CustomChannel) -> CustomchannelPatchCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client in which the custom channel will be updated.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelPatchCall<'a, C, NC, A> {
self._ad_client_id = new_value.to_string();
self
}
/// Sets the *custom channel 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.
///
/// Custom channel to get.
pub fn custom_channel_id(mut self, new_value: &str) -> CustomchannelPatchCall<'a, C, NC, A> {
self._custom_channel_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) -> CustomchannelPatchCall<'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) -> CustomchannelPatchCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelPatchCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}
/// Add a new custom channel to the host AdSense account.
///
/// A builder for the *insert* method supported by a *customchannel* resource.
/// It is not used directly, but through a `CustomchannelMethods`.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate "yup-oauth2" as oauth2;
/// # extern crate "google-adsensehost4d1" as adsensehost4d1;
/// use adsensehost4d1::CustomChannel;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use adsensehost4d1::AdSenseHost;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AdSenseHost::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: CustomChannel = 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.customchannels().insert(&req, "adClientId")
/// .doit();
/// # }
/// ```
pub struct CustomchannelInsertCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AdSenseHost<C, NC, A>,
_request: CustomChannel,
_ad_client_id: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for CustomchannelInsertCall<'a, C, NC, A> {}
impl<'a, C, NC, A> CustomchannelInsertCall<'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, CustomChannel)> {
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: "adsensehost.customchannels.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
params.push(("adClientId", self._ad_client_id.to_string()));
for &field in ["alt", "adClientId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Result::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/adsensehost/v4.1/adclients/{adClientId}/customchannels".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Full.as_slice().to_string(), ());
}
for &(find_this, param_name) in [("{adClientId}", "adClientId")].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 ["adClientId"].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_slice()))));
}
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 Result::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_slice())
.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(d);
continue;
}
dlg.finished(false);
return Result::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(d);
continue;
}
dlg.finished(false);
return Result::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 Result::JsonDecodeError(err);
}
}
};
dlg.finished(true);
return Result::Success(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: &CustomChannel) -> CustomchannelInsertCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// Sets the *ad client id* path property to the given value.
///
/// Even though the property as already been set when instantiating this call,
/// we provide this method for API completeness.
///
/// Ad client to which the new custom channel will be added.
pub fn ad_client_id(mut self, new_value: &str) -> CustomchannelInsertCall<'a, C, NC, A> {
self._ad_client_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) -> CustomchannelInsertCall<'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) -> CustomchannelInsertCall<'a, C, NC, A>
where T: Str {
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> CustomchannelInsertCall<'a, C, NC, A>
where T: Str {
self._scopes.insert(scope.as_slice().to_string(), ());
self
}
}