// DO NOT EDIT ! // This file was generated automatically from 'src/mako/api/lib.rs.mako' // DO NOT EDIT ! //! This documentation was generated from *Postmaster Tools* crate version *1.0.14+20200708*, where *20200708* is the exact revision of the *gmailpostmastertools:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.14*. //! //! Everything else about the *Postmaster Tools* *v1_beta1* API can be found at the //! [official documentation site](https://developers.google.com/gmail/postmaster). //! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/gmailpostmastertools1_beta1). //! # Features //! //! Handle the following *Resources* with ease from the central [hub](struct.PostmasterTools.html) ... //! //! * [domains](struct.Domain.html) //! * [*get*](struct.DomainGetCall.html), [*list*](struct.DomainListCall.html), [*traffic stats get*](struct.DomainTrafficStatGetCall.html) and [*traffic stats list*](struct.DomainTrafficStatListCall.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.PostmasterTools.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.domains().list(...).doit() //! let r = hub.domains().get(...).doit() //! let r = hub.domains().traffic_stats_list(...).doit() //! let r = hub.domains().traffic_stats_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-gmailpostmastertools1_beta1 = "*" //! # 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; //! use gmailpostmastertools1_beta1::{Result, Error}; //! # #[test] fn egal() { //! use std::default::Default; //! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; //! use gmailpostmastertools1_beta1::PostmasterTools; //! //! // 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 = PostmasterTools::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.domains().traffic_stats_list("parent") //! .start_date_year(-1) //! .start_date_month(-81) //! .start_date_day(-35) //! .page_token("sea") //! .page_size(-90) //! .end_date_year(-19) //! .end_date_month(-61) //! .end_date_day(-95) //! .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 PostmasterTools 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// use gmailpostmastertools1_beta1::{Result, Error}; /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use gmailpostmastertools1_beta1::PostmasterTools; /// /// // 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 = PostmasterTools::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.domains().traffic_stats_list("parent") /// .start_date_year(-66) /// .start_date_month(-61) /// .start_date_day(-21) /// .page_token("justo") /// .page_size(-34) /// .end_date_year(-17) /// .end_date_month(-41) /// .end_date_day(-55) /// .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 PostmasterTools { client: RefCell, auth: RefCell, _user_agent: String, _base_url: String, _root_url: String, } impl<'a, C, A> Hub for PostmasterTools {} impl<'a, C, A> PostmasterTools where C: BorrowMut, A: oauth2::GetToken { pub fn new(client: C, authenticator: A) -> PostmasterTools { PostmasterTools { client: RefCell::new(client), auth: RefCell::new(authenticator), _user_agent: "google-api-rust-client/1.0.14".to_string(), _base_url: "https://gmailpostmastertools.googleapis.com/".to_string(), _root_url: "https://gmailpostmastertools.googleapis.com/".to_string(), } } pub fn domains(&'a self) -> DomainMethods<'a, C, A> { DomainMethods { 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://gmailpostmastertools.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://gmailpostmastertools.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 ### // ########## /// A registered domain resource in the Postmaster API. /// /// # Activities /// /// This type is used in activities, which are methods you may call on this type or where this type is involved in. /// The list links the activity name, along with information about where it is used (one of *request* and *response*). /// /// * [list domains](struct.DomainListCall.html) (none) /// * [get domains](struct.DomainGetCall.html) (response) /// * [traffic stats list domains](struct.DomainTrafficStatListCall.html) (none) /// * [traffic stats get domains](struct.DomainTrafficStatGetCall.html) (none) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct Domain { /// Timestamp when the user registered this domain. Assigned by /// the server. #[serde(rename="createTime")] pub create_time: Option, /// The resource name of the Domain. /// Domain names have the form `domains/{domain_name}`, where domain_name /// is the fully qualified domain name (i.e., mymail.mydomain.com). pub name: Option, /// User’s permission for this domain. Assigned by the server. pub permission: Option, } impl Resource for Domain {} impl ResponseResult for Domain {} /// [Feedback loop](https://support.google.com/mail/answer/6254652) identifier /// information. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct FeedbackLoop { /// The ratio of user marked spam messages with the identifier vs the total /// number of inboxed messages with that identifier. #[serde(rename="spamRatio")] pub spam_ratio: Option, /// Feedback loop identifier that uniquely identifies individual campaigns. pub id: Option, } impl Part for FeedbackLoop {} /// Email traffic statistics pertaining to a specific date. /// /// # 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*). /// /// * [traffic stats get domains](struct.DomainTrafficStatGetCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct TrafficStats { /// Delivery errors for the domain. This metric only pertains to traffic that /// passed [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/). #[serde(rename="deliveryErrors")] pub delivery_errors: Option>, /// The resource name of the traffic statistics. Traffic statistic names have /// the form `domains/{domain}/trafficStats/{date}`, where /// domain_name is the fully qualified domain name (i.e., mymail.mydomain.com) /// of the domain this traffic statistics pertains to and date is the date in /// yyyymmdd format that these statistics corresponds to. /// For example: domains/mymail.mydomain.com/trafficStats/20160807 pub name: Option, /// Reputation information pertaining to the IP addresses of the email servers /// for the domain. There is exactly one entry for each reputation category /// except /// REPUTATION_CATEGORY_UNSPECIFIED. #[serde(rename="ipReputations")] pub ip_reputations: Option>, /// The ratio of user-report spam vs. email that was sent to the inbox. This /// metric only pertains to emails authenticated by /// [DKIM](http://www.dkim.org/). #[serde(rename="userReportedSpamRatio")] pub user_reported_spam_ratio: Option, /// Reputation of the domain. #[serde(rename="domainReputation")] pub domain_reputation: Option, /// The ratio of incoming mail (to Gmail), that passed secure transport (TLS) /// vs all mail received from that domain. This metric only pertains to traffic /// that passed [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/). #[serde(rename="inboundEncryptionRatio")] pub inbound_encryption_ratio: Option, /// The ratio of mail that passed [DMARC](https://dmarc.org/) alignment checks /// vs all mail received from the domain that successfully authenticated with /// either of [SPF](http://www.openspf.org/) or [DKIM](http://www.dkim.org/). #[serde(rename="dmarcSuccessRatio")] pub dmarc_success_ratio: Option, /// Spammy [Feedback loop identifiers] /// (https://support.google.com/mail/answer/6254652) with their individual spam /// rates. This metric only pertains to traffic that is authenticated by /// [DKIM](http://www.dkim.org/). #[serde(rename="spammyFeedbackLoops")] pub spammy_feedback_loops: Option>, /// The ratio of outgoing mail (from Gmail) that was accepted over secure /// transport (TLS). #[serde(rename="outboundEncryptionRatio")] pub outbound_encryption_ratio: Option, /// The ratio of mail that successfully authenticated with SPF vs. all mail /// that attempted to authenticate with [SPF](http://www.openspf.org/). Spoofed /// mail is excluded. #[serde(rename="spfSuccessRatio")] pub spf_success_ratio: Option, /// The ratio of mail that successfully authenticated with DKIM vs. all mail /// that attempted to authenticate with [DKIM](http://www.dkim.org/). Spoofed /// mail is excluded. #[serde(rename="dkimSuccessRatio")] pub dkim_success_ratio: Option, } impl ResponseResult for TrafficStats {} /// Metric on a particular delivery error type. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct DeliveryError { /// The class of delivery error. #[serde(rename="errorClass")] pub error_class: Option, /// The type of delivery error. #[serde(rename="errorType")] pub error_type: Option, /// The ratio of messages where the error occurred vs all authenticated /// traffic. #[serde(rename="errorRatio")] pub error_ratio: Option, } impl Part for DeliveryError {} /// Response message for ListDomains. /// /// # 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 domains](struct.DomainListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListDomainsResponse { /// The list of domains. pub domains: Option>, /// Token to retrieve the next page of results, or empty if there are no /// more results in the list. #[serde(rename="nextPageToken")] pub next_page_token: Option, } impl ResponseResult for ListDomainsResponse {} /// Response message for ListTrafficStats. /// /// # 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*). /// /// * [traffic stats list domains](struct.DomainTrafficStatListCall.html) (response) /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct ListTrafficStatsResponse { /// Token to retrieve the next page of results, or empty if there are no /// more results in the list. #[serde(rename="nextPageToken")] pub next_page_token: Option, /// The list of TrafficStats. #[serde(rename="trafficStats")] pub traffic_stats: Option>, } impl ResponseResult for ListTrafficStatsResponse {} /// IP Reputation information for a set of IPs in a specific reputation category. /// /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(Default, Clone, Debug, Serialize, Deserialize)] pub struct IpReputation { /// A sample of IPs in this reputation category. #[serde(rename="sampleIps")] pub sample_ips: Option>, /// The reputation category this IP reputation represents. pub reputation: Option, /// Total number of unique IPs in this reputation category. This metric only /// pertains to traffic that passed [SPF](http://www.openspf.org/) or /// [DKIM](http://www.dkim.org/). #[serde(rename="numIps")] pub num_ips: Option, } impl Part for IpReputation {} // ################### // MethodBuilders ### // ################# /// A builder providing access to all methods supported on *domain* resources. /// It is not used directly, but through the `PostmasterTools` 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// /// # #[test] fn egal() { /// use std::default::Default; /// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// use gmailpostmastertools1_beta1::PostmasterTools; /// /// 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 = PostmasterTools::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(...)`, `traffic_stats_get(...)` and `traffic_stats_list(...)` /// // to build up your call. /// let rb = hub.domains(); /// # } /// ``` pub struct DomainMethods<'a, C, A> where C: 'a, A: 'a { hub: &'a PostmasterTools, } impl<'a, C, A> MethodsBuilder for DomainMethods<'a, C, A> {} impl<'a, C, A> DomainMethods<'a, C, A> { /// Create a builder to help you perform the following task: /// /// Lists the domains that have been registered by the client. The order of /// domains in the response is unspecified and non-deterministic. Newly created /// domains will not necessarily be added to the end of this list. pub fn list(&self) -> DomainListCall<'a, C, A> { DomainListCall { 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 a specific domain registered by the client. /// Returns NOT_FOUND if the domain does not exist. /// /// # Arguments /// /// * `name` - The resource name of the domain. It should have the form /// `domains/{domain_name}`, where domain_name is the fully qualified /// domain name. pub fn get(&self, name: &str) -> DomainGetCall<'a, C, A> { DomainGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// List traffic statistics for all available days. /// Returns PERMISSION_DENIED if user does not have permission to access /// TrafficStats for the domain. /// /// # Arguments /// /// * `parent` - The resource name of the domain whose traffic statistics we'd like to list. /// It should have the form `domains/{domain_name}`, where domain_name is /// the fully qualified domain name. pub fn traffic_stats_list(&self, parent: &str) -> DomainTrafficStatListCall<'a, C, A> { DomainTrafficStatListCall { hub: self.hub, _parent: parent.to_string(), _start_date_year: Default::default(), _start_date_month: Default::default(), _start_date_day: Default::default(), _page_token: Default::default(), _page_size: Default::default(), _end_date_year: Default::default(), _end_date_month: Default::default(), _end_date_day: Default::default(), _delegate: Default::default(), _additional_params: Default::default(), } } /// Create a builder to help you perform the following task: /// /// Get traffic statistics for a domain on a specific date. /// Returns PERMISSION_DENIED if user does not have permission to access /// TrafficStats for the domain. /// /// # Arguments /// /// * `name` - The resource name of the traffic statistics to get. /// E.g., domains/mymail.mydomain.com/trafficStats/20160807. pub fn traffic_stats_get(&self, name: &str) -> DomainTrafficStatGetCall<'a, C, A> { DomainTrafficStatGetCall { hub: self.hub, _name: name.to_string(), _delegate: Default::default(), _additional_params: Default::default(), } } } // ################### // CallBuilders ### // ################# /// Lists the domains that have been registered by the client. The order of /// domains in the response is unspecified and non-deterministic. Newly created /// domains will not necessarily be added to the end of this list. /// /// A builder for the *list* method supported by a *domain* resource. /// It is not used directly, but through a `DomainMethods` 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use gmailpostmastertools1_beta1::PostmasterTools; /// /// # 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 = PostmasterTools::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.domains().list() /// .page_token("Lorem") /// .page_size(-21) /// .doit(); /// # } /// ``` pub struct DomainListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a PostmasterTools, _page_token: Option, _page_size: Option, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for DomainListCall<'a, C, A> {} impl<'a, C, A> DomainListCall<'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, ListDomainsResponse)> { 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: "gmailpostmastertools.domains.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() + "v1beta1/domains"; 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 next_page_token value returned from a previous List request, if any. /// This is the value of /// ListDomainsResponse.next_page_token /// returned from the previous call to `ListDomains` method. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DomainListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Requested page size. Server may return fewer domains than requested. /// If unspecified, server will pick an appropriate default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> DomainListCall<'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) -> DomainListCall<'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) -> DomainListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Gets a specific domain registered by the client. /// Returns NOT_FOUND if the domain does not exist. /// /// A builder for the *get* method supported by a *domain* resource. /// It is not used directly, but through a `DomainMethods` 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use gmailpostmastertools1_beta1::PostmasterTools; /// /// # 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 = PostmasterTools::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.domains().get("name") /// .doit(); /// # } /// ``` pub struct DomainGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a PostmasterTools, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for DomainGetCall<'a, C, A> {} impl<'a, C, A> DomainGetCall<'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, Domain)> { 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: "gmailpostmastertools.domains.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() + "v1beta1/{+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) } } } } /// The resource name of the domain. It should have the form /// `domains/{domain_name}`, where domain_name is the fully qualified /// domain name. /// /// 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) -> DomainGetCall<'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) -> DomainGetCall<'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) -> DomainGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// List traffic statistics for all available days. /// Returns PERMISSION_DENIED if user does not have permission to access /// TrafficStats for the domain. /// /// A builder for the *trafficStats.list* method supported by a *domain* resource. /// It is not used directly, but through a `DomainMethods` 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use gmailpostmastertools1_beta1::PostmasterTools; /// /// # 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 = PostmasterTools::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.domains().traffic_stats_list("parent") /// .start_date_year(-9) /// .start_date_month(-55) /// .start_date_day(-75) /// .page_token("erat") /// .page_size(-95) /// .end_date_year(-48) /// .end_date_month(-39) /// .end_date_day(-43) /// .doit(); /// # } /// ``` pub struct DomainTrafficStatListCall<'a, C, A> where C: 'a, A: 'a { hub: &'a PostmasterTools, _parent: String, _start_date_year: Option, _start_date_month: Option, _start_date_day: Option, _page_token: Option, _page_size: Option, _end_date_year: Option, _end_date_month: Option, _end_date_day: Option, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for DomainTrafficStatListCall<'a, C, A> {} impl<'a, C, A> DomainTrafficStatListCall<'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, ListTrafficStatsResponse)> { 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: "gmailpostmastertools.domains.trafficStats.list", http_method: hyper::method::Method::Get }); let mut params: Vec<(&str, String)> = Vec::with_capacity(11 + self._additional_params.len()); params.push(("parent", self._parent.to_string())); if let Some(value) = self._start_date_year { params.push(("startDate.year", value.to_string())); } if let Some(value) = self._start_date_month { params.push(("startDate.month", value.to_string())); } if let Some(value) = self._start_date_day { params.push(("startDate.day", value.to_string())); } 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())); } if let Some(value) = self._end_date_year { params.push(("endDate.year", value.to_string())); } if let Some(value) = self._end_date_month { params.push(("endDate.month", value.to_string())); } if let Some(value) = self._end_date_day { params.push(("endDate.day", value.to_string())); } for &field in ["alt", "parent", "startDate.year", "startDate.month", "startDate.day", "pageToken", "pageSize", "endDate.year", "endDate.month", "endDate.day"].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() + "v1beta1/{+parent}/trafficStats"; 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(); 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 resource name of the domain whose traffic statistics we'd like to list. /// It should have the form `domains/{domain_name}`, where domain_name is /// the fully qualified domain name. /// /// 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) -> DomainTrafficStatListCall<'a, C, A> { self._parent = new_value.to_string(); self } /// Year of date. Must be from 1 to 9999, or 0 if specifying a date without /// a year. /// /// Sets the *start date.year* query property to the given value. pub fn start_date_year(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._start_date_year = Some(new_value); self } /// Month of year. Must be from 1 to 12, or 0 if specifying a year without a /// month and day. /// /// Sets the *start date.month* query property to the given value. pub fn start_date_month(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._start_date_month = Some(new_value); self } /// 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. /// /// Sets the *start date.day* query property to the given value. pub fn start_date_day(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._start_date_day = Some(new_value); self } /// The next_page_token value returned from a previous List request, if any. /// This is the value of /// ListTrafficStatsResponse.next_page_token /// returned from the previous call to `ListTrafficStats` method. /// /// Sets the *page token* query property to the given value. pub fn page_token(mut self, new_value: &str) -> DomainTrafficStatListCall<'a, C, A> { self._page_token = Some(new_value.to_string()); self } /// Requested page size. Server may return fewer TrafficStats than /// requested. If unspecified, server will pick an appropriate default. /// /// Sets the *page size* query property to the given value. pub fn page_size(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._page_size = Some(new_value); self } /// Year of date. Must be from 1 to 9999, or 0 if specifying a date without /// a year. /// /// Sets the *end date.year* query property to the given value. pub fn end_date_year(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._end_date_year = Some(new_value); self } /// Month of year. Must be from 1 to 12, or 0 if specifying a year without a /// month and day. /// /// Sets the *end date.month* query property to the given value. pub fn end_date_month(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._end_date_month = Some(new_value); self } /// 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. /// /// Sets the *end date.day* query property to the given value. pub fn end_date_day(mut self, new_value: i32) -> DomainTrafficStatListCall<'a, C, A> { self._end_date_day = 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) -> DomainTrafficStatListCall<'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) -> DomainTrafficStatListCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } } /// Get traffic statistics for a domain on a specific date. /// Returns PERMISSION_DENIED if user does not have permission to access /// TrafficStats for the domain. /// /// A builder for the *trafficStats.get* method supported by a *domain* resource. /// It is not used directly, but through a `DomainMethods` 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_gmailpostmastertools1_beta1 as gmailpostmastertools1_beta1; /// # #[test] fn egal() { /// # use std::default::Default; /// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage}; /// # use gmailpostmastertools1_beta1::PostmasterTools; /// /// # 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 = PostmasterTools::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.domains().traffic_stats_get("name") /// .doit(); /// # } /// ``` pub struct DomainTrafficStatGetCall<'a, C, A> where C: 'a, A: 'a { hub: &'a PostmasterTools, _name: String, _delegate: Option<&'a mut dyn Delegate>, _additional_params: HashMap, } impl<'a, C, A> CallBuilder for DomainTrafficStatGetCall<'a, C, A> {} impl<'a, C, A> DomainTrafficStatGetCall<'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, TrafficStats)> { 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: "gmailpostmastertools.domains.trafficStats.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() + "v1beta1/{+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) } } } } /// The resource name of the traffic statistics to get. /// E.g., domains/mymail.mydomain.com/trafficStats/20160807. /// /// 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) -> DomainTrafficStatGetCall<'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) -> DomainTrafficStatGetCall<'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) -> DomainTrafficStatGetCall<'a, C, A> where T: AsRef { self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); self } }