Files
google-apis-rs/gen/autoscaler1_beta2/src/lib.rs
Sebastian Thiel 91861dcb71 fix(rustup): rustc (be9bd7c93 2015-04-05)
* using std::convert
* update to latest hyper (and other dependencies)

Related to #46
2015-04-07 11:59:10 +02:00

3768 lines
158 KiB
Rust

// DO NOT EDIT !
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
// DO NOT EDIT !
//! This documentation was generated from *autoscaler* crate version *0.1.2+20141112*, where *20141112* is the exact revision of the *autoscaler:v1beta2* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.2*.
//!
//! Everything else about the *autoscaler* *v1_beta2* API can be found at the
//! [official documentation site](http://developers.google.com/compute/docs/autoscaler).
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/autoscaler1_beta2).
//! # Features
//!
//! Handle the following *Resources* with ease from the central [hub](struct.AutoscalerHub.html) ...
//!
//! * [autoscalers](struct.Autoscaler.html)
//! * [*delete*](struct.AutoscalerDeleteCall.html), [*get*](struct.AutoscalerGetCall.html), [*insert*](struct.AutoscalerInsertCall.html), [*list*](struct.AutoscalerListCall.html), [*patch*](struct.AutoscalerPatchCall.html) and [*update*](struct.AutoscalerUpdateCall.html)
//! * zone operations
//! * [*delete*](struct.ZoneOperationDeleteCall.html), [*get*](struct.ZoneOperationGetCall.html) and [*list*](struct.ZoneOperationListCall.html)
//! * [zones](struct.Zone.html)
//! * [*list*](struct.ZoneListCall.html)
//!
//!
//!
//!
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](../index.html).
//!
//! # Structure of this Library
//!
//! The API is structured into the following primary items:
//!
//! * **[Hub](struct.AutoscalerHub.html)**
//! * a central object to maintain state and allow accessing all *Activities*
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
//! * **[Resources](trait.Resource.html)**
//! * primary types that you can apply *Activities* to
//! * a collection of properties and *Parts*
//! * **[Parts](trait.Part.html)**
//! * a collection of properties
//! * never directly used in *Activities*
//! * **[Activities](trait.CallBuilder.html)**
//! * operations to apply to *Resources*
//!
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
//!
//! Generally speaking, you can invoke *Activities* like this:
//!
//! ```Rust,ignore
//! let r = hub.resource().activity(...).doit()
//! ```
//!
//! Or specifically ...
//!
//! ```ignore
//! let r = hub.autoscalers().list(...).doit()
//! let r = hub.autoscalers().update(...).doit()
//! let r = hub.autoscalers().patch(...).doit()
//! let r = hub.autoscalers().delete(...).doit()
//! let r = hub.autoscalers().insert(...).doit()
//! let r = hub.autoscalers().get(...).doit()
//! ```
//!
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
//! The `doit()` method performs the actual communication with the server and returns the respective result.
//!
//! # Usage
//!
//! ## Setting up your Project
//!
//! To use this library, you would put the following lines into your `Cargo.toml` file:
//!
//! ```toml
//! [dependencies]
//! google-autoscaler1_beta2 = "*"
//! ```
//!
//! ## A complete example
//!
//! ```test_harness,no_run
//! extern crate hyper;
//! extern crate yup_oauth2 as oauth2;
//! extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
//! use autoscaler1_beta2::{Result, Error};
//! # #[test] fn egal() {
//! use std::default::Default;
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
//! use autoscaler1_beta2::AutoscalerHub;
//!
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
//! // `client_secret`, among other things.
//! let secret: ApplicationSecret = Default::default();
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
//! // unless you replace `None` with the desired Flow.
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
//! // retrieve them from storage.
//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
//! hyper::Client::new(),
//! <MemoryStorage as Default>::default(), None);
//! let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
//! // You can configure optional parameters by calling the respective setters at will, and
//! // execute the final call using `doit()`.
//! // Values shown here are possibly random and not representative !
//! let result = hub.autoscalers().list("project", "zone")
//! .page_token("accusam")
//! .max_results(93)
//! .filter("justo")
//! .doit();
//!
//! match result {
//! Err(e) => match e {
//! Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
//! Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
//! Error::MissingToken => println!("OAuth2: Missing Token"),
//! Error::Cancelled => println!("Operation canceled by user"),
//! Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
//! Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
//! Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
//! Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
//! },
//! Ok(_) => println!("Success (value doesn't print)"),
//! }
//! # }
//! ```
//! ## Handling Errors
//!
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
//! the doit() methods, or handed as possibly intermediate results to either the
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](../yup-oauth2/trait.AuthenticatorDelegate.html).
//!
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
//! makes the system potentially resilient to all kinds of errors.
//!
//! ## Uploads and Downloads
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
//! read by you to obtain the media.
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
//! this call: `.param("alt", "media")`.
//!
//! Methods supporting uploads can do so using up to 2 different protocols:
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
//!
//! ## Customization and Callbacks
//!
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
//! Respective methods will be called to provide progress information, as well as determine whether the system should
//! retry on failure.
//!
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
//!
//! ## Optional Parts in Server-Requests
//!
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
//! are valid.
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
//! the server to indicate either the set parts of the request or the desired parts in the response.
//!
//! ## Builder Arguments
//!
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
//! These will always take a single argument, for which the following statements are true.
//!
//! * [PODs][wiki-pod] are handed by copy
//! * strings are passed as `&str`
//! * [request values](trait.RequestValue.html) are borrowed
//!
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
//!
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
//! [google-go-api]: https://github.com/google/google-api-go-client
//!
//!
#![feature(std_misc)]
// Unused attributes happen thanks to defined, but unused structures
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
// unused imports in fully featured APIs. Same with unused_mut ... .
#![allow(unused_imports, unused_mut, dead_code)]
// Required for serde annotations
#![feature(custom_derive, custom_attribute, plugin, slice_patterns)]
#![plugin(serde_macros)]
#[macro_use]
extern crate hyper;
extern crate serde;
extern crate yup_oauth2 as oauth2;
extern crate mime;
extern crate url;
mod cmn;
use std::collections::HashMap;
use std::cell::RefCell;
use std::borrow::BorrowMut;
use std::default::Default;
use std::collections::BTreeMap;
use std::marker::PhantomData;
use serde::json;
use std::io;
use std::fs;
use std::thread::sleep_ms;
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder, Resource, JsonServerError};
// ##############
// UTILITIES ###
// ############
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Hash)]
pub enum Scope {
/// View and manage your Google Compute Engine resources
Compute,
/// View your Google Compute Engine resources
ComputeReadonly,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::Compute => "https://www.googleapis.com/auth/compute",
Scope::ComputeReadonly => "https://www.googleapis.com/auth/compute.readonly",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::ComputeReadonly
}
}
// ########
// HUB ###
// ######
/// Central instance to access all AutoscalerHub related resource activities
///
/// # Examples
///
/// Instantiate a new hub
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// use autoscaler1_beta2::{Result, Error};
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use autoscaler1_beta2::AutoscalerHub;
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: ApplicationSecret = Default::default();
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
/// // unless you replace `None` with the desired Flow.
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
/// // retrieve them from storage.
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().list("project", "zone")
/// .page_token("labore")
/// .max_results(92)
/// .filter("nonumy")
/// .doit();
///
/// match result {
/// Err(e) => match e {
/// Error::HttpError(err) => println!("HTTPERROR: {:?}", err),
/// Error::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
/// Error::MissingToken => println!("OAuth2: Missing Token"),
/// Error::Cancelled => println!("Operation canceled by user"),
/// Error::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
/// Error::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
/// Error::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
/// Error::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
/// },
/// Ok(_) => println!("Success (value doesn't print)"),
/// }
/// # }
/// ```
pub struct AutoscalerHub<C, NC, A> {
client: RefCell<C>,
auth: RefCell<A>,
_user_agent: String,
_m: PhantomData<NC>
}
impl<'a, C, NC, A> Hub for AutoscalerHub<C, NC, A> {}
impl<'a, C, NC, A> AutoscalerHub<C, NC, A>
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
pub fn new(client: C, authenticator: A) -> AutoscalerHub<C, NC, A> {
AutoscalerHub {
client: RefCell::new(client),
auth: RefCell::new(authenticator),
_user_agent: "google-api-rust-client/0.1.2".to_string(),
_m: PhantomData
}
}
pub fn autoscalers(&'a self) -> AutoscalerMethods<'a, C, NC, A> {
AutoscalerMethods { hub: &self }
}
pub fn zone_operations(&'a self) -> ZoneOperationMethods<'a, C, NC, A> {
ZoneOperationMethods { hub: &self }
}
pub fn zones(&'a self) -> ZoneMethods<'a, C, NC, A> {
ZoneMethods { hub: &self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/0.1.2`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
let prev = self._user_agent.clone();
self._user_agent = agent_name;
prev
}
}
// ############
// SCHEMAS ###
// ##########
/// 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, Deserialize)]
pub struct DeprecationStatus {
/// no description provided
pub deleted: String,
/// no description provided
pub deprecated: String,
/// no description provided
pub state: String,
/// no description provided
pub obsolete: String,
/// no description provided
pub replacement: String,
}
impl Part for DeprecationStatus {}
/// 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, Deserialize)]
pub struct OperationWarningsData {
/// no description provided
pub key: String,
/// no description provided
pub value: String,
}
impl NestedType for OperationWarningsData {}
impl Part for OperationWarningsData {}
/// 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 zones](struct.ZoneListCall.html) (none)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Zone {
/// no description provided
pub status: Option<String>,
/// Type of the resource.
pub kind: Option<String>,
/// no description provided
pub description: Option<String>,
/// no description provided
#[serde(alias="maintenanceWindows")]
pub maintenance_windows: Option<Vec<ZoneMaintenanceWindows>>,
/// no description provided
pub deprecated: Option<DeprecationStatus>,
/// no description provided
pub region: Option<String>,
/// no description provided
#[serde(alias="creationTimestamp")]
pub creation_timestamp: Option<String>,
/// no description provided
pub id: Option<String>,
/// Server defined URL for the resource (output only).
#[serde(alias="selfLink")]
pub self_link: Option<String>,
/// no description provided
pub name: Option<String>,
}
impl Resource for Zone {}
/// 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, Deserialize)]
pub struct OperationWarnings {
/// no description provided
pub message: String,
/// no description provided
pub code: String,
/// no description provided
pub data: Vec<OperationWarningsData>,
}
impl NestedType for OperationWarnings {}
impl Part for OperationWarnings {}
/// 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 zone operations](struct.ZoneOperationListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct OperationList {
/// no description provided
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// no description provided
pub items: Vec<Operation>,
/// Type of resource. Always compute#operations for Operations resource.
pub kind: String,
/// no description provided
pub id: String,
/// no description provided
#[serde(alias="selfLink")]
pub self_link: String,
}
impl ResponseResult for OperationList {}
/// 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, Deserialize)]
pub struct ZoneMaintenanceWindows {
/// no description provided
#[serde(alias="endTime")]
pub end_time: String,
/// no description provided
pub description: String,
/// no description provided
#[serde(alias="beginTime")]
pub begin_time: String,
/// no description provided
pub name: String,
}
impl NestedType for ZoneMaintenanceWindows {}
impl Part for ZoneMaintenanceWindows {}
/// Custom utilization metric policy.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AutoscalingPolicyCustomMetricUtilization {
/// Identifier of the metric. It should be a Cloud Monitoring metric. The metric can not have negative values. The metric should be an utilization metric (increasing number of VMs handling requests x times should reduce average value of the metric roughly x times). For example you could use: compute.googleapis.com/instance/network/received_bytes_count.
pub metric: String,
/// Defines type in which utilization_target is expressed.
#[serde(alias="utilizationTargetType")]
pub utilization_target_type: String,
/// Target value of the metric which Autoscaler should maintain. Must be a positive value.
#[serde(alias="utilizationTarget")]
pub utilization_target: f64,
}
impl Part for AutoscalingPolicyCustomMetricUtilization {}
/// 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, Deserialize)]
pub struct OperationErrorErrors {
/// no description provided
pub message: String,
/// no description provided
pub code: String,
/// no description provided
pub location: String,
}
impl NestedType for OperationErrorErrors {}
impl Part for OperationErrorErrors {}
/// Cloud Autoscaler policy.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AutoscalingPolicy {
/// Configuration parameters of autoscaling based on custom metric.
#[serde(alias="customMetricUtilizations")]
pub custom_metric_utilizations: Vec<AutoscalingPolicyCustomMetricUtilization>,
/// The maximum number of replicas that the Autoscaler can scale up to.
#[serde(alias="maxNumReplicas")]
pub max_num_replicas: i32,
/// Exactly one utilization policy should be provided. Configuration parameters of CPU based autoscaling policy.
#[serde(alias="cpuUtilization")]
pub cpu_utilization: AutoscalingPolicyCpuUtilization,
/// The minimum number of replicas that the Autoscaler can scale down to.
#[serde(alias="minNumReplicas")]
pub min_num_replicas: i32,
/// The number of seconds that the Autoscaler should wait between two succeeding changes to the number of virtual machines. You should define an interval that is at least as long as the initialization time of a virtual machine and the time it may take for replica pool to create the virtual machine. The default is 60 seconds.
#[serde(alias="coolDownPeriodSec")]
pub cool_down_period_sec: i32,
/// Configuration parameters of autoscaling based on load balancer.
#[serde(alias="loadBalancingUtilization")]
pub load_balancing_utilization: AutoscalingPolicyLoadBalancingUtilization,
}
impl Part for AutoscalingPolicy {}
/// 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, Deserialize)]
pub struct OperationError {
/// no description provided
pub errors: Vec<OperationErrorErrors>,
}
impl NestedType for OperationError {}
impl Part for OperationError {}
/// CPU utilization policy.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AutoscalingPolicyCpuUtilization {
/// The target utilization that the Autoscaler should maintain. It is represented as a fraction of used cores. For example: 6 cores used in 8-core VM are represented here as 0.75. Must be a float value between (0, 1]. If not defined, the default is 0.8.
#[serde(alias="utilizationTarget")]
pub utilization_target: f64,
}
impl Part for AutoscalingPolicyCpuUtilization {}
/// Load balancing utilization policy.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AutoscalingPolicyLoadBalancingUtilization {
/// Fraction of backend capacity utilization (set in HTTP load balancing configuration) that Autoscaler should maintain. Must be a positive float value. If not defined, the default is 0.8. For example if your maxRatePerInstance capacity (in HTTP Load Balancing configuration) is set at 10 and you would like to keep number of instances such that each instance receives 7 QPS on average, set this to 0.7.
#[serde(alias="utilizationTarget")]
pub utilization_target: f64,
}
impl Part for AutoscalingPolicyLoadBalancingUtilization {}
/// 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 autoscalers](struct.AutoscalerListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct AutoscalerListResponse {
/// [Output only] A token used to continue a truncated list request.
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// Autoscaler resources.
pub items: Vec<Autoscaler>,
/// Type of resource.
pub kind: String,
}
impl ResponseResult for AutoscalerListResponse {}
/// 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 autoscalers](struct.AutoscalerUpdateCall.html) (response)
/// * [delete autoscalers](struct.AutoscalerDeleteCall.html) (response)
/// * [insert autoscalers](struct.AutoscalerInsertCall.html) (response)
/// * [get zone operations](struct.ZoneOperationGetCall.html) (response)
/// * [patch autoscalers](struct.AutoscalerPatchCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct Operation {
/// no description provided
pub status: String,
/// no description provided
#[serde(alias="insertTime")]
pub insert_time: String,
/// no description provided
pub warnings: Vec<OperationWarnings>,
/// no description provided
pub error: OperationError,
/// no description provided
#[serde(alias="targetId")]
pub target_id: String,
/// no description provided
#[serde(alias="targetLink")]
pub target_link: String,
/// no description provided
#[serde(alias="startTime")]
pub start_time: String,
/// no description provided
#[serde(alias="clientOperationId")]
pub client_operation_id: String,
/// no description provided
#[serde(alias="creationTimestamp")]
pub creation_timestamp: String,
/// no description provided
pub id: String,
/// [Output Only] Type of the resource. Always kind#operation for Operation resources.
pub kind: String,
/// no description provided
pub name: String,
/// no description provided
pub zone: String,
/// no description provided
pub region: String,
/// no description provided
#[serde(alias="selfLink")]
pub self_link: String,
/// no description provided
#[serde(alias="operationType")]
pub operation_type: String,
/// no description provided
#[serde(alias="httpErrorMessage")]
pub http_error_message: String,
/// no description provided
pub progress: i32,
/// no description provided
#[serde(alias="endTime")]
pub end_time: String,
/// no description provided
#[serde(alias="httpErrorStatusCode")]
pub http_error_status_code: i32,
/// no description provided
#[serde(alias="statusMessage")]
pub status_message: String,
/// no description provided
pub user: String,
}
impl ResponseResult for Operation {}
/// 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 zones](struct.ZoneListCall.html) (response)
///
#[derive(Default, Clone, Debug, Deserialize)]
pub struct ZoneList {
/// no description provided
#[serde(alias="nextPageToken")]
pub next_page_token: String,
/// no description provided
pub items: Vec<Zone>,
/// Type of resource.
pub kind: String,
/// no description provided
pub id: String,
/// Server defined URL for this resource (output only).
#[serde(alias="selfLink")]
pub self_link: String,
}
impl ResponseResult for ZoneList {}
/// Cloud Autoscaler resource.
///
/// # 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 autoscalers](struct.AutoscalerListCall.html) (none)
/// * [update autoscalers](struct.AutoscalerUpdateCall.html) (request)
/// * [patch autoscalers](struct.AutoscalerPatchCall.html) (request)
/// * [delete autoscalers](struct.AutoscalerDeleteCall.html) (none)
/// * [insert autoscalers](struct.AutoscalerInsertCall.html) (request)
/// * [get autoscalers](struct.AutoscalerGetCall.html) (response)
///
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Autoscaler {
/// Type of resource.
pub kind: Option<String>,
/// An optional textual description of the resource provided by the client.
pub description: Option<String>,
/// Name of the Autoscaler resource. Must be unique per project and zone.
pub name: Option<String>,
/// Configuration parameters for autoscaling algorithm.
#[serde(alias="autoscalingPolicy")]
pub autoscaling_policy: Option<AutoscalingPolicy>,
/// [Output Only] Creation timestamp in RFC3339 text format.
#[serde(alias="creationTimestamp")]
pub creation_timestamp: Option<String>,
/// [Output Only] Unique identifier for the resource; defined by the server.
pub id: Option<String>,
/// [Output Only] A self-link to the Autoscaler configuration resource.
#[serde(alias="selfLink")]
pub self_link: Option<String>,
/// URL to the entity which will be autoscaled. Currently the only supported value is ReplicaPool?s URL. Note: it is illegal to specify multiple Autoscalers for the same target.
pub target: Option<String>,
}
impl RequestValue for Autoscaler {}
impl Resource for Autoscaler {}
impl ResponseResult for Autoscaler {}
// ###################
// MethodBuilders ###
// #################
/// A builder providing access to all methods supported on *zone* resources.
/// It is not used directly, but through the `AutoscalerHub` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use autoscaler1_beta2::AutoscalerHub;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `list(...)`
/// // to build up your call.
/// let rb = hub.zones();
/// # }
/// ```
pub struct ZoneMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
}
impl<'a, C, NC, A> MethodsBuilder for ZoneMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
///
///
/// # Arguments
///
/// * `project` - No description provided.
pub fn list(&self, project: &str) -> ZoneListCall<'a, C, NC, A> {
ZoneListCall {
hub: self.hub,
_project: project.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *zoneOperation* resources.
/// It is not used directly, but through the `AutoscalerHub` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use autoscaler1_beta2::AutoscalerHub;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)` and `list(...)`
/// // to build up your call.
/// let rb = hub.zone_operations();
/// # }
/// ```
pub struct ZoneOperationMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
}
impl<'a, C, NC, A> MethodsBuilder for ZoneOperationMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneOperationMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// Retrieves the list of operation resources contained within the specified zone.
///
/// # Arguments
///
/// * `project` - No description provided.
/// * `zone` - No description provided.
pub fn list(&self, project: &str, zone: &str) -> ZoneOperationListCall<'a, C, NC, A> {
ZoneOperationListCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes the specified zone-specific operation resource.
///
/// # Arguments
///
/// * `project` - No description provided.
/// * `zone` - No description provided.
/// * `operation` - No description provided.
pub fn delete(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationDeleteCall<'a, C, NC, A> {
ZoneOperationDeleteCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_operation: operation.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves the specified zone-specific operation resource.
///
/// # Arguments
///
/// * `project` - No description provided.
/// * `zone` - No description provided.
/// * `operation` - No description provided.
pub fn get(&self, project: &str, zone: &str, operation: &str) -> ZoneOperationGetCall<'a, C, NC, A> {
ZoneOperationGetCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_operation: operation.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
/// A builder providing access to all methods supported on *autoscaler* resources.
/// It is not used directly, but through the `AutoscalerHub` hub.
///
/// # Example
///
/// Instantiate a resource builder
///
/// ```test_harness,no_run
/// extern crate hyper;
/// extern crate yup_oauth2 as oauth2;
/// extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
///
/// # #[test] fn egal() {
/// use std::default::Default;
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// use autoscaler1_beta2::AutoscalerHub;
///
/// let secret: ApplicationSecret = Default::default();
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// hyper::Client::new(),
/// <MemoryStorage as Default>::default(), None);
/// let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
/// // to build up your call.
/// let rb = hub.autoscalers();
/// # }
/// ```
pub struct AutoscalerMethods<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
}
impl<'a, C, NC, A> MethodsBuilder for AutoscalerMethods<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerMethods<'a, C, NC, A> {
/// Create a builder to help you perform the following task:
///
/// Lists all Autoscaler resources in this zone.
///
/// # Arguments
///
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
pub fn list(&self, project: &str, zone: &str) -> AutoscalerListCall<'a, C, NC, A> {
AutoscalerListCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the entire content of the Autoscaler resource.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
/// * `autoscaler` - Name of the Autoscaler resource.
pub fn update(&self, request: &Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerUpdateCall<'a, C, NC, A> {
AutoscalerUpdateCall {
hub: self.hub,
_request: request.clone(),
_project: project.to_string(),
_zone: zone.to_string(),
_autoscaler: autoscaler.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Update the entire content of the Autoscaler resource. This method supports patch semantics.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
/// * `autoscaler` - Name of the Autoscaler resource.
pub fn patch(&self, request: &Autoscaler, project: &str, zone: &str, autoscaler: &str) -> AutoscalerPatchCall<'a, C, NC, A> {
AutoscalerPatchCall {
hub: self.hub,
_request: request.clone(),
_project: project.to_string(),
_zone: zone.to_string(),
_autoscaler: autoscaler.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Deletes the specified Autoscaler resource.
///
/// # Arguments
///
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
/// * `autoscaler` - Name of the Autoscaler resource.
pub fn delete(&self, project: &str, zone: &str, autoscaler: &str) -> AutoscalerDeleteCall<'a, C, NC, A> {
AutoscalerDeleteCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_autoscaler: autoscaler.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Adds new Autoscaler resource.
///
/// # Arguments
///
/// * `request` - No description provided.
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
pub fn insert(&self, request: &Autoscaler, project: &str, zone: &str) -> AutoscalerInsertCall<'a, C, NC, A> {
AutoscalerInsertCall {
hub: self.hub,
_request: request.clone(),
_project: project.to_string(),
_zone: zone.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Gets the specified Autoscaler resource.
///
/// # Arguments
///
/// * `project` - Project ID of Autoscaler resource.
/// * `zone` - Zone name of Autoscaler resource.
/// * `autoscaler` - Name of the Autoscaler resource.
pub fn get(&self, project: &str, zone: &str, autoscaler: &str) -> AutoscalerGetCall<'a, C, NC, A> {
AutoscalerGetCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_autoscaler: autoscaler.to_string(),
_delegate: Default::default(),
_scopes: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
///
///
/// A builder for the *list* method supported by a *zone* resource.
/// It is not used directly, but through a `ZoneMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.zones().list("project")
/// .page_token("gubergren")
/// .max_results(6)
/// .filter("aliquyam")
/// .doit();
/// # }
/// ```
pub struct ZoneListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for ZoneListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, ZoneList)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.zones.list",
http_method: hyper::method::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._filter {
params.push(("filter", value.to_string()));
}
for &field in ["alt", "project", "pageToken", "maxResults", "filter"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/{project}/zones".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::ComputeReadonly.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<usize> = Vec::with_capacity(1);
for param_name in ["project"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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) -> ZoneListCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
pub fn page_token(mut self, new_value: &str) -> ZoneListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
pub fn max_results(mut self, new_value: u32) -> ZoneListCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *filter* query property to the given value.
///
///
pub fn filter(mut self, new_value: &str) -> ZoneListCall<'a, C, NC, A> {
self._filter = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneListCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ZoneListCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ZoneListCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves the list of operation resources contained within the specified zone.
///
/// A builder for the *list* method supported by a *zoneOperation* resource.
/// It is not used directly, but through a `ZoneOperationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.zone_operations().list("project", "zone")
/// .page_token("justo")
/// .max_results(80)
/// .filter("et")
/// .doit();
/// # }
/// ```
pub struct ZoneOperationListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for ZoneOperationListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneOperationListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, OperationList)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.zoneOperations.list",
http_method: hyper::method::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(("zone", self._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._filter {
params.push(("filter", value.to_string()));
}
for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/{project}/zones/{zone}/operations".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::ComputeReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["project", "zone"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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) -> ZoneOperationListCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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 zone(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
pub fn page_token(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
pub fn max_results(mut self, new_value: u32) -> ZoneOperationListCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *filter* query property to the given value.
///
///
pub fn filter(mut self, new_value: &str) -> ZoneOperationListCall<'a, C, NC, A> {
self._filter = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationListCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationListCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ZoneOperationListCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Deletes the specified zone-specific operation resource.
///
/// A builder for the *delete* method supported by a *zoneOperation* resource.
/// It is not used directly, but through a `ZoneOperationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.zone_operations().delete("project", "zone", "operation")
/// .doit();
/// # }
/// ```
pub struct ZoneOperationDeleteCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_operation: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for ZoneOperationDeleteCall<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneOperationDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<hyper::client::Response> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.zoneOperations.delete",
http_method: hyper::method::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(("zone", self._zone.to_string()));
params.push(("operation", self._operation.to_string()));
for &field in ["project", "zone", "operation"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/{project}/zones/{zone}/operations/{operation}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Compute.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{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<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "operation"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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) -> ZoneOperationDeleteCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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 zone(mut self, new_value: &str) -> ZoneOperationDeleteCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// 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) -> ZoneOperationDeleteCall<'a, C, NC, A> {
self._operation = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationDeleteCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationDeleteCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ZoneOperationDeleteCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Retrieves the specified zone-specific operation resource.
///
/// A builder for the *get* method supported by a *zoneOperation* resource.
/// It is not used directly, but through a `ZoneOperationMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.zone_operations().get("project", "zone", "operation")
/// .doit();
/// # }
/// ```
pub struct ZoneOperationGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_operation: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for ZoneOperationGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> ZoneOperationGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.zoneOperations.get",
http_method: hyper::method::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(("zone", self._zone.to_string()));
params.push(("operation", self._operation.to_string()));
for &field in ["alt", "project", "zone", "operation"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/{project}/zones/{zone}/operations/{operation}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::ComputeReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{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<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "operation"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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) -> ZoneOperationGetCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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 zone(mut self, new_value: &str) -> ZoneOperationGetCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// 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) -> ZoneOperationGetCall<'a, C, NC, A> {
self._operation = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ZoneOperationGetCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> ZoneOperationGetCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> ZoneOperationGetCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Lists all Autoscaler resources in this zone.
///
/// A builder for the *list* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().list("project", "zone")
/// .page_token("Lorem")
/// .max_results(26)
/// .filter("erat")
/// .doit();
/// # }
/// ```
pub struct AutoscalerListCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerListCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerListCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, AutoscalerListResponse)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.list",
http_method: hyper::method::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(("zone", self._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._filter {
params.push(("filter", value.to_string()));
}
for &field in ["alt", "project", "zone", "pageToken", "maxResults", "filter"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::ComputeReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["project", "zone"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerListCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerListCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *page token* query property to the given value.
///
///
pub fn page_token(mut self, new_value: &str) -> AutoscalerListCall<'a, C, NC, A> {
self._page_token = Some(new_value.to_string());
self
}
/// Sets the *max results* query property to the given value.
///
///
pub fn max_results(mut self, new_value: u32) -> AutoscalerListCall<'a, C, NC, A> {
self._max_results = Some(new_value);
self
}
/// Sets the *filter* query property to the given value.
///
///
pub fn filter(mut self, new_value: &str) -> AutoscalerListCall<'a, C, NC, A> {
self._filter = Some(new_value.to_string());
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerListCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerListCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerListCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update the entire content of the Autoscaler resource.
///
/// A builder for the *update* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// use autoscaler1_beta2::Autoscaler;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req: Autoscaler = Default::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().update(&req, "project", "zone", "autoscaler")
/// .doit();
/// # }
/// ```
pub struct AutoscalerUpdateCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_request: Autoscaler,
_project: String,
_zone: String,
_autoscaler: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerUpdateCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerUpdateCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.update",
http_method: hyper::method::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(("zone", self._zone.to_string()));
params.push(("autoscaler", self._autoscaler.to_string()));
for &field in ["alt", "project", "zone", "autoscaler"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Compute.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "autoscaler"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Put, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(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: &Autoscaler) -> AutoscalerUpdateCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *autoscaler* 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.
///
/// Name of the Autoscaler resource.
pub fn autoscaler(mut self, new_value: &str) -> AutoscalerUpdateCall<'a, C, NC, A> {
self._autoscaler = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerUpdateCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerUpdateCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerUpdateCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Update the entire content of the Autoscaler resource. This method supports patch semantics.
///
/// A builder for the *patch* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// use autoscaler1_beta2::Autoscaler;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req: Autoscaler = Default::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().patch(&req, "project", "zone", "autoscaler")
/// .doit();
/// # }
/// ```
pub struct AutoscalerPatchCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_request: Autoscaler,
_project: String,
_zone: String,
_autoscaler: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerPatchCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerPatchCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.patch",
http_method: hyper::method::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(("zone", self._zone.to_string()));
params.push(("autoscaler", self._autoscaler.to_string()));
for &field in ["alt", "project", "zone", "autoscaler"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Compute.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "autoscaler"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Patch, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(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: &Autoscaler) -> AutoscalerPatchCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *autoscaler* 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.
///
/// Name of the Autoscaler resource.
pub fn autoscaler(mut self, new_value: &str) -> AutoscalerPatchCall<'a, C, NC, A> {
self._autoscaler = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerPatchCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerPatchCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerPatchCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Deletes the specified Autoscaler resource.
///
/// A builder for the *delete* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().delete("project", "zone", "autoscaler")
/// .doit();
/// # }
/// ```
pub struct AutoscalerDeleteCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_autoscaler: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerDeleteCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerDeleteCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.delete",
http_method: hyper::method::Method::Delete });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("project", self._project.to_string()));
params.push(("zone", self._zone.to_string()));
params.push(("autoscaler", self._autoscaler.to_string()));
for &field in ["alt", "project", "zone", "autoscaler"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Compute.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "autoscaler"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *autoscaler* 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.
///
/// Name of the Autoscaler resource.
pub fn autoscaler(mut self, new_value: &str) -> AutoscalerDeleteCall<'a, C, NC, A> {
self._autoscaler = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerDeleteCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerDeleteCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerDeleteCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Adds new Autoscaler resource.
///
/// A builder for the *insert* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// use autoscaler1_beta2::Autoscaler;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the respective structure. Some of the parts shown here might not be applicable !
/// // Values shown here are possibly random and not representative !
/// let mut req: Autoscaler = Default::default();
///
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().insert(&req, "project", "zone")
/// .doit();
/// # }
/// ```
pub struct AutoscalerInsertCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_request: Autoscaler,
_project: String,
_zone: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerInsertCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerInsertCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.insert",
http_method: hyper::method::Method::Post });
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
params.push(("project", self._project.to_string()));
params.push(("zone", self._zone.to_string()));
for &field in ["alt", "project", "zone"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::Compute.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
for param_name in ["project", "zone"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
let mut request_value_reader = io::Cursor::new(json::to_vec(&self._request));
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Post, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone())
.header(ContentType(json_mime_type.clone()))
.header(ContentLength(request_size as u64))
.body(&mut request_value_reader);
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(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: &Autoscaler) -> AutoscalerInsertCall<'a, C, NC, A> {
self._request = new_value.clone();
self
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerInsertCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerInsertCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerInsertCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerInsertCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerInsertCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}
/// Gets the specified Autoscaler resource.
///
/// A builder for the *get* method supported by a *autoscaler* resource.
/// It is not used directly, but through a `AutoscalerMethods` instance.
///
/// # Example
///
/// Instantiate a resource method builder
///
/// ```test_harness,no_run
/// # extern crate hyper;
/// # extern crate yup_oauth2 as oauth2;
/// # extern crate google_autoscaler1_beta2 as autoscaler1_beta2;
/// # #[test] fn egal() {
/// # use std::default::Default;
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
/// # use autoscaler1_beta2::AutoscalerHub;
///
/// # let secret: ApplicationSecret = Default::default();
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
/// # hyper::Client::new(),
/// # <MemoryStorage as Default>::default(), None);
/// # let mut hub = AutoscalerHub::new(hyper::Client::new(), auth);
/// // You can configure optional parameters by calling the respective setters at will, and
/// // execute the final call using `doit()`.
/// // Values shown here are possibly random and not representative !
/// let result = hub.autoscalers().get("project", "zone", "autoscaler")
/// .doit();
/// # }
/// ```
pub struct AutoscalerGetCall<'a, C, NC, A>
where C: 'a, NC: 'a, A: 'a {
hub: &'a AutoscalerHub<C, NC, A>,
_project: String,
_zone: String,
_autoscaler: String,
_delegate: Option<&'a mut Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeMap<String, ()>
}
impl<'a, C, NC, A> CallBuilder for AutoscalerGetCall<'a, C, NC, A> {}
impl<'a, C, NC, A> AutoscalerGetCall<'a, C, NC, A> where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
/// Perform the operation you have build so far.
pub fn doit(mut self) -> Result<(hyper::client::Response, Autoscaler)> {
use std::io::{Read, Seek};
use hyper::header::{ContentType, ContentLength, Authorization, UserAgent, Location};
let mut dd = DefaultDelegate;
let mut dlg: &mut Delegate = match self._delegate {
Some(d) => d,
None => &mut dd
};
dlg.begin(MethodInfo { id: "autoscaler.autoscalers.get",
http_method: hyper::method::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(("zone", self._zone.to_string()));
params.push(("autoscaler", self._autoscaler.to_string()));
for &field in ["alt", "project", "zone", "autoscaler"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(Error::FieldClash(field));
}
}
for (name, value) in self._additional_params.iter() {
params.push((&name, value.clone()));
}
params.push(("alt", "json".to_string()));
let mut url = "https://www.googleapis.com/autoscaler/v1beta2/projects/{project}/zones/{zone}/autoscalers/{autoscaler}".to_string();
if self._scopes.len() == 0 {
self._scopes.insert(Scope::ComputeReadonly.as_ref().to_string(), ());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{autoscaler}", "autoscaler")].iter() {
let mut replace_with: Option<&str> = None;
for &(name, ref value) in params.iter() {
if name == param_name {
replace_with = Some(value);
break;
}
}
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
}
{
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
for param_name in ["project", "zone", "autoscaler"].iter() {
for (index, &(ref name, _)) in params.iter().rev().enumerate() {
if name == param_name {
indices_for_removal.push(params.len() - index - 1);
break;
}
}
}
for &index in indices_for_removal.iter() {
params.remove(index);
}
}
if params.len() > 0 {
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_ref()))));
}
loop {
let mut token = self.hub.auth.borrow_mut().token(self._scopes.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
dlg.finished(false);
return Err(Error::MissingToken)
}
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
let mut req_result = {
let mut client = &mut *self.hub.client.borrow_mut();
let mut req = client.borrow_mut().request(hyper::method::Method::Get, url.as_ref())
.header(UserAgent(self.hub._user_agent.clone()))
.header(auth_header.clone());
dlg.pre_request();
req.send()
};
match req_result {
Err(err) => {
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::HttpError(err))
}
Ok(mut res) => {
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let oauth2::Retry::After(d) = dlg.http_failure(&res, json::from_str(&json_err).ok()) {
sleep_ms(d.num_milliseconds() as u32);
continue;
}
dlg.finished(false);
return Err(Error::Failure(res))
}
let result_value = {
let mut json_response = String::new();
res.read_to_string(&mut json_response).unwrap();
match json::from_str(&json_response) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&json_response, &err);
return Err(Error::JsonDecodeError(err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
/// 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.
///
/// Project ID of Autoscaler resource.
pub fn project(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, NC, A> {
self._project = new_value.to_string();
self
}
/// Sets the *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.
///
/// Zone name of Autoscaler resource.
pub fn zone(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, NC, A> {
self._zone = new_value.to_string();
self
}
/// Sets the *autoscaler* 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.
///
/// Name of the Autoscaler resource.
pub fn autoscaler(mut self, new_value: &str) -> AutoscalerGetCall<'a, C, NC, A> {
self._autoscaler = new_value.to_string();
self
}
/// Sets the *delegate* property to the given value.
///
///
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
/// while executing the actual API request.
///
/// It should be used to handle progress information, and to implement a certain level of resilience.
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AutoscalerGetCall<'a, C, NC, A> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters which are not yet available through their own
/// setters.
///
/// Please note that this method must not be used to set any of the known paramters
/// which have their own setter method. If done anyway, the request will fail.
///
/// # Additional Parameters
///
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
/// * *alt* (query-string) - Data format for the response.
pub fn param<T>(mut self, name: T, value: T) -> AutoscalerGetCall<'a, C, NC, A>
where T: AsRef<str> {
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 of relying on the
/// automated algorithm which simply prefers read-only scopes over those who are not.
///
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
/// tokens for more than one scope.
///
/// Usually there is more than one suitable scope to authorize an operation, some of which may
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
/// sufficient, a read-write scope will do as well.
pub fn add_scope<T>(mut self, scope: T) -> AutoscalerGetCall<'a, C, NC, A>
where T: AsRef<str> {
self._scopes.insert(scope.as_ref().to_string(), ());
self
}
}