// DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! //! This documentation was generated from *AdMob* crate version *1.0.14+20200709*, where *20200709* is the exact revision of the *admob:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.14*. //! //! Everything else about the *AdMob* *v1* API can be found at the //! [official documentation site](https://developers.google.com/admob/api/). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/admob1). //! # Features //! //! Handle the following *Resources* with ease from the central [hub](struct.AdMob.html) ... //! //! * accounts //! * [*get*](struct.AccountGetCall.html), [*list*](struct.AccountListCall.html), [*mediation report generate*](struct.AccountMediationReportGenerateCall.html) and [*network report generate*](struct.AccountNetworkReportGenerateCall.html) //! //! //! //! //! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs). //! //! # Structure of this Library //! //! The API is structured into the following primary items: //! //! * **[Hub](struct.AdMob.html)** //! * a central object to maintain state and allow accessing all *Activities* //! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn //! allow access to individual [*Call Builders*](trait.CallBuilder.html) //! * **[Resources](trait.Resource.html)** //! * primary types that you can apply *Activities* to //! * a collection of properties and *Parts* //! * **[Parts](trait.Part.html)** //! * a collection of properties //! * never directly used in *Activities* //! * **[Activities](trait.CallBuilder.html)** //! * operations to apply to *Resources* //! //! All *structures* are marked with applicable traits to further categorize them and ease browsing. //! //! Generally speaking, you can invoke *Activities* like this: //! //! ```Rust,ignore //! let r = hub.resource().activity(...).doit() //! ``` //! //! Or specifically ... //! //! ```ignore //! let r = hub.accounts().get(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` //! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be //! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. //! The `doit()` method performs the actual communication with the server and returns the respective result. //! //! # Usage //! //! ## Setting up your Project //! //! To use this library, you would put the following lines into your `Cargo.toml` file: //! //! ```toml //! [dependencies] //! google-admob1 = "*" //! # This project intentionally uses an old version of Hyper. See //! # https://github.com/Byron/google-apis-rs/issues/173 for more //! # information. //! hyper = "^0.10" //! hyper-rustls = "^0.6" //! serde = "^1.0" //! serde_json = "^1.0" //! yup-oauth2 = "^1.0" //! ``` //! //! ## A complete example //! //! ```test_harness,no_run //! extern crate hyper; //! extern crate hyper_rustls; //! extern crate yup_oauth2 as oauth2; //! extern crate google_admob1 as admob1; //! use admob1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; //! use admob1::AdMob; //! //! // 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::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), //! ::default(), None); //! let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); //! // You can configure optional parameters by calling the respective setters at will, and //! // execute the final call using `doit()`. //! // Values shown here are possibly random and not representative ! //! let result = hub.accounts().get("name") //! .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), //! } //! # } //! ``` //! ## Handling Errors //! //! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of //! the doit() methods, or handed as possibly intermediate results to either the //! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html). //! //! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This //! makes the system potentially resilient to all kinds of errors. //! //! ## Uploads and Downloads //! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be //! read by you to obtain the media. //! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default. //! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making //! this call: `.param("alt", "media")`. //! //! Methods supporting uploads can do so using up to 2 different protocols: //! *simple* and *resumable*. The distinctiveness of each is represented by customized //! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. //! //! ## Customization and Callbacks //! //! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the //! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call. //! Respective methods will be called to provide progress information, as well as determine whether the system should //! retry on failure. //! //! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort. //! //! ## Optional Parts in Server-Requests //! //! All structures provided by this library are made to be [encodable](trait.RequestValue.html) and //! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses //! are valid. //! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to //! the server to indicate either the set parts of the request or the desired parts in the response. //! //! ## Builder Arguments //! //! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods. //! These will always take a single argument, for which the following statements are true. //! //! * [PODs][wiki-pod] are handed by copy //! * strings are passed as `&str` //! * [request values](trait.RequestValue.html) are moved //! //! Arguments will always be copied or cloned into the builder, to make them independent of their original life times. //! //! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure //! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern //! [google-go-api]: https://github.com/google/google-api-go-client //! //! // Unused attributes happen thanks to defined, but unused structures // We don't warn about this, as depending on the API, some data structures or facilities are never used. // Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any // unused imports in fully featured APIs. Same with unused_mut ... . #![allow(unused_imports, unused_mut, dead_code)] // DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! #[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::mem; use std::thread::sleep; use std::time::Duration; pub use cmn::*; // ############## // UTILITIES ### // ############ // ######## // HUB ### // ###### /// Central instance to access all AdMob related resource activities /// /// # Examples /// /// Instantiate a new hub /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate yup_oauth2 as oauth2; /// extern crate google_admob1 as admob1; /// use admob1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use admob1::AdMob; /// /// // 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::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// ::default(), None); /// let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().get("name") /// .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 AdMob { client: RefCell, auth: RefCell, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, C, A> Hub for AdMob {} impl<'a, C, A> AdMob where C: BorrowMut, A: oauth2::GetToken { pub fn new(client: C, authenticator: A) -> AdMob { AdMob { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/1.0.14".to_string(), _base_url: "https://admob.googleapis.com/".to_string(), _root_url: "https://admob.googleapis.com/".to_string(), } } pub fn accounts(&'a self) -> AccountMethods<'a, C, A> { AccountMethods { 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.14`. /// /// Returns the previously set user-agent. pub fn user_agent(&mut self, agent_name: String) -> String { mem::replace(&mut self._user_agent, agent_name) } /// Set the base url to use in all requests to the server. /// It defaults to `https://admob.googleapis.com/`. /// /// Returns the previously set base url. pub fn base_url(&mut self, new_base_url: String) -> String { mem::replace(&mut self._base_url, new_base_url) } /// Set the root url to use in all requests to the server. /// It defaults to `https://admob.googleapis.com/`. /// /// Returns the previously set root url. pub fn root_url(&mut self, new_root_url: String) -> String { mem::replace(&mut self._root_url, new_root_url) } } // ############ // SCHEMAS ### // ########## /// Describes which report rows to match based on their dimension values. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkReportSpecDimensionFilter { /// Applies the filter criterion to the specified dimension. pub dimension: Option, /// Matches a row if its value for the specified dimension is in one of the /// values specified in this condition. #[serde(rename="matchesAny")] pub matches_any: Option, } impl Part for NetworkReportSpecDimensionFilter {} /// Describes which report rows to match based on their dimension values. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediationReportSpecDimensionFilter { /// Applies the filter criterion to the specified dimension. pub dimension: Option, /// Matches a row if its value for the specified dimension is in one of the /// values specified in this condition. #[serde(rename="matchesAny")] pub matches_any: Option, } impl Part for MediationReportSpecDimensionFilter {} /// The streaming response for the AdMob Mediation report where the first /// response contains the report header, then a stream of row responses, and /// finally a footer as the last response message. /// /// For example: /// /// ````text /// [{ /// "header": { /// "date_range": { /// "start_date": {"year": 2018, "month": 9, "day": 1}, /// "end_date": {"year": 2018, "month": 9, "day": 1} /// }, /// "localization_settings": { /// "currency_code": "USD", /// "language_code": "en-US" /// } /// } /// }, /// { /// "row": { /// "dimension_values": { /// "DATE": {"value": "20180918"}, /// "APP": { /// "value": "ca-app-pub-8123415297019784~1001342552", /// "display_label": "My app name!" /// } /// }, /// "metric_values": { /// "ESTIMATED_EARNINGS": {"decimal_value": "1324746"} /// } /// } /// }, /// { /// "footer": {"matching_row_count": 1} /// }] /// ```` /// /// # 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*). /// /// * [mediation report generate accounts](struct.AccountMediationReportGenerateCall.html) (response) #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateMediationReportResponse { /// Report generation settings that describes the report contents, such as /// the report date range and localization settings. pub header: Option, /// Additional information about the generated report, such as warnings about /// the data. pub footer: Option, /// Actual report data. pub row: Option, } impl ResponseResult for GenerateMediationReportResponse {} /// Request to generate an AdMob Network 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*). /// /// * [network report generate accounts](struct.AccountNetworkReportGenerateCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateNetworkReportRequest { /// Network report specification. #[serde(rename="reportSpec")] pub report_spec: Option, } impl RequestValue for GenerateNetworkReportRequest {} /// Specification of a single date range. Both dates are inclusive. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DateRange { /// Start date of the date range, inclusive. Must be less than or equal to the /// end date. #[serde(rename="startDate")] pub start_date: Option, /// End date of the date range, inclusive. Must be greater than or equal to the /// start date. #[serde(rename="endDate")] pub end_date: Option, } impl Part for DateRange {} /// A publisher account contains information relevant to the use of this API, /// such as the time zone used for the reports. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [get accounts](struct.AccountGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct PublisherAccount { /// Currency code of the earning-related metrics, which is the 3-letter code /// defined in ISO 4217. The daily average rate is used for the currency /// conversion. #[serde(rename="currencyCode")] pub currency_code: Option, /// The unique ID by which this publisher account can be identified /// in the API requests (for example, pub-1234567890). #[serde(rename="publisherId")] pub publisher_id: Option, /// Resource name of this account. /// Format is accounts/{publisher_id}. pub name: Option, /// The time zone that is used in reports that are generated for this account. /// The value is a time-zone ID as specified by the CLDR project, /// for example, "America/Los_Angeles". #[serde(rename="reportingTimeZone")] pub reporting_time_zone: Option, } impl ResponseResult for PublisherAccount {} /// Localization settings for reports, such as currency and language. It affects /// how metrics are calculated. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct LocalizationSettings { /// Language used for any localized text, such as some dimension value display /// labels. The language tag defined in the IETF BCP47. Defaults to 'en-US' if /// unspecified. #[serde(rename="languageCode")] pub language_code: Option, /// Currency code of the earning related metrics, which is the 3-letter code /// defined in ISO 4217. The daily average rate is used for the currency /// conversion. Defaults to the account currency code if unspecified. #[serde(rename="currencyCode")] pub currency_code: Option, } impl Part for LocalizationSettings {} /// Request to generate an AdMob Mediation 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*). /// /// * [mediation report generate accounts](struct.AccountMediationReportGenerateCall.html) (request) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateMediationReportRequest { /// Network report specification. #[serde(rename="reportSpec")] pub report_spec: Option, } impl RequestValue for GenerateMediationReportRequest {} /// Groups data available after report generation, for example, warnings and row /// counts. Always sent as the last message in the stream response. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportFooter { /// Total number of rows that did match the request. #[serde(rename="matchingRowCount")] pub matching_row_count: Option, /// Warnings associated with generation of the report. pub warnings: Option>, } impl Part for ReportFooter {} /// Sorting direction to be applied on a dimension or a metric. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediationReportSpecSortCondition { /// Sort by the specified metric. pub metric: Option, /// Sort by the specified dimension. pub dimension: Option, /// Sorting order of the dimension or metric. pub order: Option, } impl Part for MediationReportSpecSortCondition {} /// Response for the publisher account list request. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list accounts](struct.AccountListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListPublisherAccountsResponse { /// If not empty, indicates that there might be more accounts for the request; /// you must pass this value in a new `ListPublisherAccountsRequest`. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// Publisher that the client credentials can access. pub account: Option>, } impl ResponseResult for ListPublisherAccountsResponse {} /// List of string values. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct StringList { /// The string values. pub values: Option>, } impl Part for StringList {} /// Sorting direction to be applied on a dimension or a metric. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkReportSpecSortCondition { /// Sort by the specified metric. pub metric: Option, /// Sort by the specified dimension. pub dimension: Option, /// Sorting order of the dimension or metric. pub order: Option, } impl Part for NetworkReportSpecSortCondition {} /// The streaming response for the AdMob Network report where the first response /// contains the report header, then a stream of row responses, and finally a /// footer as the last response message. /// /// For example: /// /// ````text /// [{ /// "header": { /// "dateRange": { /// "startDate": {"year": 2018, "month": 9, "day": 1}, /// "endDate": {"year": 2018, "month": 9, "day": 1} /// }, /// "localizationSettings": { /// "currencyCode": "USD", /// "languageCode": "en-US" /// } /// } /// }, /// { /// "row": { /// "dimensionValues": { /// "DATE": {"value": "20180918"}, /// "APP": { /// "value": "ca-app-pub-8123415297019784~1001342552", /// displayLabel: "My app name!" /// } /// }, /// "metricValues": { /// "ESTIMATED_EARNINGS": {"microsValue": 6500000} /// } /// } /// }, /// { /// "footer": {"matchingRowCount": 1} /// }] /// ```` /// /// # 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*). /// /// * [network report generate accounts](struct.AccountNetworkReportGenerateCall.html) (response) #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct GenerateNetworkReportResponse { /// Report generation settings that describes the report contents, such as /// the report date range and localization settings. pub header: Option, /// Additional information about the generated report, such as warnings about /// the data. pub footer: Option, /// Actual report data. pub row: Option, } impl ResponseResult for GenerateNetworkReportResponse {} /// Representation of a metric value. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportRowMetricValue { /// Amount in micros. One million is equivalent to one unit. Currency value /// is in the unit (USD, EUR or other) specified by the request. /// For example, $6.50 whould be represented as 6500000 micros. #[serde(rename="microsValue")] pub micros_value: Option, /// Double precision (approximate) decimal values. Rates are from 0 to 1. #[serde(rename="doubleValue")] pub double_value: Option, /// Metric integer value. #[serde(rename="integerValue")] pub integer_value: Option, } impl Part for ReportRowMetricValue {} /// Represents a whole or partial calendar date, e.g. a birthday. The time of day /// and time zone are either specified elsewhere or are not significant. The date /// is relative to the Proleptic Gregorian Calendar. This can represent: /// /// * A full date, with non-zero year, month and day values /// * A month and day value, with a zero year, e.g. an anniversary /// * A year on its own, with zero month and day values /// * A year and month value, with a zero day, e.g. a credit card expiration date /// /// Related types are google.type.TimeOfDay and `google.protobuf.Timestamp`. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Date { /// Month of year. Must be from 1 to 12, or 0 if specifying a year without a /// month and day. pub month: Option, /// Day of month. Must be from 1 to 31 and valid for the year and month, or 0 /// if specifying a year by itself or a year and month where the day is not /// significant. pub day: Option, /// Year of date. Must be from 1 to 9999, or 0 if specifying a date without /// a year. pub year: Option, } impl Part for Date {} /// Representation of a dimension value. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportRowDimensionValue { /// The localized string representation of the value. If unspecified, the /// display label should be derived from the value. #[serde(rename="displayLabel")] pub display_label: Option, /// Dimension value in the format specified in the report's spec Dimension /// enum. pub value: Option, } impl Part for ReportRowDimensionValue {} /// A row of the returning 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 ReportRow { /// Map of dimension values in a row, with keys as enum name of the dimensions. #[serde(rename="dimensionValues")] pub dimension_values: Option>, /// Map of metric values in a row, with keys as enum name of the metrics. If /// a metric being requested has no value returned, the map will not include /// it. #[serde(rename="metricValues")] pub metric_values: Option>, } impl Part for ReportRow {} /// The specification for generating an AdMob Network report. /// For example, the specification to get clicks and estimated earnings for only /// the 'US' and 'CN' countries can look like the following example: /// /// ````text /// { /// 'date_range': { /// 'start_date': {'year': 2018, 'month': 9, 'day': 1}, /// 'end_date': {'year': 2018, 'month': 9, 'day': 30} /// }, /// 'dimensions': ['DATE', 'APP', 'COUNTRY'], /// 'metrics': ['CLICKS', 'ESTIMATED_EARNINGS'], /// 'dimension_filters': [ /// { /// 'dimension': 'COUNTRY', /// 'matches_any': {'values': [{'value': 'US', 'value': 'CN'}]} /// } /// ], /// 'sort_conditions': [ /// {'dimension':'APP', order: 'ASCENDING'}, /// {'metric':'CLICKS', order: 'DESCENDING'} /// ], /// 'localization_settings': { /// 'currency_code': 'USD', /// 'language_code': 'en-US' /// } /// } /// ```` /// /// For a better understanding, you can treat the preceding specification like /// the following pseudo SQL: /// /// ````text /// SELECT DATE, APP, COUNTRY, CLICKS, ESTIMATED_EARNINGS /// FROM NETWORK_REPORT /// WHERE DATE >= '2018-09-01' AND DATE <= '2018-09-30' /// AND COUNTRY IN ('US', 'CN') /// GROUP BY DATE, APP, COUNTRY /// ORDER BY APP ASC, CLICKS DESC; /// ```` /// /// This type is not used in any activity, and only used as *part* of another schema. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct NetworkReportSpec { /// Localization settings of the report. #[serde(rename="localizationSettings")] pub localization_settings: Option, /// List of dimensions of the report. The value combination of these dimensions /// determines the row of the report. If no dimensions are specified, the /// report returns a single row of requested metrics for the entire account. pub dimensions: Option>, /// Maximum number of report data rows to return. If the value is not set, the /// API returns as many rows as possible, up to 100000. Acceptable values are /// 1-100000, inclusive. Any other values are treated as 100000. #[serde(rename="maxReportRows")] pub max_report_rows: Option, /// The date range for which the report is generated. #[serde(rename="dateRange")] pub date_range: Option, /// Describes which report rows to match based on their dimension values. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// List of metrics of the report. A report must specify at least one metric. pub metrics: Option>, /// Describes the sorting of report rows. The order of the condition in the /// list defines its precedence; the earlier the condition, the higher its /// precedence. If no sort conditions are specified, the row ordering is /// undefined. #[serde(rename="sortConditions")] pub sort_conditions: Option>, /// A report time zone. Accepts an IANA TZ name values, such as /// "America/Los_Angeles." If no time zone is defined, the account default /// takes effect. Check default value by the get account action. /// /// **Warning:** The "America/Los_Angeles" is the only supported value at /// the moment. #[serde(rename="timeZone")] pub time_zone: Option, } impl Part for NetworkReportSpec {} /// Groups data helps to treat the generated report. Always sent as a first /// message in the stream response. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportHeader { /// Localization settings of the report. This is identical to the settings /// in the report request. #[serde(rename="localizationSettings")] pub localization_settings: Option, /// The date range for which the report is generated. This is identical to the /// range specified in the report request. #[serde(rename="dateRange")] pub date_range: Option, /// The report time zone. The value is a time-zone ID as specified by the CLDR /// project, for example, "America/Los_Angeles". #[serde(rename="reportingTimeZone")] pub reporting_time_zone: Option, } impl Part for ReportHeader {} /// The specification for generating an AdMob Mediation report. /// For example, the specification to get observed ECPM sliced by ad source and /// app for the 'US' and 'CN' countries can look like the following example: /// /// ````text /// { /// "date_range": { /// "start_date": {"year": 2018, "month": 9, "day": 1}, /// "end_date": {"year": 2018, "month": 9, "day": 30} /// }, /// "dimensions": ["AD_SOURCE", "APP", "COUNTRY"], /// "metrics": ["OBSERVED_ECPM"], /// "dimension_filters": [ /// { /// "dimension": "COUNTRY", /// "matches_any": {"values": [{"value": "US", "value": "CN"}]} /// } /// ], /// "sort_conditions": [ /// {"dimension":"APP", order: "ASCENDING"} /// ], /// "localization_settings": { /// "currency_code": "USD", /// "language_code": "en-US" /// } /// } /// ```` /// /// For a better understanding, you can treat the preceding specification like /// the following pseudo SQL: /// /// ````text /// SELECT AD_SOURCE, APP, COUNTRY, OBSERVED_ECPM /// FROM MEDIATION_REPORT /// WHERE DATE >= '2018-09-01' AND DATE <= '2018-09-30' /// AND COUNTRY IN ('US', 'CN') /// GROUP BY AD_SOURCE, APP, COUNTRY /// ORDER BY APP ASC; /// ```` /// /// This type is not used in any activity, and only used as *part* of another schema. #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct MediationReportSpec { /// Localization settings of the report. #[serde(rename="localizationSettings")] pub localization_settings: Option, /// List of dimensions of the report. The value combination of these dimensions /// determines the row of the report. If no dimensions are specified, the /// report returns a single row of requested metrics for the entire account. pub dimensions: Option>, /// Maximum number of report data rows to return. If the value is not set, the /// API returns as many rows as possible, up to 100000. Acceptable values are /// 1-100000, inclusive. Any other values are treated as 100000. #[serde(rename="maxReportRows")] pub max_report_rows: Option, /// The date range for which the report is generated. #[serde(rename="dateRange")] pub date_range: Option, /// Describes which report rows to match based on their dimension values. #[serde(rename="dimensionFilters")] pub dimension_filters: Option>, /// List of metrics of the report. A report must specify at least one metric. pub metrics: Option>, /// Describes the sorting of report rows. The order of the condition in the /// list defines its precedence; the earlier the condition, the higher its /// precedence. If no sort conditions are specified, the row ordering is /// undefined. #[serde(rename="sortConditions")] pub sort_conditions: Option>, /// A report time zone. Accepts an IANA TZ name values, such as /// "America/Los_Angeles." If no time zone is defined, the account default /// takes effect. Check default value by the get account action. /// /// **Warning:** The "America/Los_Angeles" is the only supported value at /// the moment. #[serde(rename="timeZone")] pub time_zone: Option, } impl Part for MediationReportSpec {} /// Warnings associated with generation of the report. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ReportWarning { /// Type of the warning. #[serde(rename="type")] pub type_: Option, /// Describes the details of the warning message, in English. pub description: Option, } impl Part for ReportWarning {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *account* resources. /// It is not used directly, but through the `AdMob` hub. /// /// # Example /// /// Instantiate a resource builder /// /// ```test_harness,no_run /// extern crate hyper; /// extern crate hyper_rustls; /// extern crate yup_oauth2 as oauth2; /// extern crate google_admob1 as admob1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use admob1::AdMob; /// /// let secret: ApplicationSecret = Default::default(); /// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// ::default(), None); /// let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* /// // like `get(...)`, `list(...)`, `mediation_report_generate(...)` and `network_report_generate(...)` /// // to build up your call. /// let rb = hub.accounts(); /// # } /// ``` pub struct AccountMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a AdMob, } impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {} impl<'a, C, A> AccountMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Lists the AdMob publisher account accessible with the client credential. /// Currently, all credentials have access to at most one AdMob account. pub fn list(&self) -> AccountListCall<'a, C, A> { AccountListCall { hub: self.hub, _page_token: Default::default(), _page_size: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Gets information about the specified AdMob publisher account. /// /// # Arguments /// /// * `name` - Required. Resource name of the publisher account to retrieve. /// Example: accounts/pub-9876543210987654 pub fn get(&self, name: &str) -> AccountGetCall<'a, C, A> { AccountGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Generates an AdMob Network report based on the provided report /// specification. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Resource name of the account to generate the report for. /// Example: accounts/pub-9876543210987654 pub fn network_report_generate(&self, request: GenerateNetworkReportRequest, parent: &str) -> AccountNetworkReportGenerateCall<'a, C, A> { AccountNetworkReportGenerateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Generates an AdMob Mediation report based on the provided report /// specification. /// /// # Arguments /// /// * `request` - No description provided. /// * `parent` - Resource name of the account to generate the report for. /// Example: accounts/pub-9876543210987654 pub fn mediation_report_generate(&self, request: GenerateMediationReportRequest, parent: &str) -> AccountMediationReportGenerateCall<'a, C, A> { AccountMediationReportGenerateCall { hub: self.hub, _request: request, _parent: parent.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Lists the AdMob publisher account accessible with the client credential. /// Currently, all credentials have access to at most one AdMob account. /// /// A builder for the *list* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_admob1 as admob1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use admob1::AdMob; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # ::default(), None); /// # let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().list() /// .page_token("sed") /// .page_size(-85) /// .doit(); /// # } /// ``` pub struct AccountListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AdMob, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for AccountListCall<'a, C, A> {} impl<'a, C, A> AccountListCall<'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, ListPublisherAccountsResponse)> { use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "admob.accounts.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); if let Some(value) = self._page_token { params.push(("pageToken", value.to_string())); } if let Some(value) = self._page_size { params.push(("pageSize", value.to_string())); } for &field in ["alt", "pageToken", "pageSize"].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 = self.hub._base_url.clone() + "v1/accounts"; 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) } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); 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.clone()) .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(); let json_server_error = json::from_str::(&json_err).ok(); let server_error = json::from_str::(&json_err) .or_else(|_| json::from_str::(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { 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 value returned by the last `ListPublisherAccountsResponse`; indicates /// that this is a continuation of a prior `ListPublisherAccounts` call, and /// that the system should return the next page of data. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> AccountListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Maximum number of accounts to return. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> AccountListCall<'a, C, A> { self._page_size = Some(new_value); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AccountListCall<'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 parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *callback* (query-string) - JSONP /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param(mut self, name: T, value: T) -> AccountListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Gets information about the specified AdMob publisher account. /// /// A builder for the *get* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_admob1 as admob1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use admob1::AdMob; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # ::default(), None); /// # let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth); /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().get("name") /// .doit(); /// # } /// ``` pub struct AccountGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AdMob, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for AccountGetCall<'a, C, A> {} impl<'a, C, A> AccountGetCall<'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, PublisherAccount)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "admob.accounts.get", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len()); params.push(("name", self._name.to_string())); for &field in ["alt", "name"].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 = self.hub._base_url.clone() + "v1/{+name}"; 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 [("{+name}", "name")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["name"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); 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.clone()) .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(); let json_server_error = json::from_str::(&json_err).ok(); let server_error = json::from_str::(&json_err) .or_else(|_| json::from_str::(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { 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) } } } } /// Required. Resource name of the publisher account to retrieve. /// Example: accounts/pub-9876543210987654 /// /// Sets the *name* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn name(mut self, new_value: &str) -> AccountGetCall<'a, C, A> { self._name = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AccountGetCall<'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 parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *callback* (query-string) - JSONP /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param(mut self, name: T, value: T) -> AccountGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Generates an AdMob Network report based on the provided report /// specification. /// /// A builder for the *networkReport.generate* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_admob1 as admob1; /// use admob1::GenerateNetworkReportRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use admob1::AdMob; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # ::default(), None); /// # let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::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 = GenerateNetworkReportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().network_report_generate(req, "parent") /// .doit(); /// # } /// ``` pub struct AccountNetworkReportGenerateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AdMob, _request: GenerateNetworkReportRequest, _parent: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for AccountNetworkReportGenerateCall<'a, C, A> {} impl<'a, C, A> AccountNetworkReportGenerateCall<'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, GenerateNetworkReportResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "admob.accounts.networkReport.generate", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].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 = self.hub._base_url.clone() + "v1/{+parent}/networkReport:generate"; 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 [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); 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).expect("serde to work"); 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.clone()) .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(); let json_server_error = json::from_str::(&json_err).ok(); let server_error = json::from_str::(&json_err) .or_else(|_| json::from_str::(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { 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: GenerateNetworkReportRequest) -> AccountNetworkReportGenerateCall<'a, C, A> { self._request = new_value; self } /// Resource name of the account to generate the report for. /// Example: accounts/pub-9876543210987654 /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> AccountNetworkReportGenerateCall<'a, C, A> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AccountNetworkReportGenerateCall<'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 parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *callback* (query-string) - JSONP /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param(mut self, name: T, value: T) -> AccountNetworkReportGenerateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Generates an AdMob Mediation report based on the provided report /// specification. /// /// A builder for the *mediationReport.generate* method supported by a *account* resource. /// It is not used directly, but through a `AccountMethods` instance. /// /// # Example /// /// Instantiate a resource method builder /// /// ```test_harness,no_run /// # extern crate hyper; /// # extern crate hyper_rustls; /// # extern crate yup_oauth2 as oauth2; /// # extern crate google_admob1 as admob1; /// use admob1::GenerateMediationReportRequest; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use admob1::AdMob; /// /// # let secret: ApplicationSecret = Default::default(); /// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate, /// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), /// # ::default(), None); /// # let mut hub = AdMob::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::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 = GenerateMediationReportRequest::default(); /// /// // You can configure optional parameters by calling the respective setters at will, and /// // execute the final call using `doit()`. /// // Values shown here are possibly random and not representative ! /// let result = hub.accounts().mediation_report_generate(req, "parent") /// .doit(); /// # } /// ``` pub struct AccountMediationReportGenerateCall<'a, C, A> where C: 'a, A: 'a { hub: &'a AdMob, _request: GenerateMediationReportRequest, _parent: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for AccountMediationReportGenerateCall<'a, C, A> {} impl<'a, C, A> AccountMediationReportGenerateCall<'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, GenerateMediationReportResponse)> { use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET}; use std::io::{Read, Seek}; use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location}; let mut dd = DefaultDelegate; let mut dlg: &mut dyn Delegate = match self._delegate { Some(d) => d, None => &mut dd }; dlg.begin(MethodInfo { id: "admob.accounts.mediationReport.generate", http_method: hyper::method::Method::Post }); let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); for &field in ["alt", "parent"].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 = self.hub._base_url.clone() + "v1/{+parent}/mediationReport:generate"; 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 [("{+parent}", "parent")].iter() { let mut replace_with = String::new(); for &(name, ref value) in params.iter() { if name == param_name { replace_with = value.to_string(); break; } } if find_this.as_bytes()[1] == '+' as u8 { replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET).to_string(); } url = url.replace(find_this, &replace_with); } { let mut indices_for_removal: Vec = Vec::with_capacity(1); for param_name in ["parent"].iter() { if let Some(index) = params.iter().position(|t| &t.0 == param_name) { indices_for_removal.push(index); } } for &index in indices_for_removal.iter() { params.remove(index); } } let url = hyper::Url::parse_with_params(&url, params).unwrap(); 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).expect("serde to work"); 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.clone()) .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(); let json_server_error = json::from_str::(&json_err).ok(); let server_error = json::from_str::(&json_err) .or_else(|_| json::from_str::(&json_err).map(|r| r.error)) .ok(); if let oauth2::Retry::After(d) = dlg.http_failure(&res, json_server_error, server_error) { 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: GenerateMediationReportRequest) -> AccountMediationReportGenerateCall<'a, C, A> { self._request = new_value; self } /// Resource name of the account to generate the report for. /// Example: accounts/pub-9876543210987654 /// /// Sets the *parent* path property to the given value. /// /// Even though the property as already been set when instantiating this call, /// we provide this method for API completeness. pub fn parent(mut self, new_value: &str) -> AccountMediationReportGenerateCall<'a, C, A> { self._parent = new_value.to_string(); self } /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong /// while executing the actual API request. /// /// It should be used to handle progress information, and to implement a certain level of resilience. /// /// Sets the *delegate* property to the given value. pub fn delegate(mut self, new_value: &'a mut dyn Delegate) -> AccountMediationReportGenerateCall<'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 parameters /// which have their own setter method. If done anyway, the request will fail. /// /// # Additional Parameters /// /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. /// * *access_token* (query-string) - OAuth access token. /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. /// * *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. /// * *callback* (query-string) - JSONP /// * *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. /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). /// * *alt* (query-string) - Data format for response. /// * *$.xgafv* (query-string) - V1 error format. pub fn param(mut self, name: T, value: T) -> AccountMediationReportGenerateCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } }