// DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.in.mako' // DO NOT EDIT ! #[cfg(feature = "nightly")] #[macro_use] extern crate serde_derive; extern crate hyper; extern crate serde; extern crate serde_json; 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 serde_json as json; use std::io; use std::fs; use std::thread::sleep; use std::time::Duration; pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, ErrorResponse, remove_json_null_values}; // ############## // UTILITIES ### // ############ // ######## // HUB ### // ###### /// Central instance to access all DoubleClickBidManager related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use doubleclickbidmanager1::DoubleClickBidManager; /// /// // 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(), /// ::default(), None); /// let mut hub = DoubleClickBidManager::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.queries().getquery("queryId") /// .doit(); /// /// match result { /// Err(e) => match e { /// // The Error enum provides details about what exactly happened. /// // You can also just use its `Debug`, `Display` or `Error` traits /// Error::HttpError(_) /// |Error::MissingAPIKey /// |Error::MissingToken(_) /// |Error::Cancelled /// |Error::UploadSizeLimitExceeded(_, _) /// |Error::Failure(_) /// |Error::BadRequest(_) /// |Error::FieldClash(_) /// |Error::JsonDecodeError(_, _) => println!("{}", e), /// }, /// Ok(res) => println!("Success: {:?}", res), /// } /// # } /// ``` pub struct DoubleClickBidManager { client: RefCell, auth: RefCell, _user_agent: String, } impl<'a, C, A> Hub for DoubleClickBidManager {} impl<'a, C, A> DoubleClickBidManager where C: BorrowMut, A: oauth2::GetToken { pub fn new(client: C, authenticator: A) -> DoubleClickBidManager { DoubleClickBidManager { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/1.0.2".to_string(), } } pub fn lineitems(&'a self) -> LineitemMethods<'a, C, A> { LineitemMethods { hub: &self } } pub fn queries(&'a self) -> QueryMethods<'a, C, A> { QueryMethods { hub: &self } } pub fn reports(&'a self) -> ReportMethods<'a, C, A> { ReportMethods { hub: &self } } pub fn sdf(&'a self) -> SdfMethods<'a, C, A> { SdfMethods { hub: &self } } /// Set the user-agent header field to use in all requests to the server. /// It defaults to `google-api-rust-client/1.0.2`. /// /// 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 ### // ########## /// Request to fetch stored line items. /// /// # 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*). /// /// * [downloadlineitems lineitems](struct.LineitemDownloadlineitemCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DownloadLineItemsRequest { /// File specification (column names, types, order) in which the line items will be returned. Default to EWF. #[serde(rename="fileSpec")] pub file_spec: Option, /// Filter type used to filter line items to fetch. #[serde(rename="filterType")] pub filter_type: Option, /// Ids of the specified filter type used to filter line items to fetch. If omitted, all the line items will be returned. #[serde(rename="filterIds")] pub filter_ids: Option>, /// Format in which the line items will be returned. Default to CSV. pub format: Option, } impl RequestValue for DownloadLineItemsRequest {} /// An explanation of a report failure. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportFailure { /// Error code that shows why the report was not created. #[serde(rename="errorCode")] pub error_code: Option, } impl Part for ReportFailure {} /// Parameters of a query or report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Parameters { /// Metrics to include as columns in your report. pub metrics: Option>, /// Filters used to match traffic data in your report. pub filters: Option>, /// Report type. #[serde(rename="type")] pub type_: Option, /// Data is grouped by the filters listed in this field. #[serde(rename="groupBys")] pub group_bys: Option>, /// Whether to include data from Invite Media. #[serde(rename="includeInviteData")] pub include_invite_data: Option, } impl Part for Parameters {} /// Key used to identify a report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportKey { /// Query ID. #[serde(rename="queryId")] pub query_id: Option, /// Report ID. #[serde(rename="reportId")] pub report_id: Option, } impl Part for ReportKey {} /// Request to upload line items. /// /// # 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*). /// /// * [uploadlineitems lineitems](struct.LineitemUploadlineitemCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadLineItemsRequest { /// Line items in CSV to upload. Refer to Entity Write File Format for more information on file format. #[serde(rename="lineItems")] pub line_items: Option, /// Set to true to get upload status without actually persisting the line items. #[serde(rename="dryRun")] pub dry_run: Option, /// Format the line items are in. Default to CSV. pub format: Option, } impl RequestValue for UploadLineItemsRequest {} /// List queries response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [listqueries queries](struct.QueryListqueryCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListQueriesResponse { /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listQueriesResponse". pub kind: Option, /// Retrieved queries. pub queries: Option>, } impl ResponseResult for ListQueriesResponse {} /// Report metadata. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportMetadata { /// Report status. pub status: Option, /// The ending time for the data that is shown in the report. #[serde(rename="reportDataEndTimeMs")] pub report_data_end_time_ms: Option, /// The path to the location in Google Cloud Storage where the report is stored. #[serde(rename="googleCloudStoragePath")] pub google_cloud_storage_path: Option, /// The starting time for the data that is shown in the report. #[serde(rename="reportDataStartTimeMs")] pub report_data_start_time_ms: Option, } impl Part for ReportMetadata {} /// Information on how frequently and when to run a query. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct QuerySchedule { /// Datetime to periodically run the query until. #[serde(rename="endTimeMs")] pub end_time_ms: Option, /// How often the query is run. pub frequency: Option, /// Time of day at which a new report will be generated, represented as minutes past midnight. Range is 0 to 1439. Only applies to scheduled reports. #[serde(rename="nextRunMinuteOfDay")] pub next_run_minute_of_day: Option, /// Canonical timezone code for report generation time. Defaults to America/New_York. #[serde(rename="nextRunTimezoneCode")] pub next_run_timezone_code: Option, } impl Part for QuerySchedule {} /// Request to run a stored query to generate a report. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [runquery queries](struct.QueryRunqueryCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RunQueryRequest { /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise. #[serde(rename="reportDataEndTimeMs")] pub report_data_end_time_ms: Option, /// Canonical timezone code for report data time. Defaults to America/New_York. #[serde(rename="timezoneCode")] pub timezone_code: Option, /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise. #[serde(rename="reportDataStartTimeMs")] pub report_data_start_time_ms: Option, /// Report data range used to generate the report. #[serde(rename="dataRange")] pub data_range: Option, } impl RequestValue for RunQueryRequest {} /// Upload line items response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [uploadlineitems lineitems](struct.LineitemUploadlineitemCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadLineItemsResponse { /// Status of upload. #[serde(rename="uploadStatus")] pub upload_status: Option, } impl ResponseResult for UploadLineItemsResponse {} /// Query metadata. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct QueryMetadata { /// The path to the location in Google Cloud Storage where the latest report is stored. #[serde(rename="googleCloudStoragePathForLatestReport")] pub google_cloud_storage_path_for_latest_report: Option, /// Range of report data. #[serde(rename="dataRange")] pub data_range: Option, /// Whether to send an email notification when a report is ready. Default to false. #[serde(rename="sendNotification")] pub send_notification: Option, /// Locale of the generated reports. Valid values are cs CZECH de GERMAN en ENGLISH es SPANISH fr FRENCH it ITALIAN ja JAPANESE ko KOREAN pl POLISH pt-BR BRAZILIAN_PORTUGUESE ru RUSSIAN tr TURKISH uk UKRAINIAN zh-CN CHINA_CHINESE zh-TW TAIWAN_CHINESE /// /// An locale string not in the list above will generate reports in English. pub locale: Option, /// The path in Google Drive for the latest report. #[serde(rename="googleDrivePathForLatestReport")] pub google_drive_path_for_latest_report: Option, /// Format of the generated report. pub format: Option, /// List of email addresses which are sent email notifications when the report is finished. Separate from sendNotification. #[serde(rename="shareEmailAddress")] pub share_email_address: Option>, /// Number of reports that have been generated for the query. #[serde(rename="reportCount")] pub report_count: Option, /// Whether the latest report is currently running. pub running: Option, /// The time when the latest report started to run. #[serde(rename="latestReportRunTimeMs")] pub latest_report_run_time_ms: Option, /// Query title. It is used to name the reports generated from this query. pub title: Option, } impl Part for QueryMetadata {} /// Report status. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportStatus { /// If the report failed, this records the cause. pub failure: Option, /// The state of the report. pub state: Option, /// The time when this report either completed successfully or failed. #[serde(rename="finishTimeMs")] pub finish_time_ms: Option, /// The file type of the report. pub format: Option, } impl Part for ReportStatus {} /// List reports response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [listreports reports](struct.ReportListreportCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListReportsResponse { /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listReportsResponse". pub kind: Option, /// Retrieved reports. pub reports: Option>, } impl ResponseResult for ListReportsResponse {} /// Request to fetch stored insertion orders, line items, TrueView ad groups and ads. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [download sdf](struct.SdfDownloadCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DownloadRequest { /// File types that will be returned. #[serde(rename="fileTypes")] pub file_types: Option>, /// SDF Version (column names, types, order) in which the entities will be returned. Default to 3. pub version: Option, /// Filter type used to filter line items to fetch. #[serde(rename="filterType")] pub filter_type: Option, /// The IDs of the specified filter type. This is used to filter entities to fetch. At least one ID must be specified. Only one ID is allowed for the ADVERTISER_ID filter type. For INSERTION_ORDER_ID or LINE_ITEM_ID filter types all IDs must be from the same Advertiser. #[serde(rename="filterIds")] pub filter_ids: Option>, } impl RequestValue for DownloadRequest {} /// Represents the upload status of a row in the request. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct RowStatus { /// Whether the entity is persisted. pub persisted: Option, /// Reasons why the entity can't be uploaded. pub errors: Option>, /// Entity name. #[serde(rename="entityName")] pub entity_name: Option, /// Whether the stored entity is changed as a result of upload. pub changed: Option, /// Entity Id. #[serde(rename="entityId")] pub entity_id: Option, /// Row number. #[serde(rename="rowNumber")] pub row_number: Option, } impl Part for RowStatus {} /// Represents a report. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [listreports reports](struct.ReportListreportCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Report { /// Report parameters. pub params: Option, /// Key used to identify a report. pub key: Option, /// Report metadata. pub metadata: Option, } impl Resource for Report {} /// Represents a query. /// /// # 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*). /// /// * [getquery queries](struct.QueryGetqueryCall.html) (response) /// * [createquery queries](struct.QueryCreatequeryCall.html) (request|response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Query { /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#query". pub kind: Option, /// Information on how often and when to run a query. pub schedule: Option, /// Canonical timezone code for report data time. Defaults to America/New_York. #[serde(rename="timezoneCode")] pub timezone_code: Option, /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise. #[serde(rename="reportDataEndTimeMs")] pub report_data_end_time_ms: Option, /// Query ID. #[serde(rename="queryId")] pub query_id: Option, /// Query parameters. pub params: Option, /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise. #[serde(rename="reportDataStartTimeMs")] pub report_data_start_time_ms: Option, /// Query metadata. pub metadata: Option, } impl RequestValue for Query {} impl ResponseResult for Query {} /// Download line items response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [downloadlineitems lineitems](struct.LineitemDownloadlineitemCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DownloadLineItemsResponse { /// Retrieved line items in CSV format. Refer to Entity Write File Format or Structured Data File Format for more information on file formats. #[serde(rename="lineItems")] pub line_items: Option, } impl ResponseResult for DownloadLineItemsResponse {} /// Filter used to match traffic data in your report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FilterPair { /// Filter type. #[serde(rename="type")] pub type_: Option, /// Filter value. pub value: Option, } impl Part for FilterPair {} /// Represents the status of upload. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct UploadStatus { /// Reasons why upload can't be completed. pub errors: Option>, /// Per-row upload status. #[serde(rename="rowStatus")] pub row_status: Option>, } impl Part for UploadStatus {} /// Download response. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [download sdf](struct.SdfDownloadCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DownloadResponse { /// Retrieved insertion orders in SDF format. #[serde(rename="insertionOrders")] pub insertion_orders: Option, /// Retrieved line items in SDF format. #[serde(rename="lineItems")] pub line_items: Option, /// Retrieved ads in SDF format. pub ads: Option, /// Retrieved ad groups in SDF format. #[serde(rename="adGroups")] pub ad_groups: Option, } impl ResponseResult for DownloadResponse {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *sdf* resources. /// It is not used directly, but through the `DoubleClickBidManager` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use doubleclickbidmanager1::DoubleClickBidManager; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); /// let mut hub = DoubleClickBidManager::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `download(...)` /// // to build up your call. /// let rb = hub.sdf(); /// # } /// ``` pub struct SdfMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, } impl<'a, C, A> MethodsBuilder for SdfMethods<'a, C, A> {} impl<'a, C, A> SdfMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Retrieves entities in SDF format. /// /// # Arguments /// /// * `request` - No description provided. pub fn download(&self, request: DownloadRequest) -> SdfDownloadCall<'a, C, A> { SdfDownloadCall { hub: self.hub, _request: request, _delegate: Default::default(), _additional_params: Default::default(), } } } /// A builder providing access to all methods supported on *lineitem* resources. /// It is not used directly, but through the `DoubleClickBidManager` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use doubleclickbidmanager1::DoubleClickBidManager; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); /// let mut hub = DoubleClickBidManager::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `downloadlineitems(...)` and `uploadlineitems(...)` /// // to build up your call. /// let rb = hub.lineitems(); /// # } /// ``` pub struct LineitemMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, } impl<'a, C, A> MethodsBuilder for LineitemMethods<'a, C, A> {} impl<'a, C, A> LineitemMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Uploads line items in CSV format. /// /// # Arguments /// /// * `request` - No description provided. pub fn uploadlineitems(&self, request: UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { LineitemUploadlineitemCall { hub: self.hub, _request: request, _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves line items in CSV format. /// /// # Arguments /// /// * `request` - No description provided. pub fn downloadlineitems(&self, request: DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { LineitemDownloadlineitemCall { hub: self.hub, _request: request, _delegate: 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 `DoubleClickBidManager` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use doubleclickbidmanager1::DoubleClickBidManager; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); /// let mut hub = DoubleClickBidManager::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `listreports(...)` /// // to build up your call. /// let rb = hub.reports(); /// # } /// ``` pub struct ReportMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, } impl<'a, C, A> MethodsBuilder for ReportMethods<'a, C, A> {} impl<'a, C, A> ReportMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Retrieves stored reports. /// /// # Arguments /// /// * `queryId` - Query ID with which the reports are associated. pub fn listreports(&self, query_id: &str) -> ReportListreportCall<'a, C, A> { ReportListreportCall { hub: self.hub, _query_id: query_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } } /// A builder providing access to all methods supported on *query* resources. /// It is not used directly, but through the `DoubleClickBidManager` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate yup_oauth2 as oauth2; /// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use doubleclickbidmanager1::DoubleClickBidManager; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::new(), /// ::default(), None); /// let mut hub = DoubleClickBidManager::new(hyper::Client::new(), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `createquery(...)`, `deletequery(...)`, `getquery(...)`, `listqueries(...)` and `runquery(...)` /// // to build up your call. /// let rb = hub.queries(); /// # } /// ``` pub struct QueryMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, } impl<'a, C, A> MethodsBuilder for QueryMethods<'a, C, A> {} impl<'a, C, A> QueryMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Retrieves stored queries. pub fn listqueries(&self) -> QueryListqueryCall<'a, C, A> { QueryListqueryCall { hub: self.hub, _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Retrieves a stored query. /// /// # Arguments /// /// * `queryId` - Query ID to retrieve. pub fn getquery(&self, query_id: &str) -> QueryGetqueryCall<'a, C, A> { QueryGetqueryCall { hub: self.hub, _query_id: query_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Creates a query. /// /// # Arguments /// /// * `request` - No description provided. pub fn createquery(&self, request: Query) -> QueryCreatequeryCall<'a, C, A> { QueryCreatequeryCall { hub: self.hub, _request: request, _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Deletes a stored query as well as the associated stored reports. /// /// # Arguments /// /// * `queryId` - Query ID to delete. pub fn deletequery(&self, query_id: &str) -> QueryDeletequeryCall<'a, C, A> { QueryDeletequeryCall { hub: self.hub, _query_id: query_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Runs a stored query to generate a report. /// /// # Arguments /// /// * `request` - No description provided. /// * `queryId` - Query ID to run. pub fn runquery(&self, request: RunQueryRequest, query_id: &str) -> QueryRunqueryCall<'a, C, A> { QueryRunqueryCall { hub: self.hub, _request: request, _query_id: query_id.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Retrieves entities in SDF format. /// /// A builder for the *download* method supported by a *sdf* resource. /// It is not used directly, but through a `SdfMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::DownloadRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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 = DownloadRequest::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.sdf().download(req) /// .doit(); /// # } /// ``` pub struct SdfDownloadCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _request: DownloadRequest, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for SdfDownloadCall<'a, C, A> {} impl<'a, C, A> SdfDownloadCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, DownloadResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.sdf.download", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/sdf/download".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: DownloadRequest) -> SdfDownloadCall<'a, C, A> { self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> SdfDownloadCall<'a, C, 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(mut self, name: T, value: T) -> SdfDownloadCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Uploads line items in CSV format. /// /// A builder for the *uploadlineitems* method supported by a *lineitem* resource. /// It is not used directly, but through a `LineitemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::UploadLineItemsRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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 = UploadLineItemsRequest::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.lineitems().uploadlineitems(req) /// .doit(); /// # } /// ``` pub struct LineitemUploadlineitemCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _request: UploadLineItemsRequest, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for LineitemUploadlineitemCall<'a, C, A> {} impl<'a, C, A> LineitemUploadlineitemCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, UploadLineItemsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.lineitems.uploadlineitems", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/lineitems/uploadlineitems".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: UploadLineItemsRequest) -> LineitemUploadlineitemCall<'a, C, A> { self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> LineitemUploadlineitemCall<'a, C, 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(mut self, name: T, value: T) -> LineitemUploadlineitemCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Retrieves line items in CSV format. /// /// A builder for the *downloadlineitems* method supported by a *lineitem* resource. /// It is not used directly, but through a `LineitemMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::DownloadLineItemsRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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 = DownloadLineItemsRequest::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.lineitems().downloadlineitems(req) /// .doit(); /// # } /// ``` pub struct LineitemDownloadlineitemCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _request: DownloadLineItemsRequest, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for LineitemDownloadlineitemCall<'a, C, A> {} impl<'a, C, A> LineitemDownloadlineitemCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, DownloadLineItemsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.lineitems.downloadlineitems", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/lineitems/downloadlineitems".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: DownloadLineItemsRequest) -> LineitemDownloadlineitemCall<'a, C, A> { self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> LineitemDownloadlineitemCall<'a, C, 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(mut self, name: T, value: T) -> LineitemDownloadlineitemCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Retrieves stored reports. /// /// A builder for the *listreports* method supported by a *report* resource. /// It is not used directly, but through a `ReportMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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().listreports("queryId") /// .doit(); /// # } /// ``` pub struct ReportListreportCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _query_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for ReportListreportCall<'a, C, A> {} impl<'a, C, A> ReportListreportCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListReportsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.reports.listreports", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("queryId", self._query_id.to_string())); for &field in ["alt", "queryId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/queries/{queryId}/reports".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } for &(find_this, param_name) in [("{queryId}", "queryId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["queryId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Query ID with which the reports are associated. /// /// Sets the *query id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn query_id(mut self, new_value: &str) -> ReportListreportCall<'a, C, A> { self._query_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> ReportListreportCall<'a, C, 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(mut self, name: T, value: T) -> ReportListreportCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Retrieves stored queries. /// /// A builder for the *listqueries* method supported by a *query* resource. /// It is not used directly, but through a `QueryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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.queries().listqueries() /// .doit(); /// # } /// ``` pub struct QueryListqueryCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for QueryListqueryCall<'a, C, A> {} impl<'a, C, A> QueryListqueryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, ListQueriesResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.queries.listqueries", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/queries".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> QueryListqueryCall<'a, C, 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(mut self, name: T, value: T) -> QueryListqueryCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Retrieves a stored query. /// /// A builder for the *getquery* method supported by a *query* resource. /// It is not used directly, but through a `QueryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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.queries().getquery("queryId") /// .doit(); /// # } /// ``` pub struct QueryGetqueryCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _query_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for QueryGetqueryCall<'a, C, A> {} impl<'a, C, A> QueryGetqueryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Query)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.queries.getquery", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("queryId", self._query_id.to_string())); for &field in ["alt", "queryId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/query/{queryId}".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } for &(find_this, param_name) in [("{queryId}", "queryId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["queryId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// Query ID to retrieve. /// /// Sets the *query id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn query_id(mut self, new_value: &str) -> QueryGetqueryCall<'a, C, A> { self._query_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> QueryGetqueryCall<'a, C, 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(mut self, name: T, value: T) -> QueryGetqueryCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Creates a query. /// /// A builder for the *createquery* method supported by a *query* resource. /// It is not used directly, but through a `QueryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::Query; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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 = Query::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.queries().createquery(req) /// .doit(); /// # } /// ``` pub struct QueryCreatequeryCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _request: Query, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for QueryCreatequeryCall<'a, C, A> {} impl<'a, C, A> QueryCreatequeryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result<(hyper::client::Response, Query)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.queries.createquery", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); for &field in ["alt"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } params.push(("alt", "json".to_string())); let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/query".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = { let mut json_response = String::new(); res.read_to_string(&mut json_response).unwrap(); match json::from_str(&json_response) { Ok(decoded) => (res, decoded), Err(err) => { dlg.response_json_decode_error(&json_response, &err); return Err(Error::JsonDecodeError(json_response, err)); } } }; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: Query) -> QueryCreatequeryCall<'a, C, A> { self._request = new_value; self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> QueryCreatequeryCall<'a, C, 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(mut self, name: T, value: T) -> QueryCreatequeryCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Deletes a stored query as well as the associated stored reports. /// /// A builder for the *deletequery* method supported by a *query* resource. /// It is not used directly, but through a `QueryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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.queries().deletequery("queryId") /// .doit(); /// # } /// ``` pub struct QueryDeletequeryCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _query_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for QueryDeletequeryCall<'a, C, A> {} impl<'a, C, A> QueryDeletequeryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.queries.deletequery", http_method: hyper::method::Method::Delete }); let mut params: Vec<(&str, String)> = Vec::with_capacity((2 + self._additional_params.len())); params.push(("queryId", self._query_id.to_string())); for &field in ["queryId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/query/{queryId}".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } for &(find_this, param_name) in [("{queryId}", "queryId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["queryId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// Query ID to delete. /// /// Sets the *query id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn query_id(mut self, new_value: &str) -> QueryDeletequeryCall<'a, C, A> { self._query_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> QueryDeletequeryCall<'a, C, 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(mut self, name: T, value: T) -> QueryDeletequeryCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Runs a stored query to generate a report. /// /// A builder for the *runquery* method supported by a *query* resource. /// It is not used directly, but through a `QueryMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1; /// use doubleclickbidmanager1::RunQueryRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use doubleclickbidmanager1::DoubleClickBidManager; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::new(), /// # ::default(), None); /// # let mut hub = DoubleClickBidManager::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 = RunQueryRequest::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.queries().runquery(req, "queryId") /// .doit(); /// # } /// ``` pub struct QueryRunqueryCall<'a, C, A> where C: 'a, A: 'a { hub: &'a DoubleClickBidManager, _request: RunQueryRequest, _query_id: String, _delegate: Option<&'a mut Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for QueryRunqueryCall<'a, C, A> {} impl<'a, C, A> QueryRunqueryCall<'a, C, A> where C: BorrowMut, A: oauth2::GetToken { /// Perform the operation you have build so far. pub fn doit(mut self) -> Result { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "doubleclickbidmanager.queries.runquery", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len())); params.push(("queryId", self._query_id.to_string())); for &field in ["queryId"].iter() { if self._additional_params.contains_key(field) { dlg.finished(false); return Err(Error::FieldClash(field)); } } for (name, value) in self._additional_params.iter() { params.push((&name, value.clone())); } let mut url = "https://www.googleapis.com/doubleclickbidmanager/v1/query/{queryId}".to_string(); let mut key = self.hub.auth.borrow_mut().api_key(); if key.is_none() { key = dlg.api_key(); } match key { Some(value) => params.push(("key", value)), None => { dlg.finished(false); return Err(Error::MissingAPIKey) } } for &(find_this, param_name) in [("{queryId}", "queryId")].iter() { let mut replace_with: Option<&str> = None; for &(name, ref value) in params.iter() { if name == param_name { replace_with = Some(value); break; } } url = url.replace(find_this, replace_with.expect("to find substitution value in params")); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["queryId"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } if params.len() > 0 { url.push('?'); url.push_str(&url::form_urlencoded::serialize(params)); } let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default()); let mut request_value_reader = { let mut value = json::value::to_value(&self._request); remove_json_null_values(&mut value); let mut dst = io::Cursor::new(Vec::with_capacity(128)); json::to_writer(&mut dst, &value).unwrap(); dst }; let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); loop { 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) .header(UserAgent(self.hub._user_agent.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 Err(Error::HttpError(err)) } Ok(mut res) => { if !res.status.is_success() { let mut json_err = String::new(); res.read_to_string(&mut json_err).unwrap(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok(), json::from_str(&json_err).ok()) { sleep(d); continue; } dlg.finished(false); return match json::from_str::(&json_err){ Err(_) => Err(Error::Failure(res)), Ok(serr) => Err(Error::BadRequest(serr)) } } let result_value = res; dlg.finished(true); return Ok(result_value) } } } } /// /// Sets the *request* property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn request(mut self, new_value: RunQueryRequest) -> QueryRunqueryCall<'a, C, A> { self._request = new_value; self } /// Query ID to run. /// /// Sets the *query id* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn query_id(mut self, new_value: &str) -> QueryRunqueryCall<'a, C, A> { self._query_id = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut Delegate) -> QueryRunqueryCall<'a, C, 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(mut self, name: T, value: T) -> QueryRunqueryCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } }