diff --git a/gen/docs1/Cargo.toml b/gen/docs1/Cargo.toml new file mode 100644 index 0000000000..ac8124372f --- /dev/null +++ b/gen/docs1/Cargo.toml @@ -0,0 +1,31 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/mako/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-dns1" +version = "2.0.8+20210319" +authors = ["Sebastian Thiel "] +description = "A complete library to interact with Dns (protocol v1)" +repository = "https://github.com/Byron/google-apis-rs/tree/main/gen/dns1" +homepage = "https://cloud.google.com/dns/docs" +documentation = "https://docs.rs/google-dns1/2.0.8+20210319" +license = "MIT" +keywords = ["dns", "google", "protocol", "web", "api"] +autobins = false +edition = "2018" + + +[dependencies] +hyper-rustls = "^0.22" +mime = "^ 0.2.0" +serde = "^ 1.0" +serde_json = "^ 1.0" +serde_derive = "^ 1.0" +yup-oauth2 = "^ 5.0" +itertools = "^ 0.10" +hyper = "^ 0.14" +url = "= 1.7" + + + diff --git a/gen/docs1/LICENSE.md b/gen/docs1/LICENSE.md new file mode 100644 index 0000000000..d2306e20eb --- /dev/null +++ b/gen/docs1/LICENSE.md @@ -0,0 +1,30 @@ + +The MIT License (MIT) +===================== + +Copyright © `2015-2020` `Sebastian Thiel` + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/docs1/README.md b/gen/docs1/README.md new file mode 100644 index 0000000000..07d124f8cd --- /dev/null +++ b/gen/docs1/README.md @@ -0,0 +1,201 @@ + +The `google-dns1` library allows access to all features of the *Google Dns* service. + +This documentation was generated from *Dns* crate version *2.0.8+20210319*, where *20210319* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v2.0.8*. + +Everything else about the *Dns* *v1* API can be found at the +[official documentation site](https://cloud.google.com/dns/docs). +# Features + +Handle the following *Resources* with ease from the central [hub](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/Dns) ... + +* [changes](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::Change) + * [*create*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ChangeCreateCall), [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ChangeGetCall) and [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ChangeListCall) +* [dns keys](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::DnsKey) + * [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::DnsKeyGetCall) and [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::DnsKeyListCall) +* managed zone operations + * [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneOperationGetCall) and [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneOperationListCall) +* [managed zones](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZone) + * [*create*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneCreateCall), [*delete*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneDeleteCall), [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneGetCall), [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneListCall), [*patch*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZonePatchCall) and [*update*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ManagedZoneUpdateCall) +* [policies](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::Policy) + * [*create*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyCreateCall), [*delete*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyDeleteCall), [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyGetCall), [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyListCall), [*patch*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyPatchCall) and [*update*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::PolicyUpdateCall) +* [projects](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::Project) + * [*get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ProjectGetCall), [*managed zones rrsets create*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ProjectManagedZoneRrsetCreateCall), [*managed zones rrsets delete*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ProjectManagedZoneRrsetDeleteCall), [*managed zones rrsets get*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ProjectManagedZoneRrsetGetCall) and [*managed zones rrsets patch*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ProjectManagedZoneRrsetPatchCall) +* [resource record sets](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ResourceRecordSet) + * [*list*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/api::ResourceRecordSetListCall) + + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/Dns)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::MethodsBuilder) which in turn + allow access to individual [*Call Builders*](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::CallBuilder) +* **[Resources](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Resource)** + * primary types that you can apply *Activities* to + * a collection of properties and *Parts* + * **[Parts](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Part)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::CallBuilder)** + * 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().await +``` + +Or specifically ... + +```ignore +let r = hub.managed_zones().create(...).doit().await +let r = hub.managed_zones().delete(...).doit().await +let r = hub.managed_zones().get(...).doit().await +let r = hub.managed_zones().list(...).doit().await +let r = hub.managed_zones().patch(...).doit().await +let r = hub.managed_zones().update(...).doit().await +``` + +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-dns1 = "*" +hyper = "^0.14" +hyper-rustls = "^0.22" +serde = "^1.0" +serde_json = "^1.0" +yup-oauth2 = "^5.0" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate hyper_rustls; +extern crate yup_oauth2 as oauth2; +extern crate google_dns1 as dns1; +use dns1::{Result, Error}; +use std::default::Default; +use oauth2; +use dns1::Dns; + +// Get an ApplicationSecret instance by some means. It contains the `client_id` and +// `client_secret`, among other things. +let secret: oauth2::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 = yup_oauth2::InstalledFlowAuthenticator::builder( + secret, + yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, + ).build().await.unwrap(); +let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().list("project") + .page_token("magna") + .max_results(-11) + .dns_name("ipsum") + .doit().await; + +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::Io(_) + |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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Result) enumeration as return value of +the doit() methods, or handed as possibly intermediate results to either the +[Hub Delegate](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Delegate), 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Result), should be +read by you to obtain the media. +If such a method also supports a [Response Result](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::ResponseResult), 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Delegate) to the +[Method Builder](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::CallBuilder) 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Delegate) 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::RequestValue) and +[decodable](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses +are valid. +Most optionals are are considered [Parts](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::Part) 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::CallBuilder), 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](https://docs.rs/google-dns1/2.0.8+20210319/google_dns1/client::RequestValue) 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 + +# License +The **dns1** library was generated by Sebastian Thiel, and is placed +under the *MIT* license. +You can read the full text at the repository's [license file][repo-license]. + +[repo-license]: https://github.com/Byron/google-apis-rsblob/main/LICENSE.md diff --git a/gen/docs1/src/api.rs b/gen/docs1/src/api.rs new file mode 100644 index 0000000000..9229aed1da --- /dev/null +++ b/gen/docs1/src/api.rs @@ -0,0 +1,9309 @@ +use std::collections::HashMap; +use std::cell::RefCell; +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 crate::client; + +// ############## +// UTILITIES ### +// ############ + +/// Identifies the an OAuth2 authorization scope. +/// A scope is needed when requesting an +/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication). +#[derive(PartialEq, Eq, Hash)] +pub enum Scope { + /// See, edit, configure, and delete your Google Cloud Platform data + CloudPlatform, + + /// View your data across Google Cloud Platform services + CloudPlatformReadOnly, + + /// View your DNS records hosted by Google Cloud DNS + NdevClouddnReadonly, + + /// View and manage your DNS records hosted by Google Cloud DNS + NdevClouddnReadwrite, +} + +impl AsRef for Scope { + fn as_ref(&self) -> &str { + match *self { + Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform", + Scope::CloudPlatformReadOnly => "https://www.googleapis.com/auth/cloud-platform.read-only", + Scope::NdevClouddnReadonly => "https://www.googleapis.com/auth/ndev.clouddns.readonly", + Scope::NdevClouddnReadwrite => "https://www.googleapis.com/auth/ndev.clouddns.readwrite", + } + } +} + +impl Default for Scope { + fn default() -> Scope { + Scope::NdevClouddnReadonly + } +} + + + +// ######## +// HUB ### +// ###### + +/// Central instance to access all Dns 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_dns1 as dns1; +/// use dns1::{Result, Error}; +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and +/// // `client_secret`, among other things. +/// let secret: oauth2::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 = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().list("project") +/// .page_token("takimata") +/// .max_results(-52) +/// .dns_name("duo") +/// .doit().await; +/// +/// 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::Io(_) +/// |Error::MissingAPIKey +/// |Error::MissingToken(_) +/// |Error::Cancelled +/// |Error::UploadSizeLimitExceeded(_, _) +/// |Error::Failure(_) +/// |Error::BadRequest(_) +/// |Error::FieldClash(_) +/// |Error::JsonDecodeError(_, _) => println!("{}", e), +/// }, +/// Ok(res) => println!("Success: {:?}", res), +/// } +/// # } +/// ``` +#[derive(Clone)] +pub struct Dns<> { + client: hyper::Client, hyper::body::Body>, + auth: oauth2::authenticator::Authenticator>, + _user_agent: String, + _base_url: String, + _root_url: String, +} + +impl<'a, > client::Hub for Dns<> {} + +impl<'a, > Dns<> { + + pub fn new(client: hyper::Client, hyper::body::Body>, authenticator: oauth2::authenticator::Authenticator>) -> Dns<> { + Dns { + client, + auth: authenticator, + _user_agent: "google-api-rust-client/2.0.8".to_string(), + _base_url: "https://dns.googleapis.com/".to_string(), + _root_url: "https://dns.googleapis.com/".to_string(), + } + } + + pub fn changes(&'a self) -> ChangeMethods<'a> { + ChangeMethods { hub: &self } + } + pub fn dns_keys(&'a self) -> DnsKeyMethods<'a> { + DnsKeyMethods { hub: &self } + } + pub fn managed_zone_operations(&'a self) -> ManagedZoneOperationMethods<'a> { + ManagedZoneOperationMethods { hub: &self } + } + pub fn managed_zones(&'a self) -> ManagedZoneMethods<'a> { + ManagedZoneMethods { hub: &self } + } + pub fn policies(&'a self) -> PolicyMethods<'a> { + PolicyMethods { hub: &self } + } + pub fn projects(&'a self) -> ProjectMethods<'a> { + ProjectMethods { hub: &self } + } + pub fn resource_record_sets(&'a self) -> ResourceRecordSetMethods<'a> { + ResourceRecordSetMethods { hub: &self } + } + + /// Set the user-agent header field to use in all requests to the server. + /// It defaults to `google-api-rust-client/2.0.8`. + /// + /// 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://dns.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://dns.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 Change represents a set of ResourceRecordSet additions and deletions applied atomically to a ManagedZone. ResourceRecordSets within a ManagedZone are modified by creating a new Change element in the Changes collection. In turn the Changes collection also records the past modifications to the ResourceRecordSets in a ManagedZone. The current state of the ManagedZone is the sum effect of applying all Change elements in the Changes collection in sequence. +/// +/// # 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*). +/// +/// * [create changes](ChangeCreateCall) (request|response) +/// * [get changes](ChangeGetCall) (response) +/// * [list changes](ChangeListCall) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Change { + /// Which ResourceRecordSets to add? + pub additions: Option>, + /// Which ResourceRecordSets to remove? Must match existing data exactly. + pub deletions: Option>, + /// Unique identifier for the resource; defined by the server (output only). + pub id: Option, + /// If the DNS queries for the zone will be served. + #[serde(rename="isServing")] + pub is_serving: Option, + /// no description provided + pub kind: Option, + /// The time that this operation was started by the server (output only). This is in RFC3339 text format. + #[serde(rename="startTime")] + pub start_time: Option, + /// Status of the operation (output only). A status of "done" means that the request to update the authoritative servers has been sent, but the servers might not be updated yet. + pub status: Option, +} + +impl client::RequestValue for Change {} +impl client::Resource for Change {} +impl client::ResponseResult for Change {} + + +/// The response to a request to enumerate Changes to a ResourceRecordSets collection. +/// +/// # 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 changes](ChangeListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChangesListResponse { + /// The requested changes. + pub changes: Option>, + /// no description provided + pub header: Option, + /// Type of resource. + pub kind: Option, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your pagination token. This lets you retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You cannot retrieve a "snapshot" of collections larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl client::ResponseResult for ChangesListResponse {} + + +/// A DNSSEC key pair. +/// +/// # 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 dns keys](DnsKeyGetCall) (response) +/// * [list dns keys](DnsKeyListCall) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DnsKey { + /// String mnemonic specifying the DNSSEC algorithm of this key. Immutable after creation time. + pub algorithm: Option, + /// The time that this resource was created in the control plane. This is in RFC3339 text format. Output only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the resource's function. + pub description: Option, + /// Cryptographic hashes of the DNSKEY resource record associated with this DnsKey. These digests are needed to construct a DS record that points at this DNS key. Output only. + pub digests: Option>, + /// Unique identifier for the resource; defined by the server (output only). + pub id: Option, + /// Active keys are used to sign subsequent changes to the ManagedZone. Inactive keys are still present as DNSKEY Resource Records for the use of resolvers validating existing signatures. + #[serde(rename="isActive")] + pub is_active: Option, + /// Length of the key in bits. Specified at creation time, and then immutable. + #[serde(rename="keyLength")] + pub key_length: Option, + /// The key tag is a non-cryptographic hash of the a DNSKEY resource record associated with this DnsKey. The key tag can be used to identify a DNSKEY more quickly (but it is not a unique identifier). In particular, the key tag is used in a parent zone's DS record to point at the DNSKEY in this child ManagedZone. The key tag is a number in the range [0, 65535] and the algorithm to calculate it is specified in RFC4034 Appendix B. Output only. + #[serde(rename="keyTag")] + pub key_tag: Option, + /// no description provided + pub kind: Option, + /// Base64 encoded public half of this key. Output only. + #[serde(rename="publicKey")] + pub public_key: Option, + /// One of "KEY_SIGNING" or "ZONE_SIGNING". Keys of type KEY_SIGNING have the Secure Entry Point flag set and, when active, are used to sign only resource record sets of type DNSKEY. Otherwise, the Secure Entry Point flag is cleared, and this key is used to sign only resource record sets of other types. Immutable after creation time. + #[serde(rename="type")] + pub type_: Option, +} + +impl client::Resource for DnsKey {} +impl client::ResponseResult for DnsKey {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DnsKeyDigest { + /// The base-16 encoded bytes of this digest. Suitable for use in a DS resource record. + pub digest: Option, + /// Specifies the algorithm used to calculate this digest. + #[serde(rename="type")] + pub type_: Option, +} + +impl client::Part for DnsKeyDigest {} + + +/// Parameters for DnsKey key generation. Used for generating initial keys for a new ManagedZone and as default when adding a new DnsKey. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DnsKeySpec { + /// String mnemonic specifying the DNSSEC algorithm of this key. + pub algorithm: Option, + /// Length of the keys in bits. + #[serde(rename="keyLength")] + pub key_length: Option, + /// Specifies whether this is a key signing key (KSK) or a zone signing key (ZSK). Key signing keys have the Secure Entry Point flag set and, when active, are only used to sign resource record sets of type DNSKEY. Zone signing keys do not have the Secure Entry Point flag set and are used to sign all other types of resource record sets. + #[serde(rename="keyType")] + pub key_type: Option, + /// no description provided + pub kind: Option, +} + +impl client::Part for DnsKeySpec {} + + +/// The response to a request to enumerate DnsKeys in a ManagedZone. +/// +/// # 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 dns keys](DnsKeyListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct DnsKeysListResponse { + /// The requested resources. + #[serde(rename="dnsKeys")] + pub dns_keys: Option>, + /// no description provided + pub header: Option, + /// Type of resource. + pub kind: Option, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your pagination token. In this way you can retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. There is no way to retrieve a "snapshot" of collections larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl client::ResponseResult for DnsKeysListResponse {} + + +/// A zone is a subtree of the DNS namespace under one administrative responsibility. A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service. +/// +/// # 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*). +/// +/// * [create managed zones](ManagedZoneCreateCall) (request|response) +/// * [delete managed zones](ManagedZoneDeleteCall) (none) +/// * [get managed zones](ManagedZoneGetCall) (response) +/// * [list managed zones](ManagedZoneListCall) (none) +/// * [patch managed zones](ManagedZonePatchCall) (request) +/// * [update managed zones](ManagedZoneUpdateCall) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZone { + /// The time that this resource was created on the server. This is in RFC3339 text format. Output only. + #[serde(rename="creationTime")] + pub creation_time: Option, + /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the managed zone's function. + pub description: Option, + /// The DNS name of this managed zone, for instance "example.com.". + #[serde(rename="dnsName")] + pub dns_name: Option, + /// DNSSEC configuration. + #[serde(rename="dnssecConfig")] + pub dnssec_config: Option, + /// The presence for this field indicates that outbound forwarding is enabled for this zone. The value of this field contains the set of destinations to forward to. + #[serde(rename="forwardingConfig")] + pub forwarding_config: Option, + /// Unique identifier for the resource; defined by the server (output only) + pub id: Option, + /// no description provided + pub kind: Option, + /// User labels. + pub labels: Option>, + /// User assigned name for this resource. Must be unique within the project. The name must be 1-63 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes. + pub name: Option, + /// Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users leave this field unset. If you need to use this field, contact your account team. + #[serde(rename="nameServerSet")] + pub name_server_set: Option, + /// Delegate your managed_zone to these virtual name servers; defined by the server (output only) + #[serde(rename="nameServers")] + pub name_servers: Option>, + /// The presence of this field indicates that DNS Peering is enabled for this zone. The value of this field contains the network to peer with. + #[serde(rename="peeringConfig")] + pub peering_config: Option, + /// For privately visible zones, the set of Virtual Private Cloud resources that the zone is visible from. + #[serde(rename="privateVisibilityConfig")] + pub private_visibility_config: Option, + /// The presence of this field indicates that this is a managed reverse lookup zone and Cloud DNS resolves reverse lookup queries using automatically configured records for VPC resources. This only applies to networks listed under private_visibility_config. + #[serde(rename="reverseLookupConfig")] + pub reverse_lookup_config: Option, + /// This field links to the associated service directory namespace. Do not set this field for public zones or forwarding zones. + #[serde(rename="serviceDirectoryConfig")] + pub service_directory_config: Option, + /// The zone's visibility: public zones are exposed to the Internet, while private zones are visible only to Virtual Private Cloud resources. + pub visibility: Option, +} + +impl client::RequestValue for ManagedZone {} +impl client::Resource for ManagedZone {} +impl client::ResponseResult for ManagedZone {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneDnsSecConfig { + /// Specifies parameters for generating initial DnsKeys for this ManagedZone. Can only be changed while the state is OFF. + #[serde(rename="defaultKeySpecs")] + pub default_key_specs: Option>, + /// no description provided + pub kind: Option, + /// Specifies the mechanism for authenticated denial-of-existence responses. Can only be changed while the state is OFF. + #[serde(rename="nonExistence")] + pub non_existence: Option, + /// Specifies whether DNSSEC is enabled, and what mode it is in. + pub state: Option, +} + +impl client::Part for ManagedZoneDnsSecConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneForwardingConfig { + /// no description provided + pub kind: Option, + /// List of target name servers to forward to. Cloud DNS selects the best available name server if more than one target is given. + #[serde(rename="targetNameServers")] + pub target_name_servers: Option>, +} + +impl client::Part for ManagedZoneForwardingConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneForwardingConfigNameServerTarget { + /// Forwarding path for this NameServerTarget. If unset or set to DEFAULT, Cloud DNS makes forwarding decisions based on IP address ranges; that is, RFC1918 addresses go to the VPC network, non-RFC1918 addresses go to the internet. When set to PRIVATE, Cloud DNS always sends queries through the VPC network for this target. + #[serde(rename="forwardingPath")] + pub forwarding_path: Option, + /// IPv4 address of a target name server. + #[serde(rename="ipv4Address")] + pub ipv4_address: Option, + /// no description provided + pub kind: Option, +} + +impl client::Part for ManagedZoneForwardingConfigNameServerTarget {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list managed zone operations](ManagedZoneOperationListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneOperationsListResponse { + /// no description provided + pub header: Option, + /// no description provided + pub kind: Option, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your page token. This lets you retrieve the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You cannot retrieve a consistent snapshot of a collection larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The operation resources. + pub operations: Option>, +} + +impl client::ResponseResult for ManagedZoneOperationsListResponse {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZonePeeringConfig { + /// no description provided + pub kind: Option, + /// The network with which to peer. + #[serde(rename="targetNetwork")] + pub target_network: Option, +} + +impl client::Part for ManagedZonePeeringConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZonePeeringConfigTargetNetwork { + /// The time at which the zone was deactivated, in RFC 3339 date-time format. An empty string indicates that the peering connection is active. The producer network can deactivate a zone. The zone is automatically deactivated if the producer network that the zone targeted is deleted. Output only. + #[serde(rename="deactivateTime")] + pub deactivate_time: Option, + /// no description provided + pub kind: Option, + /// The fully qualified URL of the VPC network to forward queries to. This should be formatted like https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + #[serde(rename="networkUrl")] + pub network_url: Option, +} + +impl client::Part for ManagedZonePeeringConfigTargetNetwork {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZonePrivateVisibilityConfig { + /// no description provided + pub kind: Option, + /// The list of VPC networks that can see this zone. + pub networks: Option>, +} + +impl client::Part for ManagedZonePrivateVisibilityConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZonePrivateVisibilityConfigNetwork { + /// no description provided + pub kind: Option, + /// The fully qualified URL of the VPC network to bind to. Format this URL like https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + #[serde(rename="networkUrl")] + pub network_url: Option, +} + +impl client::Part for ManagedZonePrivateVisibilityConfigNetwork {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneReverseLookupConfig { + /// no description provided + pub kind: Option, +} + +impl client::Part for ManagedZoneReverseLookupConfig {} + + +/// Contains information about Service Directory-backed zones. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneServiceDirectoryConfig { + /// no description provided + pub kind: Option, + /// Contains information about the namespace associated with the zone. + pub namespace: Option, +} + +impl client::Part for ManagedZoneServiceDirectoryConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZoneServiceDirectoryConfigNamespace { + /// The time that the namespace backing this zone was deleted; an empty string if it still exists. This is in RFC3339 text format. Output only. + #[serde(rename="deletionTime")] + pub deletion_time: Option, + /// no description provided + pub kind: Option, + /// The fully qualified URL of the namespace associated with the zone. Format must be https://servicedirectory.googleapis.com/v1/projects/{project}/locations/{location}/namespaces/{namespace} + #[serde(rename="namespaceUrl")] + pub namespace_url: Option, +} + +impl client::Part for ManagedZoneServiceDirectoryConfigNamespace {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list managed zones](ManagedZoneListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ManagedZonesListResponse { + /// no description provided + pub header: Option, + /// Type of resource. + pub kind: Option, + /// The managed zone resources. + #[serde(rename="managedZones")] + pub managed_zones: Option>, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your page token. This lets you the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You cannot retrieve a consistent snapshot of a collection larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, +} + +impl client::ResponseResult for ManagedZonesListResponse {} + + +/// An operation represents a successful mutation performed on a Cloud DNS resource. Operations provide: - An audit log of server resource mutations. - A way to recover/retry API calls in the case where the response is never received by the caller. Use the caller specified client_operation_id. +/// +/// # 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 managed zone operations](ManagedZoneOperationGetCall) (response) +/// * [patch managed zones](ManagedZonePatchCall) (response) +/// * [update managed zones](ManagedZoneUpdateCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Operation { + /// Only populated if the operation targeted a DnsKey (output only). + #[serde(rename="dnsKeyContext")] + pub dns_key_context: Option, + /// Unique identifier for the resource. This is the client_operation_id if the client specified it when the mutation was initiated, otherwise, it is generated by the server. The name must be 1-63 characters long and match the regular expression [-a-z0-9]? (output only) + pub id: Option, + /// no description provided + pub kind: Option, + /// The time that this operation was started by the server. This is in RFC3339 text format (output only). + #[serde(rename="startTime")] + pub start_time: Option, + /// Status of the operation. Can be one of the following: "PENDING" or "DONE" (output only). A status of "DONE" means that the request to update the authoritative servers has been sent, but the servers might not be updated yet. + pub status: Option, + /// Type of the operation. Operations include insert, update, and delete (output only). + #[serde(rename="type")] + pub type_: Option, + /// User who requested the operation, for example: user@example.com. cloud-dns-system for operations automatically done by the system. (output only) + pub user: Option, + /// Only populated if the operation targeted a ManagedZone (output only). + #[serde(rename="zoneContext")] + pub zone_context: Option, +} + +impl client::ResponseResult for Operation {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperationDnsKeyContext { + /// The post-operation DnsKey resource. + #[serde(rename="newValue")] + pub new_value: Option, + /// The pre-operation DnsKey resource. + #[serde(rename="oldValue")] + pub old_value: Option, +} + +impl client::Part for OperationDnsKeyContext {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct OperationManagedZoneContext { + /// The post-operation ManagedZone resource. + #[serde(rename="newValue")] + pub new_value: Option, + /// The pre-operation ManagedZone resource. + #[serde(rename="oldValue")] + pub old_value: Option, +} + +impl client::Part for OperationManagedZoneContext {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list policies](PolicyListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PoliciesListResponse { + /// no description provided + pub header: Option, + /// Type of resource. + pub kind: Option, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your page token. This lets you the complete contents of even very large collections one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You cannot retrieve a consistent snapshot of a collection larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The policy resources. + pub policies: Option>, +} + +impl client::ResponseResult for PoliciesListResponse {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [patch policies](PolicyPatchCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PoliciesPatchResponse { + /// no description provided + pub header: Option, + /// no description provided + pub policy: Option, +} + +impl client::ResponseResult for PoliciesPatchResponse {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [update policies](PolicyUpdateCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PoliciesUpdateResponse { + /// no description provided + pub header: Option, + /// no description provided + pub policy: Option, +} + +impl client::ResponseResult for PoliciesUpdateResponse {} + + +/// A policy is a collection of DNS rules applied to one or more Virtual Private Cloud resources. +/// +/// # 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*). +/// +/// * [create policies](PolicyCreateCall) (request|response) +/// * [get policies](PolicyGetCall) (response) +/// * [patch policies](PolicyPatchCall) (request) +/// * [update policies](PolicyUpdateCall) (request) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Policy { + /// Sets an alternative name server for the associated networks. When specified, all DNS queries are forwarded to a name server that you choose. Names such as .internal are not available when an alternative name server is specified. + #[serde(rename="alternativeNameServerConfig")] + pub alternative_name_server_config: Option, + /// A mutable string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the policy's function. + pub description: Option, + /// Allows networks bound to this policy to receive DNS queries sent by VMs or applications over VPN connections. When enabled, a virtual IP address is allocated from each of the subnetworks that are bound to this policy. + #[serde(rename="enableInboundForwarding")] + pub enable_inbound_forwarding: Option, + /// Controls whether logging is enabled for the networks bound to this policy. Defaults to no logging if not set. + #[serde(rename="enableLogging")] + pub enable_logging: Option, + /// Unique identifier for the resource; defined by the server (output only). + pub id: Option, + /// no description provided + pub kind: Option, + /// User-assigned name for this policy. + pub name: Option, + /// List of network names specifying networks to which this policy is applied. + pub networks: Option>, +} + +impl client::RequestValue for Policy {} +impl client::ResponseResult for Policy {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PolicyAlternativeNameServerConfig { + /// no description provided + pub kind: Option, + /// Sets an alternative name server for the associated networks. When specified, all DNS queries are forwarded to a name server that you choose. Names such as .internal are not available when an alternative name server is specified. + #[serde(rename="targetNameServers")] + pub target_name_servers: Option>, +} + +impl client::Part for PolicyAlternativeNameServerConfig {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PolicyAlternativeNameServerConfigTargetNameServer { + /// Forwarding path for this TargetNameServer. If unset or set to DEFAULT, Cloud DNS makes forwarding decisions based on address ranges; that is, RFC1918 addresses go to the VPC network, non-RFC1918 addresses go to the internet. When set to PRIVATE, Cloud DNS always sends queries through the VPC network for this target. + #[serde(rename="forwardingPath")] + pub forwarding_path: Option, + /// IPv4 address to forward to. + #[serde(rename="ipv4Address")] + pub ipv4_address: Option, + /// no description provided + pub kind: Option, +} + +impl client::Part for PolicyAlternativeNameServerConfigTargetNameServer {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PolicyNetwork { + /// no description provided + pub kind: Option, + /// The fully qualified URL of the VPC network to bind to. This should be formatted like https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + #[serde(rename="networkUrl")] + pub network_url: Option, +} + +impl client::Part for PolicyNetwork {} + + +/// A project resource. The project is a top level container for resources including Cloud DNS ManagedZones. Projects can be created only in the APIs console. Next tag: 7. +/// +/// # 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*). +/// +/// * [managed zones rrsets create projects](ProjectManagedZoneRrsetCreateCall) (none) +/// * [managed zones rrsets delete projects](ProjectManagedZoneRrsetDeleteCall) (none) +/// * [managed zones rrsets get projects](ProjectManagedZoneRrsetGetCall) (none) +/// * [managed zones rrsets patch projects](ProjectManagedZoneRrsetPatchCall) (none) +/// * [get projects](ProjectGetCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Project { + /// User assigned unique identifier for the resource (output only). + pub id: Option, + /// no description provided + pub kind: Option, + /// Unique numeric identifier for the resource; defined by the server (output only). + pub number: Option, + /// Quotas assigned to this project (output only). + pub quota: Option, +} + +impl client::Resource for Project {} +impl client::ResponseResult for Project {} + + +/// Limits associated with a Project. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Quota { + /// Maximum allowed number of DnsKeys per ManagedZone. + #[serde(rename="dnsKeysPerManagedZone")] + pub dns_keys_per_managed_zone: Option, + /// no description provided + pub kind: Option, + /// Maximum allowed number of managed zones in the project. + #[serde(rename="managedZones")] + pub managed_zones: Option, + /// Maximum allowed number of managed zones which can be attached to a network. + #[serde(rename="managedZonesPerNetwork")] + pub managed_zones_per_network: Option, + /// Maximum allowed number of networks to which a privately scoped zone can be attached. + #[serde(rename="networksPerManagedZone")] + pub networks_per_managed_zone: Option, + /// Maximum allowed number of networks per policy. + #[serde(rename="networksPerPolicy")] + pub networks_per_policy: Option, + /// Maximum allowed number of policies per project. + pub policies: Option, + /// Maximum allowed number of ResourceRecords per ResourceRecordSet. + #[serde(rename="resourceRecordsPerRrset")] + pub resource_records_per_rrset: Option, + /// Maximum allowed number of ResourceRecordSets to add per ChangesCreateRequest. + #[serde(rename="rrsetAdditionsPerChange")] + pub rrset_additions_per_change: Option, + /// Maximum allowed number of ResourceRecordSets to delete per ChangesCreateRequest. + #[serde(rename="rrsetDeletionsPerChange")] + pub rrset_deletions_per_change: Option, + /// Maximum allowed number of ResourceRecordSets per zone in the project. + #[serde(rename="rrsetsPerManagedZone")] + pub rrsets_per_managed_zone: Option, + /// Maximum allowed number of target name servers per managed forwarding zone. + #[serde(rename="targetNameServersPerManagedZone")] + pub target_name_servers_per_managed_zone: Option, + /// Maximum allowed number of alternative target name servers per policy. + #[serde(rename="targetNameServersPerPolicy")] + pub target_name_servers_per_policy: Option, + /// Maximum allowed size for total rrdata in one ChangesCreateRequest in bytes. + #[serde(rename="totalRrdataSizePerChange")] + pub total_rrdata_size_per_change: Option, + /// DNSSEC algorithm and key length types that can be used for DnsKeys. + #[serde(rename="whitelistedKeySpecs")] + pub whitelisted_key_specs: Option>, +} + +impl client::Part for Quota {} + + +/// A unit of data that is returned by the DNS servers. +/// +/// # 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*). +/// +/// * [managed zones rrsets create projects](ProjectManagedZoneRrsetCreateCall) (request|response) +/// * [managed zones rrsets get projects](ProjectManagedZoneRrsetGetCall) (response) +/// * [managed zones rrsets patch projects](ProjectManagedZoneRrsetPatchCall) (request|response) +/// * [list resource record sets](ResourceRecordSetListCall) (none) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ResourceRecordSet { + /// no description provided + pub kind: Option, + /// For example, www.example.com. + pub name: Option, + /// As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) -- see examples. + pub rrdatas: Option>, + /// As defined in RFC 4034 (section 3.2). + #[serde(rename="signatureRrdatas")] + pub signature_rrdatas: Option>, + /// Number of seconds that this ResourceRecordSet can be cached by resolvers. + pub ttl: Option, + /// The identifier of a supported record type. See the list of Supported DNS record types. + #[serde(rename="type")] + pub type_: Option, +} + +impl client::RequestValue for ResourceRecordSet {} +impl client::Resource for ResourceRecordSet {} +impl client::ResponseResult for ResourceRecordSet {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [managed zones rrsets delete projects](ProjectManagedZoneRrsetDeleteCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ResourceRecordSetsDeleteResponse { _never_set: Option } + +impl client::ResponseResult for ResourceRecordSetsDeleteResponse {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [list resource record sets](ResourceRecordSetListCall) (response) +/// +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ResourceRecordSetsListResponse { + /// no description provided + pub header: Option, + /// Type of resource. + pub kind: Option, + /// The presence of this field indicates that there exist more results following your last page of results in pagination order. To fetch them, make another list request using this value as your pagination token. This lets you retrieve complete contents of even larger collections, one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of elements returned are an inconsistent view of the collection. You cannot retrieve a consistent snapshot of a collection larger than the maximum page size. + #[serde(rename="nextPageToken")] + pub next_page_token: Option, + /// The resource record set resources. + pub rrsets: Option>, +} + +impl client::ResponseResult for ResourceRecordSetsListResponse {} + + +/// Elements common to every 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 ResponseHeader { + /// For mutating operation requests that completed successfully. This is the client_operation_id if the client specified it, otherwise it is generated by the server (output only). + #[serde(rename="operationId")] + pub operation_id: Option, +} + +impl client::Part for ResponseHeader {} + + + +// ################### +// MethodBuilders ### +// ################# + +/// A builder providing access to all methods supported on *change* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `create(...)`, `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.changes(); +/// # } +/// ``` +pub struct ChangeMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for ChangeMethods<'a> {} + +impl<'a> ChangeMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Atomically updates the ResourceRecordSet collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn create(&self, request: Change, project: &str, managed_zone: &str) -> ChangeCreateCall<'a> { + ChangeCreateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing Change. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// * `changeId` - The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse. + pub fn get(&self, project: &str, managed_zone: &str, change_id: &str) -> ChangeGetCall<'a> { + ChangeGetCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _change_id: change_id.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enumerates Changes to a ResourceRecordSet collection. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn list(&self, project: &str, managed_zone: &str) -> ChangeListCall<'a> { + ChangeListCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _sort_order: Default::default(), + _sort_by: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *dnsKey* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.dns_keys(); +/// # } +/// ``` +pub struct DnsKeyMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for DnsKeyMethods<'a> {} + +impl<'a> DnsKeyMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing DnsKey. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// * `dnsKeyId` - The identifier of the requested DnsKey. + pub fn get(&self, project: &str, managed_zone: &str, dns_key_id: &str) -> DnsKeyGetCall<'a> { + DnsKeyGetCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _dns_key_id: dns_key_id.to_string(), + _digest_type: Default::default(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enumerates DnsKeys to a ResourceRecordSet collection. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn list(&self, project: &str, managed_zone: &str) -> DnsKeyListCall<'a> { + DnsKeyListCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _digest_type: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *managedZoneOperation* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)` and `list(...)` +/// // to build up your call. +/// let rb = hub.managed_zone_operations(); +/// # } +/// ``` +pub struct ManagedZoneOperationMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for ManagedZoneOperationMethods<'a> {} + +impl<'a> ManagedZoneOperationMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing Operation. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. + /// * `operation` - Identifies the operation addressed by this request (ID of the operation). + pub fn get(&self, project: &str, managed_zone: &str, operation: &str) -> ManagedZoneOperationGetCall<'a> { + ManagedZoneOperationGetCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _operation: operation.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enumerates Operations for the given ManagedZone. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. + pub fn list(&self, project: &str, managed_zone: &str) -> ManagedZoneOperationListCall<'a> { + ManagedZoneOperationListCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _sort_by: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *managedZone* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.managed_zones(); +/// # } +/// ``` +pub struct ManagedZoneMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for ManagedZoneMethods<'a> {} + +impl<'a> ManagedZoneMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Creates a new ManagedZone. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + pub fn create(&self, request: ManagedZone, project: &str) -> ManagedZoneCreateCall<'a> { + ManagedZoneCreateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a previously created ManagedZone. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn delete(&self, project: &str, managed_zone: &str) -> ManagedZoneDeleteCall<'a> { + ManagedZoneDeleteCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing ManagedZone. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn get(&self, project: &str, managed_zone: &str) -> ManagedZoneGetCall<'a> { + ManagedZoneGetCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enumerates ManagedZones that have been created but not yet deleted. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + pub fn list(&self, project: &str) -> ManagedZoneListCall<'a> { + ManagedZoneListCall { + hub: self.hub, + _project: project.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _dns_name: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Applies a partial update to an existing ManagedZone. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn patch(&self, request: ManagedZone, project: &str, managed_zone: &str) -> ManagedZonePatchCall<'a> { + ManagedZonePatchCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing ManagedZone. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn update(&self, request: ManagedZone, project: &str, managed_zone: &str) -> ManagedZoneUpdateCall<'a> { + ManagedZoneUpdateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *policy* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.policies(); +/// # } +/// ``` +pub struct PolicyMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for PolicyMethods<'a> {} + +impl<'a> PolicyMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Creates a new Policy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + pub fn create(&self, request: Policy, project: &str) -> PolicyCreateCall<'a> { + PolicyCreateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a previously created Policy. Fails if the policy is still being referenced by a network. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `policy` - User given friendly name of the policy addressed by this request. + pub fn delete(&self, project: &str, policy: &str) -> PolicyDeleteCall<'a> { + PolicyDeleteCall { + hub: self.hub, + _project: project.to_string(), + _policy: policy.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing Policy. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `policy` - User given friendly name of the policy addressed by this request. + pub fn get(&self, project: &str, policy: &str) -> PolicyGetCall<'a> { + PolicyGetCall { + hub: self.hub, + _project: project.to_string(), + _policy: policy.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Enumerates all Policies associated with a project. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + pub fn list(&self, project: &str) -> PolicyListCall<'a> { + PolicyListCall { + hub: self.hub, + _project: project.to_string(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Applies a partial update to an existing Policy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `policy` - User given friendly name of the policy addressed by this request. + pub fn patch(&self, request: Policy, project: &str, policy: &str) -> PolicyPatchCall<'a> { + PolicyPatchCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _policy: policy.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing Policy. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `policy` - User given friendly name of the policy addressed by this request. + pub fn update(&self, request: Policy, project: &str, policy: &str) -> PolicyUpdateCall<'a> { + PolicyUpdateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _policy: policy.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *project* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `get(...)`, `managed_zones_rrsets_create(...)`, `managed_zones_rrsets_delete(...)`, `managed_zones_rrsets_get(...)` and `managed_zones_rrsets_patch(...)` +/// // to build up your call. +/// let rb = hub.projects(); +/// # } +/// ``` +pub struct ProjectMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for ProjectMethods<'a> {} + +impl<'a> ProjectMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Creates a new ResourceRecordSet. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn managed_zones_rrsets_create(&self, request: ResourceRecordSet, project: &str, managed_zone: &str) -> ProjectManagedZoneRrsetCreateCall<'a> { + ProjectManagedZoneRrsetCreateCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Deletes a previously created ResourceRecordSet. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// * `name` - Fully qualified domain name. + /// * `type` - RRSet type. + pub fn managed_zones_rrsets_delete(&self, project: &str, managed_zone: &str, name: &str, type_: &str) -> ProjectManagedZoneRrsetDeleteCall<'a> { + ProjectManagedZoneRrsetDeleteCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _name: name.to_string(), + _type_: type_.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing ResourceRecordSet. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// * `name` - Fully qualified domain name. + /// * `type` - RRSet type. + pub fn managed_zones_rrsets_get(&self, project: &str, managed_zone: &str, name: &str, type_: &str) -> ProjectManagedZoneRrsetGetCall<'a> { + ProjectManagedZoneRrsetGetCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _name: name.to_string(), + _type_: type_.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Applies a partial update to an existing ResourceRecordSet. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// * `name` - Fully qualified domain name. + /// * `type` - RRSet type. + pub fn managed_zones_rrsets_patch(&self, request: ResourceRecordSet, project: &str, managed_zone: &str, name: &str, type_: &str) -> ProjectManagedZoneRrsetPatchCall<'a> { + ProjectManagedZoneRrsetPatchCall { + hub: self.hub, + _request: request, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _name: name.to_string(), + _type_: type_.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Fetches the representation of an existing Project. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + pub fn get(&self, project: &str) -> ProjectGetCall<'a> { + ProjectGetCall { + hub: self.hub, + _project: project.to_string(), + _client_operation_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *resourceRecordSet* resources. +/// It is not used directly, but through the `Dns` 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_dns1 as dns1; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use oauth2; +/// use dns1::Dns; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.resource_record_sets(); +/// # } +/// ``` +pub struct ResourceRecordSetMethods<'a> + where { + + hub: &'a Dns<>, +} + +impl<'a> client::MethodsBuilder for ResourceRecordSetMethods<'a> {} + +impl<'a> ResourceRecordSetMethods<'a> { + + /// Create a builder to help you perform the following task: + /// + /// Enumerates ResourceRecordSets that you have created but not yet deleted. + /// + /// # Arguments + /// + /// * `project` - Identifies the project addressed by this request. + /// * `managedZone` - Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + pub fn list(&self, project: &str, managed_zone: &str) -> ResourceRecordSetListCall<'a> { + ResourceRecordSetListCall { + hub: self.hub, + _project: project.to_string(), + _managed_zone: managed_zone.to_string(), + _type_: Default::default(), + _page_token: Default::default(), + _name: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + + + +// ################### +// CallBuilders ### +// ################# + +/// Atomically updates the ResourceRecordSet collection. +/// +/// A builder for the *create* method supported by a *change* resource. +/// It is not used directly, but through a `ChangeMethods` 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_dns1 as dns1; +/// use dns1::api::Change; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = Change::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.changes().create(req, "project", "managedZone") +/// .client_operation_id("Lorem") +/// .doit().await; +/// # } +/// ``` +pub struct ChangeCreateCall<'a> + where { + + hub: &'a Dns<>, + _request: Change, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ChangeCreateCall<'a> {} + +impl<'a> ChangeCreateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Change)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.changes.create", + http_method: hyper::Method::POST }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/changes"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: Change) -> ChangeCreateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ChangeCreateCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ChangeCreateCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ChangeCreateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ChangeCreateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChangeCreateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ChangeCreateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing Change. +/// +/// A builder for the *get* method supported by a *change* resource. +/// It is not used directly, but through a `ChangeMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.changes().get("project", "managedZone", "changeId") +/// .client_operation_id("ea") +/// .doit().await; +/// # } +/// ``` +pub struct ChangeGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _change_id: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ChangeGetCall<'a> {} + +impl<'a> ChangeGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Change)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.changes.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("changeId", self._change_id.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "changeId", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/changes/{changeId}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{changeId}", "changeId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["changeId", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ChangeGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ChangeGetCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// The identifier of the requested change, from a previous ResourceRecordSetsChangeResponse. + /// + /// Sets the *change id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn change_id(mut self, new_value: &str) -> ChangeGetCall<'a> { + self._change_id = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ChangeGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ChangeGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChangeGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ChangeGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates Changes to a ResourceRecordSet collection. +/// +/// A builder for the *list* method supported by a *change* resource. +/// It is not used directly, but through a `ChangeMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.changes().list("project", "managedZone") +/// .sort_order("amet") +/// .sort_by("duo") +/// .page_token("ipsum") +/// .max_results(-93) +/// .doit().await; +/// # } +/// ``` +pub struct ChangeListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _sort_order: Option, + _sort_by: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ChangeListCall<'a> {} + +impl<'a> ChangeListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ChangesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.changes.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._sort_order { + params.push(("sortOrder", value.to_string())); + } + if let Some(value) = self._sort_by { + params.push(("sortBy", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "sortOrder", "sortBy", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/changes"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ChangeListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ChangeListCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// Sorting order direction: 'ascending' or 'descending'. + /// + /// Sets the *sort order* query property to the given value. + pub fn sort_order(mut self, new_value: &str) -> ChangeListCall<'a> { + self._sort_order = Some(new_value.to_string()); + self + } + /// Sorting criterion. The only supported value is change sequence. + /// + /// Sets the *sort by* query property to the given value. + pub fn sort_by(mut self, new_value: &str) -> ChangeListCall<'a> { + self._sort_by = Some(new_value.to_string()); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ChangeListCall<'a> { + self._max_results = 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 client::Delegate) -> ChangeListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChangeListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ChangeListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing DnsKey. +/// +/// A builder for the *get* method supported by a *dnsKey* resource. +/// It is not used directly, but through a `DnsKeyMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.dns_keys().get("project", "managedZone", "dnsKeyId") +/// .digest_type("est") +/// .client_operation_id("ipsum") +/// .doit().await; +/// # } +/// ``` +pub struct DnsKeyGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _dns_key_id: String, + _digest_type: Option, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for DnsKeyGetCall<'a> {} + +impl<'a> DnsKeyGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, DnsKey)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.dnsKeys.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("dnsKeyId", self._dns_key_id.to_string())); + if let Some(value) = self._digest_type { + params.push(("digestType", value.to_string())); + } + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "dnsKeyId", "digestType", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/dnsKeys/{dnsKeyId}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{dnsKeyId}", "dnsKeyId")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["dnsKeyId", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> DnsKeyGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> DnsKeyGetCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// The identifier of the requested DnsKey. + /// + /// Sets the *dns key id* path property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn dns_key_id(mut self, new_value: &str) -> DnsKeyGetCall<'a> { + self._dns_key_id = new_value.to_string(); + self + } + /// An optional comma-separated list of digest types to compute and display for key signing keys. If omitted, the recommended digest type is computed and displayed. + /// + /// Sets the *digest type* query property to the given value. + pub fn digest_type(mut self, new_value: &str) -> DnsKeyGetCall<'a> { + self._digest_type = Some(new_value.to_string()); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> DnsKeyGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> DnsKeyGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> DnsKeyGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> DnsKeyGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates DnsKeys to a ResourceRecordSet collection. +/// +/// A builder for the *list* method supported by a *dnsKey* resource. +/// It is not used directly, but through a `DnsKeyMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.dns_keys().list("project", "managedZone") +/// .page_token("gubergren") +/// .max_results(-17) +/// .digest_type("dolor") +/// .doit().await; +/// # } +/// ``` +pub struct DnsKeyListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _page_token: Option, + _max_results: Option, + _digest_type: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for DnsKeyListCall<'a> {} + +impl<'a> DnsKeyListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, DnsKeysListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.dnsKeys.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._digest_type { + params.push(("digestType", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "pageToken", "maxResults", "digestType"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/dnsKeys"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> DnsKeyListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> DnsKeyListCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> DnsKeyListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> DnsKeyListCall<'a> { + self._max_results = Some(new_value); + self + } + /// An optional comma-separated list of digest types to compute and display for key signing keys. If omitted, the recommended digest type is computed and displayed. + /// + /// Sets the *digest type* query property to the given value. + pub fn digest_type(mut self, new_value: &str) -> DnsKeyListCall<'a> { + self._digest_type = Some(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 client::Delegate) -> DnsKeyListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> DnsKeyListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> DnsKeyListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing Operation. +/// +/// A builder for the *get* method supported by a *managedZoneOperation* resource. +/// It is not used directly, but through a `ManagedZoneOperationMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zone_operations().get("project", "managedZone", "operation") +/// .client_operation_id("sed") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneOperationGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _operation: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneOperationGetCall<'a> {} + +impl<'a> ManagedZoneOperationGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Operation)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZoneOperations.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("operation", self._operation.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "operation", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/operations/{operation}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{operation}", "operation")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(3); + for param_name in ["operation", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// Identifies the operation addressed by this request (ID of the operation). + /// + /// Sets the *operation* 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 operation(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a> { + self._operation = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneOperationGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZoneOperationGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneOperationGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneOperationGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates Operations for the given ManagedZone. +/// +/// A builder for the *list* method supported by a *managedZoneOperation* resource. +/// It is not used directly, but through a `ManagedZoneOperationMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zone_operations().list("project", "managedZone") +/// .sort_by("no") +/// .page_token("Stet") +/// .max_results(-13) +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneOperationListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _sort_by: Option, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneOperationListCall<'a> {} + +impl<'a> ManagedZoneOperationListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ManagedZoneOperationsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZoneOperations.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._sort_by { + params.push(("sortBy", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "sortBy", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/operations"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// Sorting criterion. The only supported values are START_TIME and ID. + /// + /// Sets the *sort by* query property to the given value. + pub fn sort_by(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a> { + self._sort_by = Some(new_value.to_string()); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ManagedZoneOperationListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagedZoneOperationListCall<'a> { + self._max_results = 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 client::Delegate) -> ManagedZoneOperationListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneOperationListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneOperationListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Creates a new ManagedZone. +/// +/// A builder for the *create* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// use dns1::api::ManagedZone; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = ManagedZone::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.managed_zones().create(req, "project") +/// .client_operation_id("sed") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneCreateCall<'a> + where { + + hub: &'a Dns<>, + _request: ManagedZone, + _project: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneCreateCall<'a> {} + +impl<'a> ManagedZoneCreateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ManagedZone)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.create", + http_method: hyper::Method::POST }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: ManagedZone) -> ManagedZoneCreateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneCreateCall<'a> { + self._project = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneCreateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZoneCreateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneCreateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneCreateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Deletes a previously created ManagedZone. +/// +/// A builder for the *delete* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().delete("project", "managedZone") +/// .client_operation_id("vero") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneDeleteCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneDeleteCall<'a> {} + +impl<'a> ManagedZoneDeleteCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.delete", + http_method: hyper::Method::DELETE }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/managedZones/{managedZone}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneDeleteCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZoneDeleteCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneDeleteCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneDeleteCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing ManagedZone. +/// +/// A builder for the *get* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().get("project", "managedZone") +/// .client_operation_id("duo") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneGetCall<'a> {} + +impl<'a> ManagedZoneGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ManagedZone)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZoneGetCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZoneGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates ManagedZones that have been created but not yet deleted. +/// +/// A builder for the *list* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().list("project") +/// .page_token("et") +/// .max_results(-28) +/// .dns_name("amet.") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _page_token: Option, + _max_results: Option, + _dns_name: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneListCall<'a> {} + +impl<'a> ManagedZoneListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ManagedZonesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + if let Some(value) = self._dns_name { + params.push(("dnsName", value.to_string())); + } + for &field in ["alt", "project", "pageToken", "maxResults", "dnsName"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ManagedZoneListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ManagedZoneListCall<'a> { + self._max_results = Some(new_value); + self + } + /// Restricts the list to return only zones with this domain name. + /// + /// Sets the *dns name* query property to the given value. + pub fn dns_name(mut self, new_value: &str) -> ManagedZoneListCall<'a> { + self._dns_name = Some(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 client::Delegate) -> ManagedZoneListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Applies a partial update to an existing ManagedZone. +/// +/// A builder for the *patch* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// use dns1::api::ManagedZone; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = ManagedZone::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.managed_zones().patch(req, "project", "managedZone") +/// .client_operation_id("dolor") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZonePatchCall<'a> + where { + + hub: &'a Dns<>, + _request: ManagedZone, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZonePatchCall<'a> {} + +impl<'a> ManagedZonePatchCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Operation)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.patch", + http_method: hyper::Method::PATCH }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: ManagedZone) -> ManagedZonePatchCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZonePatchCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZonePatchCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZonePatchCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZonePatchCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZonePatchCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZonePatchCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Updates an existing ManagedZone. +/// +/// A builder for the *update* method supported by a *managedZone* resource. +/// It is not used directly, but through a `ManagedZoneMethods` 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_dns1 as dns1; +/// use dns1::api::ManagedZone; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = ManagedZone::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.managed_zones().update(req, "project", "managedZone") +/// .client_operation_id("sadipscing") +/// .doit().await; +/// # } +/// ``` +pub struct ManagedZoneUpdateCall<'a> + where { + + hub: &'a Dns<>, + _request: ManagedZone, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ManagedZoneUpdateCall<'a> {} + +impl<'a> ManagedZoneUpdateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Operation)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.managedZones.update", + http_method: hyper::Method::PUT }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: ManagedZone) -> ManagedZoneUpdateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ManagedZoneUpdateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ManagedZoneUpdateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ManagedZoneUpdateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ManagedZoneUpdateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Creates a new Policy. +/// +/// A builder for the *create* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// use dns1::api::Policy; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = Policy::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.policies().create(req, "project") +/// .client_operation_id("dolor") +/// .doit().await; +/// # } +/// ``` +pub struct PolicyCreateCall<'a> + where { + + hub: &'a Dns<>, + _request: Policy, + _project: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyCreateCall<'a> {} + +impl<'a> PolicyCreateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Policy)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.create", + http_method: hyper::Method::POST }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/policies"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: Policy) -> PolicyCreateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyCreateCall<'a> { + self._project = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> PolicyCreateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> PolicyCreateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyCreateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyCreateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Deletes a previously created Policy. Fails if the policy is still being referenced by a network. +/// +/// A builder for the *delete* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.policies().delete("project", "policy") +/// .client_operation_id("vero") +/// .doit().await; +/// # } +/// ``` +pub struct PolicyDeleteCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _policy: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyDeleteCall<'a> {} + +impl<'a> PolicyDeleteCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.delete", + http_method: hyper::Method::DELETE }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("policy", self._policy.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["project", "policy", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + for (name, value) in self._additional_params.iter() { + params.push((&name, value.clone())); + } + + + let mut url = self.hub._base_url.clone() + "dns/v1/projects/{project}/policies/{policy}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["policy", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyDeleteCall<'a> { + self._project = new_value.to_string(); + self + } + /// User given friendly name of the policy addressed by this request. + /// + /// Sets the *policy* 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 policy(mut self, new_value: &str) -> PolicyDeleteCall<'a> { + self._policy = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> PolicyDeleteCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> PolicyDeleteCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyDeleteCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyDeleteCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing Policy. +/// +/// A builder for the *get* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.policies().get("project", "policy") +/// .client_operation_id("vero") +/// .doit().await; +/// # } +/// ``` +pub struct PolicyGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _policy: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyGetCall<'a> {} + +impl<'a> PolicyGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Policy)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("policy", self._policy.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "policy", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/policies/{policy}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["policy", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// User given friendly name of the policy addressed by this request. + /// + /// Sets the *policy* 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 policy(mut self, new_value: &str) -> PolicyGetCall<'a> { + self._policy = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> PolicyGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> PolicyGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates all Policies associated with a project. +/// +/// A builder for the *list* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.policies().list("project") +/// .page_token("Lorem") +/// .max_results(-29) +/// .doit().await; +/// # } +/// ``` +pub struct PolicyListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _page_token: Option, + _max_results: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyListCall<'a> {} + +impl<'a> PolicyListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PoliciesListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "project", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/policies"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PolicyListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> PolicyListCall<'a> { + self._max_results = 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 client::Delegate) -> PolicyListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Applies a partial update to an existing Policy. +/// +/// A builder for the *patch* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// use dns1::api::Policy; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = Policy::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.policies().patch(req, "project", "policy") +/// .client_operation_id("accusam") +/// .doit().await; +/// # } +/// ``` +pub struct PolicyPatchCall<'a> + where { + + hub: &'a Dns<>, + _request: Policy, + _project: String, + _policy: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyPatchCall<'a> {} + +impl<'a> PolicyPatchCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PoliciesPatchResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.patch", + http_method: hyper::Method::PATCH }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("policy", self._policy.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "policy", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/policies/{policy}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["policy", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: Policy) -> PolicyPatchCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyPatchCall<'a> { + self._project = new_value.to_string(); + self + } + /// User given friendly name of the policy addressed by this request. + /// + /// Sets the *policy* 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 policy(mut self, new_value: &str) -> PolicyPatchCall<'a> { + self._policy = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> PolicyPatchCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> PolicyPatchCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyPatchCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyPatchCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Updates an existing Policy. +/// +/// A builder for the *update* method supported by a *policy* resource. +/// It is not used directly, but through a `PolicyMethods` 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_dns1 as dns1; +/// use dns1::api::Policy; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = Policy::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.policies().update(req, "project", "policy") +/// .client_operation_id("voluptua.") +/// .doit().await; +/// # } +/// ``` +pub struct PolicyUpdateCall<'a> + where { + + hub: &'a Dns<>, + _request: Policy, + _project: String, + _policy: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for PolicyUpdateCall<'a> {} + +impl<'a> PolicyUpdateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PoliciesUpdateResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.policies.update", + http_method: hyper::Method::PUT }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("policy", self._policy.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "policy", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/policies/{policy}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{policy}", "policy")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["policy", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::PUT).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: Policy) -> PolicyUpdateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> PolicyUpdateCall<'a> { + self._project = new_value.to_string(); + self + } + /// User given friendly name of the policy addressed by this request. + /// + /// Sets the *policy* 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 policy(mut self, new_value: &str) -> PolicyUpdateCall<'a> { + self._policy = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> PolicyUpdateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> PolicyUpdateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PolicyUpdateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> PolicyUpdateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Creates a new ResourceRecordSet. +/// +/// A builder for the *managedZones.rrsets.create* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` 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_dns1 as dns1; +/// use dns1::api::ResourceRecordSet; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = ResourceRecordSet::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.projects().managed_zones_rrsets_create(req, "project", "managedZone") +/// .client_operation_id("consetetur") +/// .doit().await; +/// # } +/// ``` +pub struct ProjectManagedZoneRrsetCreateCall<'a> + where { + + hub: &'a Dns<>, + _request: ResourceRecordSet, + _project: String, + _managed_zone: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ProjectManagedZoneRrsetCreateCall<'a> {} + +impl<'a> ProjectManagedZoneRrsetCreateCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ResourceRecordSet)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.projects.managedZones.rrsets.create", + http_method: hyper::Method::POST }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::POST).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: ResourceRecordSet) -> ProjectManagedZoneRrsetCreateCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectManagedZoneRrsetCreateCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ProjectManagedZoneRrsetCreateCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ProjectManagedZoneRrsetCreateCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ProjectManagedZoneRrsetCreateCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ProjectManagedZoneRrsetCreateCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ProjectManagedZoneRrsetCreateCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Deletes a previously created ResourceRecordSet. +/// +/// A builder for the *managedZones.rrsets.delete* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.projects().managed_zones_rrsets_delete("project", "managedZone", "name", "type") +/// .client_operation_id("gubergren") +/// .doit().await; +/// # } +/// ``` +pub struct ProjectManagedZoneRrsetDeleteCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _name: String, + _type_: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ProjectManagedZoneRrsetDeleteCall<'a> {} + +impl<'a> ProjectManagedZoneRrsetDeleteCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ResourceRecordSetsDeleteResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.projects.managedZones.rrsets.delete", + http_method: hyper::Method::DELETE }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("name", self._name.to_string())); + params.push(("type", self._type_.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "name", "type", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{name}", "name"), ("{type}", "type")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["type", "name", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::DELETE).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectManagedZoneRrsetDeleteCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ProjectManagedZoneRrsetDeleteCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// 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) -> ProjectManagedZoneRrsetDeleteCall<'a> { + self._name = new_value.to_string(); + self + } + /// RRSet type. + /// + /// Sets the *type* 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 type_(mut self, new_value: &str) -> ProjectManagedZoneRrsetDeleteCall<'a> { + self._type_ = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ProjectManagedZoneRrsetDeleteCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ProjectManagedZoneRrsetDeleteCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ProjectManagedZoneRrsetDeleteCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ProjectManagedZoneRrsetDeleteCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing ResourceRecordSet. +/// +/// A builder for the *managedZones.rrsets.get* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.projects().managed_zones_rrsets_get("project", "managedZone", "name", "type") +/// .client_operation_id("dolore") +/// .doit().await; +/// # } +/// ``` +pub struct ProjectManagedZoneRrsetGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _name: String, + _type_: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ProjectManagedZoneRrsetGetCall<'a> {} + +impl<'a> ProjectManagedZoneRrsetGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ResourceRecordSet)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.projects.managedZones.rrsets.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("name", self._name.to_string())); + params.push(("type", self._type_.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "name", "type", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{name}", "name"), ("{type}", "type")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["type", "name", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectManagedZoneRrsetGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ProjectManagedZoneRrsetGetCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// 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) -> ProjectManagedZoneRrsetGetCall<'a> { + self._name = new_value.to_string(); + self + } + /// RRSet type. + /// + /// Sets the *type* 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 type_(mut self, new_value: &str) -> ProjectManagedZoneRrsetGetCall<'a> { + self._type_ = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ProjectManagedZoneRrsetGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ProjectManagedZoneRrsetGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ProjectManagedZoneRrsetGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ProjectManagedZoneRrsetGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Applies a partial update to an existing ResourceRecordSet. +/// +/// A builder for the *managedZones.rrsets.patch* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` 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_dns1 as dns1; +/// use dns1::api::ResourceRecordSet; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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 = ResourceRecordSet::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.projects().managed_zones_rrsets_patch(req, "project", "managedZone", "name", "type") +/// .client_operation_id("sadipscing") +/// .doit().await; +/// # } +/// ``` +pub struct ProjectManagedZoneRrsetPatchCall<'a> + where { + + hub: &'a Dns<>, + _request: ResourceRecordSet, + _project: String, + _managed_zone: String, + _name: String, + _type_: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ProjectManagedZoneRrsetPatchCall<'a> {} + +impl<'a> ProjectManagedZoneRrsetPatchCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ResourceRecordSet)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.projects.managedZones.rrsets.patch", + http_method: hyper::Method::PATCH }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + params.push(("name", self._name.to_string())); + params.push(("type", self._type_.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "name", "type", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets/{name}/{type}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone"), ("{name}", "name"), ("{type}", "type")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(4); + for param_name in ["type", "name", "managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + let mut json_mime_type: mime::Mime = "application/json".parse().unwrap(); + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::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 { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::PATCH).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string())) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, 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: ResourceRecordSet) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._request = new_value; + self + } + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// 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) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._name = new_value.to_string(); + self + } + /// RRSet type. + /// + /// Sets the *type* 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 type_(mut self, new_value: &str) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._type_ = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ProjectManagedZoneRrsetPatchCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ProjectManagedZoneRrsetPatchCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ProjectManagedZoneRrsetPatchCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::CloudPlatform`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ProjectManagedZoneRrsetPatchCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Fetches the representation of an existing Project. +/// +/// A builder for the *get* method supported by a *project* resource. +/// It is not used directly, but through a `ProjectMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.projects().get("project") +/// .client_operation_id("invidunt") +/// .doit().await; +/// # } +/// ``` +pub struct ProjectGetCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _client_operation_id: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ProjectGetCall<'a> {} + +impl<'a> ProjectGetCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Project)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.projects.get", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + if let Some(value) = self._client_operation_id { + params.push(("clientOperationId", value.to_string())); + } + for &field in ["alt", "project", "clientOperationId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(1); + for param_name in ["project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ProjectGetCall<'a> { + self._project = new_value.to_string(); + self + } + /// For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection. + /// + /// Sets the *client operation id* query property to the given value. + pub fn client_operation_id(mut self, new_value: &str) -> ProjectGetCall<'a> { + self._client_operation_id = Some(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 client::Delegate) -> ProjectGetCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ProjectGetCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ProjectGetCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + +/// Enumerates ResourceRecordSets that you have created but not yet deleted. +/// +/// A builder for the *list* method supported by a *resourceRecordSet* resource. +/// It is not used directly, but through a `ResourceRecordSetMethods` 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_dns1 as dns1; +/// # async fn dox() { +/// # use std::default::Default; +/// # use oauth2; +/// # use dns1::Dns; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.resource_record_sets().list("project", "managedZone") +/// .type_("At") +/// .page_token("sed") +/// .name("sit") +/// .max_results(-35) +/// .doit().await; +/// # } +/// ``` +pub struct ResourceRecordSetListCall<'a> + where { + + hub: &'a Dns<>, + _project: String, + _managed_zone: String, + _type_: Option, + _page_token: Option, + _name: Option, + _max_results: Option, + _delegate: Option<&'a mut dyn client::Delegate>, + _additional_params: HashMap, + _scopes: BTreeMap +} + +impl<'a> client::CallBuilder for ResourceRecordSetListCall<'a> {} + +impl<'a> ResourceRecordSetListCall<'a> { + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ResourceRecordSetsListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::ToParts; + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = match self._delegate { + Some(d) => d, + None => &mut dd + }; + dlg.begin(client::MethodInfo { id: "dns.resourceRecordSets.list", + http_method: hyper::Method::GET }); + let mut params: Vec<(&str, String)> = Vec::with_capacity(8 + self._additional_params.len()); + params.push(("project", self._project.to_string())); + params.push(("managedZone", self._managed_zone.to_string())); + if let Some(value) = self._type_ { + params.push(("type", value.to_string())); + } + if let Some(value) = self._page_token { + params.push(("pageToken", value.to_string())); + } + if let Some(value) = self._name { + params.push(("name", value.to_string())); + } + if let Some(value) = self._max_results { + params.push(("maxResults", value.to_string())); + } + for &field in ["alt", "project", "managedZone", "type", "pageToken", "name", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::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() + "dns/v1/projects/{project}/managedZones/{managedZone}/rrsets"; + if self._scopes.len() == 0 { + self._scopes.insert(Scope::NdevClouddnReadonly.as_ref().to_string(), ()); + } + + for &(find_this, param_name) in [("{project}", "project"), ("{managedZone}", "managedZone")].iter() { + let mut replace_with: Option<&str> = None; + for &(name, ref value) in params.iter() { + if name == param_name { + replace_with = Some(value); + break; + } + } + url = url.replace(find_this, replace_with.expect("to find substitution value in params")); + } + { + let mut indices_for_removal: Vec = Vec::with_capacity(2); + for param_name in ["managedZone", "project"].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 = url::Url::parse_with_params(&url, params).unwrap(); + + + + loop { + let token = match self.hub.auth.token(&self._scopes.keys().collect::>()[..]).await { + Ok(token) => token.clone(), + Err(err) => { + match dlg.token(&err) { + Some(token) => token, + None => { + dlg.finished(false); + return Err(client::Error::MissingToken(err)) + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder().method(hyper::Method::GET).uri(url.clone().into_string()) + .header(USER_AGENT, self.hub._user_agent.clone()) .header(AUTHORIZATION, format!("Bearer {}", token.as_str())); + + + let request = req_builder + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d); + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + let json_server_error = json::from_str::(&res_body_string).ok(); + let server_error = json::from_str::(&res_body_string) + .or_else(|_| json::from_str::(&res_body_string).map(|r| r.error)) + .ok(); + + if let client::Retry::After(d) = dlg.http_failure(&res, + json_server_error, + server_error) { + sleep(d); + continue; + } + dlg.finished(false); + return match json::from_str::(&res_body_string){ + Err(_) => Err(client::Error::Failure(res)), + Ok(serr) => Err(client::Error::BadRequest(serr)) + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Identifies the project addressed by this request. + /// + /// Sets the *project* 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 project(mut self, new_value: &str) -> ResourceRecordSetListCall<'a> { + self._project = new_value.to_string(); + self + } + /// Identifies the managed zone addressed by this request. Can be the managed zone name or ID. + /// + /// Sets the *managed zone* 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 managed_zone(mut self, new_value: &str) -> ResourceRecordSetListCall<'a> { + self._managed_zone = new_value.to_string(); + self + } + /// Restricts the list to return only records of this type. If present, the "name" parameter must also be present. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &str) -> ResourceRecordSetListCall<'a> { + self._type_ = Some(new_value.to_string()); + self + } + /// Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ResourceRecordSetListCall<'a> { + self._page_token = Some(new_value.to_string()); + self + } + /// Restricts the list to return only records with this fully qualified domain name. + /// + /// Sets the *name* query property to the given value. + pub fn name(mut self, new_value: &str) -> ResourceRecordSetListCall<'a> { + self._name = Some(new_value.to_string()); + self + } + /// Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: i32) -> ResourceRecordSetListCall<'a> { + self._max_results = 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 client::Delegate) -> ResourceRecordSetListCall<'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 + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *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. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *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. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ResourceRecordSetListCall<'a> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead the default `Scope` variant + /// `Scope::NdevClouddnReadonly`. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// If `None` is specified, then all scopes will be removed and no default scope will be used either. + /// In that case, you have to specify your API-key using the `key` parameter (see the `param()` + /// function for details). + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: T) -> ResourceRecordSetListCall<'a> + where T: Into>, + S: AsRef { + match scope.into() { + Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()), + None => None, + }; + self + } +} + + diff --git a/gen/docs1/src/client.rs b/gen/docs1/src/client.rs new file mode 100644 index 0000000000..6a3af690e0 --- /dev/null +++ b/gen/docs1/src/client.rs @@ -0,0 +1,819 @@ +// COPY OF 'src/rust/api/client.rs' +// DO NOT EDIT +use std::error; +use std::fmt::{self, Display}; +use std::io::{self, Cursor, Read, Seek, SeekFrom, Write}; +use std::str::FromStr; +use std::thread::sleep; +use std::time::Duration; + +use itertools::Itertools; + +use hyper::body::Buf; +use hyper::header::{HeaderMap, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, USER_AGENT}; +use hyper::Method; +use hyper::StatusCode; + +use mime::{Attr, Mime, SubLevel, TopLevel, Value}; + +use serde_json as json; + +const LINE_ENDING: &str = "\r\n"; + +pub enum Retry { + /// Signal you don't want to retry + Abort, + /// Signals you want to retry after the given duration + After(Duration), +} + +/// Identifies the Hub. There is only one per library, this trait is supposed +/// to make intended use more explicit. +/// The hub allows to access all resource methods more easily. +pub trait Hub {} + +/// Identifies types for building methods of a particular resource type +pub trait MethodsBuilder {} + +/// Identifies types which represent builders for a particular resource method +pub trait CallBuilder {} + +/// Identifies types which can be inserted and deleted. +/// Types with this trait are most commonly used by clients of this API. +pub trait Resource {} + +/// Identifies types which are used in API responses. +pub trait ResponseResult {} + +/// Identifies types which are used in API requests. +pub trait RequestValue {} + +/// Identifies types which are not actually used by the API +/// This might be a bug within the google API schema. +pub trait UnusedType {} + +/// Identifies types which are only used as part of other types, which +/// usually are carrying the `Resource` trait. +pub trait Part {} + +/// Identifies types which are only used by other types internally. +/// They have no special meaning, this trait just marks them for completeness. +pub trait NestedType {} + +/// A utility to specify reader types which provide seeking capabilities too +pub trait ReadSeek: Seek + Read + Send {} +impl ReadSeek for T {} + +/// A trait for all types that can convert themselves into a *parts* string +pub trait ToParts { + fn to_parts(&self) -> String; +} + +/// A utility type which can decode a server response that indicates error +#[derive(Deserialize)] +pub struct JsonServerError { + pub error: String, + pub error_description: Option, +} + +/// A utility to represent detailed errors we might see in case there are BadRequests. +/// The latter happen if the sent parameters or request structures are unsound +#[derive(Deserialize, Serialize, Debug)] +pub struct ErrorResponse { + pub error: ServerError, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerError { + pub errors: Vec, + pub code: u16, + pub message: String, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct ServerMessage { + pub domain: String, + pub reason: String, + pub message: String, + #[serde(rename = "locationType")] + pub location_type: Option, + pub location: Option, +} + +/// A trait specifying functionality to help controlling any request performed by the API. +/// The trait has a conservative default implementation. +/// +/// It contains methods to deal with all common issues, as well with the ones related to +/// uploading media +pub trait Delegate: Send { + /// Called at the beginning of any API request. The delegate should store the method + /// information if he is interesting in knowing more context when further calls to it + /// are made. + /// The matching `finished()` call will always be made, no matter whether or not the API + /// request was successful. That way, the delegate may easily maintain a clean state + /// between various API calls. + fn begin(&mut self, _info: MethodInfo) {} + + /// Called whenever there is an [HttpError](hyper::Error), usually if there are network problems. + /// + /// If you choose to retry after a duration, the duration should be chosen using the + /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). + /// + /// Return retry information. + fn http_error(&mut self, _err: &hyper::Error) -> Retry { + Retry::Abort + } + + /// Called whenever there is the need for your applications API key after + /// the official authenticator implementation didn't provide one, for some reason. + /// If this method returns None as well, the underlying operation will fail + fn api_key(&mut self) -> Option { + None + } + + /// Called whenever the Authenticator didn't yield a token. The delegate + /// may attempt to provide one, or just take it as a general information about the + /// impending failure. + /// The given Error provides information about why the token couldn't be acquired in the + /// first place + fn token(&mut self, err: &oauth2::Error) -> Option { + let _ = err; + None + } + + /// Called during resumable uploads to provide a URL for the impending upload. + /// It was saved after a previous call to `store_upload_url(...)`, and if not None, + /// will be used instead of asking the server for a new upload URL. + /// This is useful in case a previous resumable upload was aborted/canceled, but should now + /// be resumed. + /// The returned URL will be used exactly once - if it fails again and the delegate allows + /// to retry, we will ask the server for a new upload URL. + fn upload_url(&mut self) -> Option { + None + } + + /// Called after we have retrieved a new upload URL for a resumable upload to store it + /// in case we fail or cancel. That way, we can attempt to resume the upload later, + /// see `upload_url()`. + /// It will also be called with None after a successful upload, which allows the delegate + /// to forget the URL. That way, we will not attempt to resume an upload that has already + /// finished. + fn store_upload_url(&mut self, url: Option<&str>) { + let _ = url; + } + + /// Called whenever a server response could not be decoded from json. + /// It's for informational purposes only, the caller will return with an error + /// accordingly. + /// + /// # Arguments + /// + /// * `json_encoded_value` - The json-encoded value which failed to decode. + /// * `json_decode_error` - The decoder error + fn response_json_decode_error( + &mut self, + json_encoded_value: &str, + json_decode_error: &json::Error, + ) { + let _ = json_encoded_value; + let _ = json_decode_error; + } + + /// Called whenever the http request returns with a non-success status code. + /// This can involve authentication issues, or anything else that very much + /// depends on the used API method. + /// The delegate should check the status, header and decoded json error to decide + /// whether to retry or not. In the latter case, the underlying call will fail. + /// + /// If you choose to retry after a duration, the duration should be chosen using the + /// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff). + fn http_failure( + &mut self, + _: &hyper::Response, + _err: Option, + _: Option, + ) -> Retry { + Retry::Abort + } + + /// Called prior to sending the main request of the given method. It can be used to time + /// the call or to print progress information. + /// It's also useful as you can be sure that a request will definitely be made. + fn pre_request(&mut self) {} + + /// Return the size of each chunk of a resumable upload. + /// Must be a power of two, with 1<<18 being the smallest allowed chunk size. + /// Will be called once before starting any resumable upload. + fn chunk_size(&mut self) -> u64 { + 1 << 23 + } + + /// Called before the given chunk is uploaded to the server. + /// If true is returned, the upload will be interrupted. + /// However, it may be resumable if you stored the upload URL in a previous call + /// to `store_upload_url()` + fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool { + let _ = chunk; + false + } + + /// Called before the API request method returns, in every case. It can be used to clean up + /// internal state between calls to the API. + /// This call always has a matching call to `begin(...)`. + /// + /// # Arguments + /// + /// * `is_success` - a true value indicates the operation was successful. If false, you should + /// discard all values stored during `store_upload_url`. + fn finished(&mut self, is_success: bool) { + let _ = is_success; + } +} + +/// A delegate with a conservative default implementation, which is used if no other delegate is +/// set. +#[derive(Default)] +pub struct DefaultDelegate; + +impl Delegate for DefaultDelegate {} + +#[derive(Debug)] +pub enum Error { + /// The http connection failed + HttpError(hyper::Error), + + /// An attempt was made to upload a resource with size stored in field `.0` + /// even though the maximum upload size is what is stored in field `.1`. + UploadSizeLimitExceeded(u64, u64), + + /// Represents information about a request that was not understood by the server. + /// Details are included. + BadRequest(ErrorResponse), + + /// We needed an API key for authentication, but didn't obtain one. + /// Neither through the authenticator, nor through the Delegate. + MissingAPIKey, + + /// We required a Token, but didn't get one from the Authenticator + MissingToken(oauth2::Error), + + /// The delgate instructed to cancel the operation + Cancelled, + + /// An additional, free form field clashed with one of the built-in optional ones + FieldClash(&'static str), + + /// Shows that we failed to decode the server response. + /// This can happen if the protocol changes in conjunction with strict json decoding. + JsonDecodeError(String, json::Error), + + /// Indicates an HTTP repsonse with a non-success status code + Failure(hyper::Response), + + /// An IO error occurred while reading a stream into memory + Io(std::io::Error), +} + +impl Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Io(ref err) => err.fmt(f), + Error::HttpError(ref err) => err.fmt(f), + Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) => writeln!( + f, + "The media size {} exceeds the maximum allowed upload size of {}", + resource_size, max_size + ), + Error::MissingAPIKey => { + (writeln!( + f, + "The application's API key was not found in the configuration" + )) + .ok(); + writeln!( + f, + "It is used as there are no Scopes defined for this method." + ) + } + Error::BadRequest(ref err) => { + writeln!(f, "Bad Request ({}): {}", err.error.code, err.error.message)?; + for err in err.error.errors.iter() { + writeln!( + f, + " {}: {}, {}{}", + err.domain, + err.message, + err.reason, + match err.location { + Some(ref loc) => format!("@{}", loc), + None => String::new(), + } + )?; + } + Ok(()) + } + Error::MissingToken(ref err) => { + writeln!(f, "Token retrieval failed with error: {}", err) + } + Error::Cancelled => writeln!(f, "Operation cancelled by delegate"), + Error::FieldClash(field) => writeln!( + f, + "The custom parameter '{}' is already provided natively by the CallBuilder.", + field + ), + Error::JsonDecodeError(ref json_str, ref err) => writeln!(f, "{}: {}", err, json_str), + Error::Failure(ref response) => { + writeln!(f, "Http status indicates failure: {:?}", response) + } + } + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + match *self { + Error::HttpError(ref err) => err.source(), + Error::JsonDecodeError(_, ref err) => err.source(), + _ => None, + } + } +} + +impl From for Error { + fn from(err: std::io::Error) -> Self { + Error::Io(err) + } +} + +/// A universal result type used as return for all calls. +pub type Result = std::result::Result; + +/// Contains information about an API request. +pub struct MethodInfo { + pub id: &'static str, + pub http_method: Method, +} + +const BOUNDARY: &str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d"; + +/// Provides a `Read` interface that converts multiple parts into the protocol +/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387). +/// **Note**: This implementation is just as rich as it needs to be to perform uploads +/// to google APIs, and might not be a fully-featured implementation. +#[derive(Default)] +pub struct MultiPartReader<'a> { + raw_parts: Vec<(HeaderMap, &'a mut (dyn Read + Send))>, + current_part: Option<(Cursor>, &'a mut (dyn Read + Send))>, + last_part_boundary: Option>>, +} + +impl<'a> MultiPartReader<'a> { + /// Reserve memory for exactly the given amount of parts + pub fn reserve_exact(&mut self, cap: usize) { + self.raw_parts.reserve_exact(cap); + } + + /// Add a new part to the queue of parts to be read on the first `read` call. + /// + /// # Arguments + /// + /// `headers` - identifying the body of the part. It's similar to the header + /// in an ordinary single-part call, and should thus contain the + /// same information. + /// `reader` - a reader providing the part's body + /// `size` - the amount of bytes provided by the reader. It will be put onto the header as + /// content-size. + /// `mime` - It will be put onto the content type + pub fn add_part( + &mut self, + reader: &'a mut (dyn Read + Send), + size: u64, + mime_type: Mime, + ) -> &mut MultiPartReader<'a> { + let mut headers = HeaderMap::new(); + headers.insert( + CONTENT_TYPE, + hyper::header::HeaderValue::from_str(&format!("{}", mime_type)).unwrap(), + ); + headers.insert(CONTENT_LENGTH, size.into()); + self.raw_parts.push((headers, reader)); + self + } + + /// Returns the mime-type representing our multi-part message. + /// Use it with the ContentType header. + pub fn mime_type(&self) -> Mime { + Mime( + TopLevel::Multipart, + SubLevel::Ext("related".to_string()), + vec![( + Attr::Ext("boundary".to_string()), + Value::Ext(BOUNDARY.to_string()), + )], + ) + } + + /// Returns true if we are totally used + fn is_depleted(&self) -> bool { + self.raw_parts.is_empty() + && self.current_part.is_none() + && self.last_part_boundary.is_none() + } + + /// Returns true if we are handling our last part + fn is_last_part(&self) -> bool { + self.raw_parts.is_empty() && self.current_part.is_some() + } +} + +impl<'a> Read for MultiPartReader<'a> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + match ( + self.raw_parts.len(), + self.current_part.is_none(), + self.last_part_boundary.is_none(), + ) { + (_, _, false) => { + let br = self + .last_part_boundary + .as_mut() + .unwrap() + .read(buf) + .unwrap_or(0); + if br < buf.len() { + self.last_part_boundary = None; + } + return Ok(br); + } + (0, true, true) => return Ok(0), + (n, true, _) if n > 0 => { + let (headers, reader) = self.raw_parts.remove(0); + let mut c = Cursor::new(Vec::::new()); + // TODO: The first line ending should be omitted for the first part, + // fortunately Google's API serves don't seem to mind. + (write!( + &mut c, + "{}--{}{}{}{}{}", + LINE_ENDING, + BOUNDARY, + LINE_ENDING, + headers + .iter() + .map(|(k, v)| format!("{}: {}", k, v.to_str().unwrap())) + .join(LINE_ENDING), + LINE_ENDING, + LINE_ENDING, + )) + .unwrap(); + c.seek(SeekFrom::Start(0)).unwrap(); + self.current_part = Some((c, reader)); + } + _ => {} + } + + // read headers as long as possible + let (hb, rr) = { + let &mut (ref mut c, ref mut reader) = self.current_part.as_mut().unwrap(); + let b = c.read(buf).unwrap_or(0); + (b, reader.read(&mut buf[b..])) + }; + + match rr { + Ok(bytes_read) => { + if hb < buf.len() && bytes_read == 0 { + if self.is_last_part() { + // before clearing the last part, we will add the boundary that + // will be written last + self.last_part_boundary = Some(Cursor::new( + format!("{}--{}--{}", LINE_ENDING, BOUNDARY, LINE_ENDING).into_bytes(), + )) + } + // We are depleted - this can trigger the next part to come in + self.current_part = None; + } + let mut total_bytes_read = hb + bytes_read; + while total_bytes_read < buf.len() && !self.is_depleted() { + match self.read(&mut buf[total_bytes_read..]) { + Ok(br) => total_bytes_read += br, + Err(err) => return Err(err), + } + } + Ok(total_bytes_read) + } + Err(err) => { + // fail permanently + self.current_part = None; + self.last_part_boundary = None; + self.raw_parts.clear(); + Err(err) + } + } + } +} + +/// The `X-Upload-Content-Type` header. +/// +/// Generated via rustc --pretty expanded -Z unstable-options, and manually +/// processed to be more readable. +#[derive(PartialEq, Debug, Clone)] +pub struct XUploadContentType(pub Mime); + +impl ::std::ops::Deref for XUploadContentType { + type Target = Mime; + fn deref(&self) -> &Mime { + &self.0 + } +} +impl ::std::ops::DerefMut for XUploadContentType { + fn deref_mut(&mut self) -> &mut Mime { + &mut self.0 + } +} +impl Display for XUploadContentType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&**self, f) + } +} + +#[derive(Clone, PartialEq, Debug)] +pub struct Chunk { + pub first: u64, + pub last: u64, +} + +impl fmt::Display for Chunk { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + (write!(fmt, "{}-{}", self.first, self.last)).ok(); + Ok(()) + } +} + +impl FromStr for Chunk { + type Err = &'static str; + + /// NOTE: only implements `%i-%i`, not `*` + fn from_str(s: &str) -> std::result::Result { + let parts: Vec<&str> = s.split('-').collect(); + if parts.len() != 2 { + return Err("Expected two parts: %i-%i"); + } + Ok(Chunk { + first: match FromStr::from_str(parts[0]) { + Ok(d) => d, + _ => return Err("Couldn't parse 'first' as digit"), + }, + last: match FromStr::from_str(parts[1]) { + Ok(d) => d, + _ => return Err("Couldn't parse 'last' as digit"), + }, + }) + } +} + +/// Implements the Content-Range header, for serialization only +#[derive(Clone, PartialEq, Debug)] +pub struct ContentRange { + pub range: Option, + pub total_length: u64, +} + +impl ContentRange { + pub fn header_value(&self) -> String { + format!( + "bytes {}/{}", + match self.range { + Some(ref c) => format!("{}", c), + None => "*".to_string(), + }, + self.total_length + ) + } +} + +#[derive(Clone, PartialEq, Debug)] +pub struct RangeResponseHeader(pub Chunk); + +impl RangeResponseHeader { + fn from_bytes(raw: &[u8]) -> Self { + if !raw.is_empty() { + if let Ok(s) = std::str::from_utf8(raw) { + const PREFIX: &str = "bytes "; + if let Some(stripped) = s.strip_prefix(PREFIX) { + if let Ok(c) = ::from_str(&stripped) { + return RangeResponseHeader(c); + } + } + } + } + + panic!("Unable to parse Range header {:?}", raw) + } +} + +/// A utility type to perform a resumable upload from start to end. +pub struct ResumableUploadHelper<'a, A: 'a> { + pub client: &'a hyper::client::Client< + hyper_rustls::HttpsConnector, + hyper::body::Body, + >, + pub delegate: &'a mut dyn Delegate, + pub start_at: Option, + pub auth: &'a A, + pub user_agent: &'a str, + pub auth_header: String, + pub url: &'a str, + pub reader: &'a mut dyn ReadSeek, + pub media_type: Mime, + pub content_length: u64, +} + +impl<'a, A> ResumableUploadHelper<'a, A> { + async fn query_transfer_status( + &mut self, + ) -> std::result::Result>> { + loop { + match self + .client + .request( + hyper::Request::builder() + .method(hyper::Method::POST) + .uri(self.url) + .header(USER_AGENT, self.user_agent.to_string()) + .header( + "Content-Range", + ContentRange { + range: None, + total_length: self.content_length, + } + .header_value(), + ) + .header(AUTHORIZATION, self.auth_header.clone()) + .body(hyper::body::Body::empty()) + .unwrap(), + ) + .await + { + Ok(r) => { + // 308 = resume-incomplete == PermanentRedirect + let headers = r.headers().clone(); + let h: RangeResponseHeader = match headers.get("Range") { + Some(hh) if r.status() == StatusCode::PERMANENT_REDIRECT => { + RangeResponseHeader::from_bytes(hh.as_bytes()) + } + None | Some(_) => { + if let Retry::After(d) = self.delegate.http_failure(&r, None, None) { + sleep(d); + continue; + } + return Err(Ok(r)); + } + }; + return Ok(h.0.last); + } + Err(err) => { + if let Retry::After(d) = self.delegate.http_error(&err) { + sleep(d); + continue; + } + return Err(Err(err)); + } + } + } + } + + /// returns None if operation was cancelled by delegate, or the HttpResult. + /// It can be that we return the result just because we didn't understand the status code - + /// caller should check for status himself before assuming it's OK to use + pub async fn upload(&mut self) -> Option>> { + let mut start = match self.start_at { + Some(s) => s, + None => match self.query_transfer_status().await { + Ok(s) => s, + Err(result) => return Some(result), + }, + }; + + const MIN_CHUNK_SIZE: u64 = 1 << 18; + let chunk_size = match self.delegate.chunk_size() { + cs if cs > MIN_CHUNK_SIZE => cs, + _ => MIN_CHUNK_SIZE, + }; + + loop { + self.reader.seek(SeekFrom::Start(start)).unwrap(); + + let request_size = match self.content_length - start { + rs if rs > chunk_size => chunk_size, + rs => rs, + }; + + let mut section_reader = self.reader.take(request_size); + let mut req_bytes = vec![]; + section_reader.read_to_end(&mut req_bytes).unwrap(); + let range_header = ContentRange { + range: Some(Chunk { + first: start, + last: start + request_size - 1, + }), + total_length: self.content_length, + }; + if self.delegate.cancel_chunk_upload(&range_header) { + return None; + } + let res = self + .client + .request( + hyper::Request::builder() + .uri(self.url) + .method(hyper::Method::POST) + .header("Content-Range", range_header.header_value()) + .header(CONTENT_TYPE, format!("{}", self.media_type)) + .header(USER_AGENT, self.user_agent.to_string()) + .body(hyper::body::Body::from(req_bytes)) + .unwrap(), + ) + .await; + match res { + Ok(res) => { + start += request_size; + + if res.status() == StatusCode::PERMANENT_REDIRECT { + continue; + } + + let (res_parts, res_body) = res.into_parts(); + let res_body_string: String = String::from_utf8( + hyper::body::to_bytes(res_body) + .await + .unwrap() + .into_iter() + .collect(), + ) + .unwrap(); + let reconstructed_result = + hyper::Response::from_parts(res_parts, res_body_string.clone().into()); + + if !reconstructed_result.status().is_success() { + if let Retry::After(d) = self.delegate.http_failure( + &reconstructed_result, + json::from_str(&res_body_string).ok(), + json::from_str(&res_body_string).ok(), + ) { + sleep(d); + continue; + } + } + return Some(Ok(reconstructed_result)); + } + Err(err) => { + if let Retry::After(d) = self.delegate.http_error(&err) { + sleep(d); + continue; + } + return Some(Err(err)); + } + } + } + } +} + +// Copy of src/rust/cli/client.rs +// TODO(ST): Allow sharing common code between program types +pub fn remove_json_null_values(value: &mut json::value::Value) { + match *value { + json::value::Value::Object(ref mut map) => { + let mut for_removal = Vec::new(); + + for (key, mut value) in map.iter_mut() { + if value.is_null() { + for_removal.push(key.clone()); + } else { + remove_json_null_values(&mut value); + } + } + + for key in &for_removal { + map.remove(key); + } + } + json::value::Value::Array(ref mut arr) => { + let mut i = 0; + while i < arr.len() { + if arr[i].is_null() { + arr.remove(i); + } else { + remove_json_null_values(&mut arr[i]); + i += 1; + } + } + } + _ => {} + } +} + +// Borrowing the body object as mutable and converts it to a string +pub async fn get_body_as_string(res_body: &mut hyper::Body) -> String { + let res_body_buf = hyper::body::to_bytes(res_body).await.unwrap(); + let res_body_string = String::from_utf8_lossy(&res_body_buf); + res_body_string.to_string() +} diff --git a/gen/docs1/src/lib.rs b/gen/docs1/src/lib.rs new file mode 100644 index 0000000000..12fb40589d --- /dev/null +++ b/gen/docs1/src/lib.rs @@ -0,0 +1,224 @@ +// DO NOT EDIT ! +// This file was generated automatically from 'src/mako/api/lib.rs.mako' +// DO NOT EDIT ! + +//! This documentation was generated from *Dns* crate version *2.0.8+20210319*, where *20210319* is the exact revision of the *dns:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v2.0.8*. +//! +//! Everything else about the *Dns* *v1* API can be found at the +//! [official documentation site](https://cloud.google.com/dns/docs). +//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/main/gen/dns1). +//! # Features +//! +//! Handle the following *Resources* with ease from the central [hub](Dns) ... +//! +//! * [changes](api::Change) +//! * [*create*](api::ChangeCreateCall), [*get*](api::ChangeGetCall) and [*list*](api::ChangeListCall) +//! * [dns keys](api::DnsKey) +//! * [*get*](api::DnsKeyGetCall) and [*list*](api::DnsKeyListCall) +//! * managed zone operations +//! * [*get*](api::ManagedZoneOperationGetCall) and [*list*](api::ManagedZoneOperationListCall) +//! * [managed zones](api::ManagedZone) +//! * [*create*](api::ManagedZoneCreateCall), [*delete*](api::ManagedZoneDeleteCall), [*get*](api::ManagedZoneGetCall), [*list*](api::ManagedZoneListCall), [*patch*](api::ManagedZonePatchCall) and [*update*](api::ManagedZoneUpdateCall) +//! * [policies](api::Policy) +//! * [*create*](api::PolicyCreateCall), [*delete*](api::PolicyDeleteCall), [*get*](api::PolicyGetCall), [*list*](api::PolicyListCall), [*patch*](api::PolicyPatchCall) and [*update*](api::PolicyUpdateCall) +//! * [projects](api::Project) +//! * [*get*](api::ProjectGetCall), [*managed zones rrsets create*](api::ProjectManagedZoneRrsetCreateCall), [*managed zones rrsets delete*](api::ProjectManagedZoneRrsetDeleteCall), [*managed zones rrsets get*](api::ProjectManagedZoneRrsetGetCall) and [*managed zones rrsets patch*](api::ProjectManagedZoneRrsetPatchCall) +//! * [resource record sets](api::ResourceRecordSet) +//! * [*list*](api::ResourceRecordSetListCall) +//! +//! +//! +//! +//! 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](Dns)** +//! * a central object to maintain state and allow accessing all *Activities* +//! * creates [*Method Builders*](client::MethodsBuilder) which in turn +//! allow access to individual [*Call Builders*](client::CallBuilder) +//! * **[Resources](client::Resource)** +//! * primary types that you can apply *Activities* to +//! * a collection of properties and *Parts* +//! * **[Parts](client::Part)** +//! * a collection of properties +//! * never directly used in *Activities* +//! * **[Activities](client::CallBuilder)** +//! * 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().await +//! ``` +//! +//! Or specifically ... +//! +//! ```ignore +//! let r = hub.managed_zones().create(...).doit().await +//! let r = hub.managed_zones().delete(...).doit().await +//! let r = hub.managed_zones().get(...).doit().await +//! let r = hub.managed_zones().list(...).doit().await +//! let r = hub.managed_zones().patch(...).doit().await +//! let r = hub.managed_zones().update(...).doit().await +//! ``` +//! +//! 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-dns1 = "*" +//! hyper = "^0.14" +//! hyper-rustls = "^0.22" +//! serde = "^1.0" +//! serde_json = "^1.0" +//! yup-oauth2 = "^5.0" +//! ``` +//! +//! ## A complete example +//! +//! ```test_harness,no_run +//! extern crate hyper; +//! extern crate hyper_rustls; +//! extern crate yup_oauth2 as oauth2; +//! extern crate google_dns1 as dns1; +//! use dns1::{Result, Error}; +//! # async fn dox() { +//! use std::default::Default; +//! use oauth2; +//! use dns1::Dns; +//! +//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and +//! // `client_secret`, among other things. +//! let secret: oauth2::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 = yup_oauth2::InstalledFlowAuthenticator::builder( +//! secret, +//! yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect, +//! ).build().await.unwrap(); +//! let mut hub = Dns::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots()), 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.managed_zones().list("project") +//! .page_token("At") +//! .max_results(-8) +//! .dns_name("sed") +//! .doit().await; +//! +//! 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::Io(_) +//! |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](client::Result) enumeration as return value of +//! the doit() methods, or handed as possibly intermediate results to either the +//! [Hub Delegate](client::Delegate), 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](client::Result), should be +//! read by you to obtain the media. +//! If such a method also supports a [Response Result](client::ResponseResult), 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](client::Delegate) to the +//! [Method Builder](client::CallBuilder) 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](client::Delegate) 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](client::RequestValue) and +//! [decodable](client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses +//! are valid. +//! Most optionals are are considered [Parts](client::Part) 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](client::CallBuilder), 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](client::RequestValue) 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; + +pub mod api; +pub mod client; + +// Re-export the hub type and some basic client structs +pub use api::Dns; +pub use client::{Result, Error, Delegate};