mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
Previously, it would query the size from the wrong dict and obtain the value 0 all the time. This would have made every upload fail with `UploadSizeLimitExeeded`. Now we obtain the actual size limit, and will ignore it if unset/0 for some reason. Patch += 1
3354 lines
148 KiB
Rust
3354 lines
148 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *replicapoolupdater* crate version *0.1.1+20150129*, where *20150129* is the exact revision of the *replicapoolupdater:v1beta1* schema built by the [mako](http://www.makotemplates.org/) code generator *v0.1.1*.
|
|
//!
|
|
//! Everything else about the *replicapoolupdater* *v1_beta1* API can be found at the
|
|
//! [official documentation site](https://cloud.google.com/compute/docs/instance-groups/manager/#applying_rolling_updates_using_the_updater_service).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/replicapoolupdater1_beta1).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.Replicapoolupdater.html) ...
|
|
//!
|
|
//! * [rolling updates](struct.RollingUpdate.html)
|
|
//! * [*cancel*](struct.RollingUpdateCancelCall.html), [*get*](struct.RollingUpdateGetCall.html), [*insert*](struct.RollingUpdateInsertCall.html), [*list*](struct.RollingUpdateListCall.html), [*list instance updates*](struct.RollingUpdateListInstanceUpdateCall.html), [*pause*](struct.RollingUpdatePauseCall.html), [*resume*](struct.RollingUpdateResumeCall.html) and [*rollback*](struct.RollingUpdateRollbackCall.html)
|
|
//! * zone operations
|
|
//! * [*get*](struct.ZoneOperationGetCall.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.Replicapoolupdater.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * **[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*
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.rolling_updates().pause(...).doit()
|
|
//! let r = hub.rolling_updates().rollback(...).doit()
|
|
//! let r = hub.rolling_updates().get(...).doit()
|
|
//! let r = hub.rolling_updates().resume(...).doit()
|
|
//! let r = hub.rolling_updates().list(...).doit()
|
|
//! let r = hub.rolling_updates().insert(...).doit()
|
|
//! let r = hub.rolling_updates().list_instance_updates(...).doit()
|
|
//! let r = hub.rolling_updates().cancel(...).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-replicapoolupdater1_beta1 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate "yup-oauth2" as oauth2;
|
|
//! extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
//! use replicapoolupdater1_beta1::Result;
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
//!
|
|
//! // 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 = Replicapoolupdater::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.rolling_updates().list("project", "zone")
|
|
//! .page_token("takimata")
|
|
//! .max_results(31)
|
|
//! .instance_group_manager("amet.")
|
|
//! .filter("erat")
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
//! Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
//! Result::MissingToken => println!("OAuth2: Missing Token"),
|
|
//! Result::Cancelled => println!("Operation cancelled by user"),
|
|
//! Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
//! Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
//! Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
//! Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
//! Result::Success(_) => 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 Downlods
|
|
//! 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 identifyable 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(core,io,thread_sleep)]
|
|
// 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)]
|
|
#![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;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, CallBuilder, Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, ResourceMethodsBuilder, 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 data across Google Cloud Platform services
|
|
CloudPlatform,
|
|
|
|
/// View and manage replica pools
|
|
Replicapool,
|
|
|
|
/// View replica pools
|
|
ReplicapoolReadonly,
|
|
}
|
|
|
|
impl Str for Scope {
|
|
fn as_slice(&self) -> &str {
|
|
match *self {
|
|
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
|
|
Scope::Replicapool => "https://www.googleapis.com/auth/replicapool",
|
|
Scope::ReplicapoolReadonly => "https://www.googleapis.com/auth/replicapool.readonly",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::ReplicapoolReadonly
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all Replicapoolupdater related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// use replicapoolupdater1_beta1::Result;
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// // 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 = Replicapoolupdater::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.rolling_updates().list("project", "zone")
|
|
/// .page_token("nonumy")
|
|
/// .max_results(82)
|
|
/// .instance_group_manager("gubergren")
|
|
/// .filter("sadipscing")
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Result::HttpError(err) => println!("HTTPERROR: {:?}", err),
|
|
/// Result::MissingAPIKey => println!("Auth: Missing API Key - used if there are no scopes"),
|
|
/// Result::MissingToken => println!("OAuth2: Missing Token"),
|
|
/// Result::Cancelled => println!("Operation cancelled by user"),
|
|
/// Result::UploadSizeLimitExceeded(size, max_size) => println!("Upload size too big: {} of {}", size, max_size),
|
|
/// Result::Failure(_) => println!("General Failure (hyper::client::Response doesn't print)"),
|
|
/// Result::FieldClash(clashed_field) => println!("You added custom parameter which is part of builder: {:?}", clashed_field),
|
|
/// Result::JsonDecodeError(err) => println!("Couldn't understand server reply - maybe API needs update: {:?}", err),
|
|
/// Result::Success(_) => println!("Success (value doesn't print)"),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct Replicapoolupdater<C, NC, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
|
|
_m: PhantomData<NC>
|
|
}
|
|
|
|
impl<'a, C, NC, A> Hub for Replicapoolupdater<C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> Replicapoolupdater<C, NC, A>
|
|
where NC: hyper::net::NetworkConnector, C: BorrowMut<hyper::Client<NC>>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> Replicapoolupdater<C, NC, A> {
|
|
Replicapoolupdater {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/0.1.1".to_string(),
|
|
_m: PhantomData
|
|
}
|
|
}
|
|
|
|
pub fn rolling_updates(&'a self) -> RollingUpdateMethods<'a, C, NC, A> {
|
|
RollingUpdateMethods { hub: &self }
|
|
}
|
|
pub fn zone_operations(&'a self) -> ZoneOperationMethods<'a, C, NC, A> {
|
|
ZoneOperationMethods { 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.1`.
|
|
///
|
|
/// 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 ###
|
|
// ##########
|
|
/// Update of a single instance.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InstanceUpdate {
|
|
/// Status of the instance update. Possible values are:
|
|
/// - "PENDING": The instance update is pending execution.
|
|
/// - "ROLLING_FORWARD": The instance update is going forward.
|
|
/// - "ROLLING_BACK": The instance update is being rolled back.
|
|
/// - "PAUSED": The instance update is temporarily paused (inactive).
|
|
/// - "ROLLED_OUT": The instance update is finished, the instance is running the new template.
|
|
/// - "ROLLED_BACK": The instance update is finished, the instance has been reverted to the previous template.
|
|
/// - "CANCELLED": The instance update is paused and no longer can be resumed, undefined in which template the instance is running.
|
|
pub status: String,
|
|
/// URL of the instance being updated.
|
|
pub instance: String,
|
|
/// Errors that occurred during the instance update.
|
|
pub error: InstanceUpdateError,
|
|
}
|
|
|
|
impl Part for InstanceUpdate {}
|
|
|
|
|
|
/// Response returned by ListInstanceUpdates method.
|
|
///
|
|
/// # 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 instance updates rolling updates](struct.RollingUpdateListInstanceUpdateCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InstanceUpdateList {
|
|
/// A token used to continue a truncated list request.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// Collection of requested instance updates.
|
|
pub items: Vec<InstanceUpdate>,
|
|
/// [Output Only] Type of the resource.
|
|
pub kind: String,
|
|
/// [Output Only] The fully qualified URL for the resource.
|
|
#[serde(alias="selfLink")]
|
|
pub self_link: String,
|
|
}
|
|
|
|
impl ResponseResult for InstanceUpdateList {}
|
|
|
|
|
|
/// [Output only] Metadata for this warning in key:value format.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct OperationWarningsData {
|
|
/// [Output Only] Metadata key for this warning.
|
|
pub key: String,
|
|
/// [Output Only] Metadata value for this warning.
|
|
pub value: String,
|
|
}
|
|
|
|
impl NestedType for OperationWarningsData {}
|
|
impl Part for OperationWarningsData {}
|
|
|
|
|
|
/// Errors that occurred during the instance update.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InstanceUpdateError {
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
pub errors: Vec<InstanceUpdateErrorErrors>,
|
|
}
|
|
|
|
impl NestedType for InstanceUpdateError {}
|
|
impl Part for InstanceUpdateError {}
|
|
|
|
|
|
/// The following represents a resource describing a single update (rollout) of a group of instances to the given template.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [pause rolling updates](struct.RollingUpdatePauseCall.html) (none)
|
|
/// * [rollback rolling updates](struct.RollingUpdateRollbackCall.html) (none)
|
|
/// * [get rolling updates](struct.RollingUpdateGetCall.html) (response)
|
|
/// * [resume rolling updates](struct.RollingUpdateResumeCall.html) (none)
|
|
/// * [list rolling updates](struct.RollingUpdateListCall.html) (none)
|
|
/// * [insert rolling updates](struct.RollingUpdateInsertCall.html) (request)
|
|
/// * [list instance updates rolling updates](struct.RollingUpdateListInstanceUpdateCall.html) (none)
|
|
/// * [cancel rolling updates](struct.RollingUpdateCancelCall.html) (none)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RollingUpdate {
|
|
/// [Output Only] Status of the update. Possible values are:
|
|
/// - "ROLLING_FORWARD": The update is going forward.
|
|
/// - "ROLLING_BACK": The update is being rolled back.
|
|
/// - "PAUSED": The update is temporarily paused (inactive).
|
|
/// - "ROLLED_OUT": The update is finished, all instances have been updated successfully.
|
|
/// - "ROLLED_BACK": The update is finished, all instances have been reverted to the previous template.
|
|
/// - "CANCELLED": The update is paused and no longer can be resumed, undefined how many instances are running in which template.
|
|
pub status: Option<String>,
|
|
/// An optional textual description of the resource; provided by the client when the resource is created.
|
|
pub description: Option<String>,
|
|
/// Fully-qualified URL of an instance group being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set.
|
|
#[serde(alias="instanceGroup")]
|
|
pub instance_group: Option<String>,
|
|
/// List of fully-qualified URLs of instances to be updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set.
|
|
pub instances: Option<Vec<String>>,
|
|
/// Fully-qualified URL of an instance template to apply.
|
|
#[serde(alias="instanceTemplate")]
|
|
pub instance_template: Option<String>,
|
|
/// Specifies the action to take for each instance within the instance group. This can be RECREATE which will recreate each instance and is only available for managed instance groups. It can also be REBOOT which performs a soft reboot for each instance and is only available for regular (non-managed) instance groups and explicit lists of instances.
|
|
#[serde(alias="actionType")]
|
|
pub action_type: Option<String>,
|
|
/// [Output Only] User who requested the update, for example: user@example.com.
|
|
pub user: Option<String>,
|
|
/// [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] Type of the resource.
|
|
pub kind: Option<String>,
|
|
/// [Output Only] The fully qualified URL for the resource.
|
|
#[serde(alias="selfLink")]
|
|
pub self_link: Option<String>,
|
|
/// [Output Only] Errors that occurred during rolling update.
|
|
pub error: Option<RollingUpdateError>,
|
|
/// Parameters of the update process.
|
|
pub policy: Option<RollingUpdatePolicy>,
|
|
/// [Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the update will be complete. This number should be monotonically increasing as the update progresses.
|
|
pub progress: Option<i32>,
|
|
/// [Output Only] An optional textual description of the current status of the update.
|
|
#[serde(alias="statusMessage")]
|
|
pub status_message: Option<String>,
|
|
/// Fully-qualified URL of an instance group manager being updated. Exactly one of instanceGroupManager, instanceGroup and instance list must be set.
|
|
#[serde(alias="instanceGroupManager")]
|
|
pub instance_group_manager: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for RollingUpdate {}
|
|
impl Resource for RollingUpdate {}
|
|
impl ResponseResult for RollingUpdate {}
|
|
|
|
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RollingUpdateErrorErrors {
|
|
/// [Output Only] An optional, human-readable error message.
|
|
pub message: String,
|
|
/// [Output Only] The error type identifier for this error.
|
|
pub code: String,
|
|
/// [Output Only] Indicates the field in the request which caused the error. This property is optional.
|
|
pub location: String,
|
|
}
|
|
|
|
impl NestedType for RollingUpdateErrorErrors {}
|
|
impl Part for RollingUpdateErrorErrors {}
|
|
|
|
|
|
/// Parameters of the update process.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RollingUpdatePolicy {
|
|
/// Time period after the instance has been restarted but before marking the update of this instance as done. This field is deprecated and ignored by Rolling Updater.
|
|
#[serde(alias="sleepAfterInstanceRestartSec")]
|
|
pub sleep_after_instance_restart_sec: i32,
|
|
/// Maximum amount of time we will wait after finishing all steps until we receive HEALTHY state for instance. If this deadline is exceeded instance update is considered as failed.
|
|
#[serde(alias="instanceStartupTimeoutSec")]
|
|
pub instance_startup_timeout_sec: i32,
|
|
/// Maximum number of instances that can be updated simultaneously (concurrently). An update of an instance starts when the instance is about to be restarted and finishes after the instance has been restarted and the sleep period (defined by sleepAfterInstanceRestartSec) has passed.
|
|
#[serde(alias="maxNumConcurrentInstances")]
|
|
pub max_num_concurrent_instances: i32,
|
|
/// Specifies minimum amount of time we will spend on updating single instance, measuring at the start of the first update action (e.g. Recreate call on Instance Group Manager or Stop call on Instance resource). If actual instance update takes less time we will simply sleep before proceeding with next instance.
|
|
#[serde(alias="minInstanceUpdateTimeSec")]
|
|
pub min_instance_update_time_sec: i32,
|
|
/// Number of instances updated before the update gets automatically paused.
|
|
#[serde(alias="autoPauseAfterInstances")]
|
|
pub auto_pause_after_instances: i32,
|
|
/// Maximum number of instance updates that can fail without failing the group update. Instance update is considered failed if any of it's update actions (e.g. Stop call on Instance resource in Rolling Reboot) failed with permanent failure, or if after finishing all update actions this instance is in UNHEALTHY state.
|
|
#[serde(alias="maxNumFailedInstances")]
|
|
pub max_num_failed_instances: i32,
|
|
}
|
|
|
|
impl NestedType for RollingUpdatePolicy {}
|
|
impl Part for RollingUpdatePolicy {}
|
|
|
|
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct OperationErrorErrors {
|
|
/// [Output Only] An optional, human-readable error message.
|
|
pub message: String,
|
|
/// [Output Only] The error type identifier for this error.
|
|
pub code: String,
|
|
/// [Output Only] Indicates the field in the request which caused the error. This property is optional.
|
|
pub location: String,
|
|
}
|
|
|
|
impl NestedType for OperationErrorErrors {}
|
|
impl Part for OperationErrorErrors {}
|
|
|
|
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct InstanceUpdateErrorErrors {
|
|
/// [Output Only] An optional, human-readable error message.
|
|
pub message: String,
|
|
/// [Output Only] The error type identifier for this error.
|
|
pub code: String,
|
|
/// [Output Only] Indicates the field in the request which caused the error. This property is optional.
|
|
pub location: String,
|
|
}
|
|
|
|
impl NestedType for InstanceUpdateErrorErrors {}
|
|
impl Part for InstanceUpdateErrorErrors {}
|
|
|
|
|
|
/// [Output Only] If errors occurred during processing of this operation, this field will be populated.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct OperationError {
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
pub errors: Vec<OperationErrorErrors>,
|
|
}
|
|
|
|
impl NestedType for OperationError {}
|
|
impl Part for OperationError {}
|
|
|
|
|
|
/// 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 {
|
|
/// [Output only] Optional human-readable details for this warning.
|
|
pub message: String,
|
|
/// [Output only] The warning type identifier for this warning.
|
|
pub code: String,
|
|
/// [Output only] Metadata for this warning in key:value format.
|
|
pub data: Vec<OperationWarningsData>,
|
|
}
|
|
|
|
impl NestedType for OperationWarnings {}
|
|
impl Part for OperationWarnings {}
|
|
|
|
|
|
/// An operation resource, used to manage asynchronous API requests.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [pause rolling updates](struct.RollingUpdatePauseCall.html) (response)
|
|
/// * [get zone operations](struct.ZoneOperationGetCall.html) (response)
|
|
/// * [rollback rolling updates](struct.RollingUpdateRollbackCall.html) (response)
|
|
/// * [resume rolling updates](struct.RollingUpdateResumeCall.html) (response)
|
|
/// * [insert rolling updates](struct.RollingUpdateInsertCall.html) (response)
|
|
/// * [cancel rolling updates](struct.RollingUpdateCancelCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct Operation {
|
|
/// [Output Only] Status of the operation. Can be one of the following: "PENDING", "RUNNING", or "DONE".
|
|
pub status: String,
|
|
/// [Output Only] The time that this operation was requested. This is in RFC 3339 format.
|
|
#[serde(alias="insertTime")]
|
|
pub insert_time: String,
|
|
/// no description provided
|
|
pub warnings: Vec<OperationWarnings>,
|
|
/// [Output Only] If errors occurred during processing of this operation, this field will be populated.
|
|
pub error: OperationError,
|
|
/// [Output Only] Unique target id which identifies a particular incarnation of the target.
|
|
#[serde(alias="targetId")]
|
|
pub target_id: String,
|
|
/// [Output Only] URL of the resource the operation is mutating (output only).
|
|
#[serde(alias="targetLink")]
|
|
pub target_link: String,
|
|
/// [Output Only] The time that this operation was started by the server. This is in RFC 3339 format.
|
|
#[serde(alias="startTime")]
|
|
pub start_time: String,
|
|
/// no description provided
|
|
#[serde(alias="clientOperationId")]
|
|
pub client_operation_id: String,
|
|
/// [Output Only] Creation timestamp in RFC3339 text format (output only).
|
|
#[serde(alias="creationTimestamp")]
|
|
pub creation_timestamp: String,
|
|
/// [Output Only] Unique identifier for the resource; defined by the server.
|
|
pub id: String,
|
|
/// [Output Only] Type of the resource. Always kind#operation for Operation resources.
|
|
pub kind: String,
|
|
/// [Output Only] Name of the resource (output only).
|
|
pub name: String,
|
|
/// [Output Only] URL of the zone where the operation resides (output only).
|
|
pub zone: String,
|
|
/// [Output Only] URL of the region where the operation resides (output only).
|
|
pub region: String,
|
|
/// [Output Only] Server defined URL for the resource.
|
|
#[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,
|
|
/// [Output Only] An optional textual description of the current status of the operation.
|
|
#[serde(alias="statusMessage")]
|
|
pub status_message: String,
|
|
/// no description provided
|
|
pub user: String,
|
|
}
|
|
|
|
impl ResponseResult for Operation {}
|
|
|
|
|
|
/// [Output Only] Errors that occurred during rolling update.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RollingUpdateError {
|
|
/// [Output Only] The array of errors encountered while processing this operation.
|
|
pub errors: Vec<RollingUpdateErrorErrors>,
|
|
}
|
|
|
|
impl NestedType for RollingUpdateError {}
|
|
impl Part for RollingUpdateError {}
|
|
|
|
|
|
/// Response returned by List method.
|
|
///
|
|
/// # 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 rolling updates](struct.RollingUpdateListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Deserialize)]
|
|
pub struct RollingUpdateList {
|
|
/// A token used to continue a truncated list request.
|
|
#[serde(alias="nextPageToken")]
|
|
pub next_page_token: String,
|
|
/// Collection of requested updates.
|
|
pub items: Vec<RollingUpdate>,
|
|
/// [Output Only] Type of the resource.
|
|
pub kind: String,
|
|
/// [Output Only] The fully qualified URL for the resource.
|
|
#[serde(alias="selfLink")]
|
|
pub self_link: String,
|
|
}
|
|
|
|
impl ResponseResult for RollingUpdateList {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *rollingUpdate* resources.
|
|
/// It is not used directly, but through the `Replicapoolupdater` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Replicapoolupdater::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `cancel(...)`, `get(...)`, `insert(...)`, `list(...)`, `list_instance_updates(...)`, `pause(...)`, `resume(...)` and `rollback(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.rolling_updates();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateMethods<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder for RollingUpdateMethods<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateMethods<'a, C, NC, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Pauses the update in state from ROLLING_FORWARD or ROLLING_BACK. Has no effect if invoked when the state of the update is PAUSED.
|
|
pub fn pause(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdatePauseCall<'a, C, NC, A> {
|
|
RollingUpdatePauseCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Rolls back the update in state from ROLLING_FORWARD or PAUSED. Has no effect if invoked when the state of the update is ROLLED_BACK.
|
|
pub fn rollback(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdateRollbackCall<'a, C, NC, A> {
|
|
RollingUpdateRollbackCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns information about an update.
|
|
pub fn get(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdateGetCall<'a, C, NC, A> {
|
|
RollingUpdateGetCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Continues an update in PAUSED state. Has no effect if invoked when the state of the update is ROLLED_OUT.
|
|
pub fn resume(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdateResumeCall<'a, C, NC, A> {
|
|
RollingUpdateResumeCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists recent updates for a given managed instance group, in reverse chronological order and paginated format.
|
|
pub fn list(&self, project: &str, zone: &str) -> RollingUpdateListCall<'a, C, NC, A> {
|
|
RollingUpdateListCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_page_token: Default::default(),
|
|
_max_results: Default::default(),
|
|
_instance_group_manager: 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:
|
|
///
|
|
/// Inserts and starts a new update.
|
|
pub fn insert(&self, request: &RollingUpdate, project: &str, zone: &str) -> RollingUpdateInsertCall<'a, C, NC, A> {
|
|
RollingUpdateInsertCall {
|
|
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:
|
|
///
|
|
/// Lists the current status for each instance within a given update.
|
|
pub fn list_instance_updates(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {
|
|
RollingUpdateListInstanceUpdateCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.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:
|
|
///
|
|
/// Cancels an update. The update must be PAUSED before it can be cancelled. This has no effect if the update is already CANCELLED.
|
|
pub fn cancel(&self, project: &str, zone: &str, rolling_update: &str) -> RollingUpdateCancelCall<'a, C, NC, A> {
|
|
RollingUpdateCancelCall {
|
|
hub: self.hub,
|
|
_project: project.to_string(),
|
|
_zone: zone.to_string(),
|
|
_rolling_update: rolling_update.to_string(),
|
|
_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 `Replicapoolupdater` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate "yup-oauth2" as oauth2;
|
|
/// extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::new(),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = Replicapoolupdater::new(hyper::Client::new(), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `get(...)`
|
|
/// // 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 Replicapoolupdater<C, NC, A>,
|
|
}
|
|
|
|
impl<'a, C, NC, A> ResourceMethodsBuilder 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 specified zone-specific operation resource.
|
|
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(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Pauses the update in state from ROLLING_FORWARD or ROLLING_BACK. Has no effect if invoked when the state of the update is PAUSED.
|
|
///
|
|
/// A builder for the *pause* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().pause("project", "zone", "rollingUpdate")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdatePauseCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdatePauseCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdatePauseCall<'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: "replicapoolupdater.rollingUpdates.pause",
|
|
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()));
|
|
params.push(("rollingUpdate", self._rolling_update.to_string()));
|
|
for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/pause".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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::Post, url.as_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdatePauseCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdatePauseCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdatePauseCall<'a, C, NC, A> {
|
|
self._rolling_update = 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) -> RollingUpdatePauseCall<'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) -> RollingUpdatePauseCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdatePauseCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Rolls back the update in state from ROLLING_FORWARD or PAUSED. Has no effect if invoked when the state of the update is ROLLED_BACK.
|
|
///
|
|
/// A builder for the *rollback* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().rollback("project", "zone", "rollingUpdate")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateRollbackCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateRollbackCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateRollbackCall<'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: "replicapoolupdater.rollingUpdates.rollback",
|
|
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()));
|
|
params.push(("rollingUpdate", self._rolling_update.to_string()));
|
|
for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/rollback".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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::Post, url.as_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateRollbackCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateRollbackCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateRollbackCall<'a, C, NC, A> {
|
|
self._rolling_update = 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) -> RollingUpdateRollbackCall<'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) -> RollingUpdateRollbackCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateRollbackCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns information about an update.
|
|
///
|
|
/// A builder for the *get* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().get("project", "zone", "rollingUpdate")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateGetCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateGetCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateGetCall<'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, RollingUpdate)> {
|
|
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: "replicapoolupdater.rollingUpdates.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(("rollingUpdate", self._rolling_update.to_string()));
|
|
for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::ReplicapoolReadonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateGetCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateGetCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateGetCall<'a, C, NC, A> {
|
|
self._rolling_update = 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) -> RollingUpdateGetCall<'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) -> RollingUpdateGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateGetCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Continues an update in PAUSED state. Has no effect if invoked when the state of the update is ROLLED_OUT.
|
|
///
|
|
/// A builder for the *resume* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().resume("project", "zone", "rollingUpdate")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateResumeCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateResumeCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateResumeCall<'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: "replicapoolupdater.rollingUpdates.resume",
|
|
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()));
|
|
params.push(("rollingUpdate", self._rolling_update.to_string()));
|
|
for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/resume".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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::Post, url.as_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateResumeCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateResumeCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateResumeCall<'a, C, NC, A> {
|
|
self._rolling_update = 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) -> RollingUpdateResumeCall<'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) -> RollingUpdateResumeCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateResumeCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists recent updates for a given managed instance group, in reverse chronological order and paginated format.
|
|
///
|
|
/// A builder for the *list* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().list("project", "zone")
|
|
/// .page_token("Lorem")
|
|
/// .max_results(26)
|
|
/// .instance_group_manager("erat")
|
|
/// .filter("sadipscing")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateListCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_page_token: Option<String>,
|
|
_max_results: Option<u32>,
|
|
_instance_group_manager: Option<String>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateListCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateListCall<'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, RollingUpdateList)> {
|
|
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: "replicapoolupdater.rollingUpdates.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
params.push(("project", self._project.to_string()));
|
|
params.push(("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._instance_group_manager {
|
|
params.push(("instanceGroupManager", value.to_string()));
|
|
}
|
|
if let Some(value) = self._filter {
|
|
params.push(("filter", value.to_string()));
|
|
}
|
|
for &field in ["alt", "project", "zone", "pageToken", "maxResults", "instanceGroupManager", "filter"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::ReplicapoolReadonly.as_slice().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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateListCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateListCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
|
|
pub fn page_token(mut self, new_value: &str) -> RollingUpdateListCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
|
|
pub fn max_results(mut self, new_value: u32) -> RollingUpdateListCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *instance group manager* query property to the given value.
|
|
///
|
|
///
|
|
/// The name of the instance group manager used for filtering.
|
|
pub fn instance_group_manager(mut self, new_value: &str) -> RollingUpdateListCall<'a, C, NC, A> {
|
|
self._instance_group_manager = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *filter* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Filter expression for filtering listed resources.
|
|
pub fn filter(mut self, new_value: &str) -> RollingUpdateListCall<'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) -> RollingUpdateListCall<'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) -> RollingUpdateListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateListCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Inserts and starts a new update.
|
|
///
|
|
/// A builder for the *insert* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// use replicapoolupdater1_beta1::RollingUpdate;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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: RollingUpdate = 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.rolling_updates().insert(&req, "project", "zone")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateInsertCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_request: RollingUpdate,
|
|
_project: String,
|
|
_zone: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateInsertCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateInsertCall<'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: "replicapoolupdater.rollingUpdates.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 Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_slice().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_slice()))));
|
|
}
|
|
|
|
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 Result::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_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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: &RollingUpdate) -> RollingUpdateInsertCall<'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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateInsertCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateInsertCall<'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) -> RollingUpdateInsertCall<'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) -> RollingUpdateInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateInsertCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists the current status for each instance within a given update.
|
|
///
|
|
/// A builder for the *listInstanceUpdates* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().list_instance_updates("project", "zone", "rollingUpdate")
|
|
/// .page_token("labore")
|
|
/// .max_results(62)
|
|
/// .filter("dolore")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateListInstanceUpdateCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: 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 RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateListInstanceUpdateCall<'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, InstanceUpdateList)> {
|
|
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: "replicapoolupdater.rollingUpdates.listInstanceUpdates",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((8 + self._additional_params.len()));
|
|
params.push(("project", self._project.to_string()));
|
|
params.push(("zone", self._zone.to_string()));
|
|
params.push(("rollingUpdate", self._rolling_update.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", "rollingUpdate", "pageToken", "maxResults", "filter"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/instanceUpdates".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::ReplicapoolReadonly.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {
|
|
self._rolling_update = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *page token* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Tag returned by a previous list request truncated by maxResults. Used to continue a previous list request.
|
|
pub fn page_token(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Sets the *max results* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Maximum count of results to be returned. Maximum value is 500 and default value is 500.
|
|
pub fn max_results(mut self, new_value: u32) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A> {
|
|
self._max_results = Some(new_value);
|
|
self
|
|
}
|
|
/// Sets the *filter* query property to the given value.
|
|
///
|
|
///
|
|
/// Optional. Filter expression for filtering listed resources.
|
|
pub fn filter(mut self, new_value: &str) -> RollingUpdateListInstanceUpdateCall<'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) -> RollingUpdateListInstanceUpdateCall<'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) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateListInstanceUpdateCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Cancels an update. The update must be PAUSED before it can be cancelled. This has no effect if the update is already CANCELLED.
|
|
///
|
|
/// A builder for the *cancel* method supported by a *rollingUpdate* resource.
|
|
/// It is not used directly, but through a `RollingUpdateMethods`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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.rolling_updates().cancel("project", "zone", "rollingUpdate")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct RollingUpdateCancelCall<'a, C, NC, A>
|
|
where C: 'a, NC: 'a, A: 'a {
|
|
|
|
hub: &'a Replicapoolupdater<C, NC, A>,
|
|
_project: String,
|
|
_zone: String,
|
|
_rolling_update: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, NC, A> CallBuilder for RollingUpdateCancelCall<'a, C, NC, A> {}
|
|
|
|
impl<'a, C, NC, A> RollingUpdateCancelCall<'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: "replicapoolupdater.rollingUpdates.cancel",
|
|
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()));
|
|
params.push(("rollingUpdate", self._rolling_update.to_string()));
|
|
for &field in ["alt", "project", "zone", "rollingUpdate"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/rollingUpdates/{rollingUpdate}/cancel".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_slice().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{rollingUpdate}", "rollingUpdate")].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", "rollingUpdate"].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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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::Post, url.as_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// The Google Developers Console project name.
|
|
pub fn project(mut self, new_value: &str) -> RollingUpdateCancelCall<'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.
|
|
///
|
|
/// The name of the zone in which the update's target resides.
|
|
pub fn zone(mut self, new_value: &str) -> RollingUpdateCancelCall<'a, C, NC, A> {
|
|
self._zone = new_value.to_string();
|
|
self
|
|
}
|
|
/// Sets the *rolling update* 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.
|
|
///
|
|
/// The name of the update.
|
|
pub fn rolling_update(mut self, new_value: &str) -> RollingUpdateCancelCall<'a, C, NC, A> {
|
|
self._rolling_update = 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) -> RollingUpdateCancelCall<'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) -> RollingUpdateCancelCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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) -> RollingUpdateCancelCall<'a, C, NC, A>
|
|
where T: Str {
|
|
self._scopes.insert(scope.as_slice().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`.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate "yup-oauth2" as oauth2;
|
|
/// # extern crate "google-replicapoolupdater1_beta1" as replicapoolupdater1_beta1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use replicapoolupdater1_beta1::Replicapoolupdater;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::new(),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = Replicapoolupdater::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 Replicapoolupdater<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: "replicapoolupdater.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 Result::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/replicapoolupdater/v1beta1/projects/{project}/zones/{zone}/operations/{operation}".to_string();
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::ReplicapoolReadonly.as_slice().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_slice()))));
|
|
}
|
|
|
|
|
|
|
|
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 Result::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_slice())
|
|
.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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return Result::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 Result::JsonDecodeError(err);
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Result::Success(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.
|
|
///
|
|
/// Name of the project scoping this request.
|
|
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.
|
|
///
|
|
/// Name of the zone scoping this request.
|
|
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.
|
|
///
|
|
/// Name of the operation resource to return.
|
|
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: Str {
|
|
self._additional_params.insert(name.as_slice().to_string(), value.as_slice().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: Str {
|
|
self._scopes.insert(scope.as_slice().to_string(), ());
|
|
self
|
|
}
|
|
}
|
|
|
|
|