mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-01 09:03:39 +01:00
4406 lines
187 KiB
Rust
4406 lines
187 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
//! This documentation was generated from *Service Usage* crate version *1.0.7+20181011*, where *20181011* is the exact revision of the *serviceusage:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.7*.
|
|
//!
|
|
//! Everything else about the *Service Usage* *v1* API can be found at the
|
|
//! [official documentation site](https://cloud.google.com/service-usage/).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/serviceusage1).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.ServiceUsage.html) ...
|
|
//!
|
|
//! * [operations](struct.Operation.html)
|
|
//! * [*cancel*](struct.OperationCancelCall.html), [*delete*](struct.OperationDeleteCall.html), [*get*](struct.OperationGetCall.html) and [*list*](struct.OperationListCall.html)
|
|
//! * services
|
|
//! * [*batch enable*](struct.ServiceBatchEnableCall.html), [*disable*](struct.ServiceDisableCall.html), [*enable*](struct.ServiceEnableCall.html), [*get*](struct.ServiceGetCall.html) and [*list*](struct.ServiceListCall.html)
|
|
//!
|
|
//!
|
|
//!
|
|
//!
|
|
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
|
|
//!
|
|
//! # Structure of this Library
|
|
//!
|
|
//! The API is structured into the following primary items:
|
|
//!
|
|
//! * **[Hub](struct.ServiceUsage.html)**
|
|
//! * a central object to maintain state and allow accessing all *Activities*
|
|
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
|
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
|
//! * **[Resources](trait.Resource.html)**
|
|
//! * primary types that you can apply *Activities* to
|
|
//! * a collection of properties and *Parts*
|
|
//! * **[Parts](trait.Part.html)**
|
|
//! * a collection of properties
|
|
//! * never directly used in *Activities*
|
|
//! * **[Activities](trait.CallBuilder.html)**
|
|
//! * operations to apply to *Resources*
|
|
//!
|
|
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
|
//!
|
|
//! Generally speaking, you can invoke *Activities* like this:
|
|
//!
|
|
//! ```Rust,ignore
|
|
//! let r = hub.resource().activity(...).doit()
|
|
//! ```
|
|
//!
|
|
//! Or specifically ...
|
|
//!
|
|
//! ```ignore
|
|
//! let r = hub.operations().get(...).doit()
|
|
//! let r = hub.operations().cancel(...).doit()
|
|
//! let r = hub.services().batch_enable(...).doit()
|
|
//! let r = hub.services().enable(...).doit()
|
|
//! let r = hub.operations().list(...).doit()
|
|
//! let r = hub.operations().delete(...).doit()
|
|
//! let r = hub.services().disable(...).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-serviceusage1 = "*"
|
|
//! # This project intentionally uses an old version of Hyper. See
|
|
//! # https://github.com/Byron/google-apis-rs/issues/173 for more
|
|
//! # information.
|
|
//! hyper = "^0.10"
|
|
//! hyper-rustls = "^0.6"
|
|
//! serde = "^1.0"
|
|
//! serde_json = "^1.0"
|
|
//! yup-oauth2 = "^1.0"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate hyper_rustls;
|
|
//! extern crate yup_oauth2 as oauth2;
|
|
//! extern crate google_serviceusage1 as serviceusage1;
|
|
//! use serviceusage1::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use serviceusage1::ServiceUsage;
|
|
//!
|
|
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
//! // `client_secret`, among other things.
|
|
//! let secret: ApplicationSecret = Default::default();
|
|
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
//! // unless you replace `None` with the desired Flow.
|
|
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
//! // retrieve them from storage.
|
|
//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
//! hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
//! <MemoryStorage as Default>::default(), None);
|
|
//! let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
//! // You can configure optional parameters by calling the respective setters at will, and
|
|
//! // execute the final call using `doit()`.
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let result = hub.operations().list()
|
|
//! .page_token("et")
|
|
//! .page_size(-18)
|
|
//! .name("kasd")
|
|
//! .filter("accusam")
|
|
//! .doit();
|
|
//!
|
|
//! match result {
|
|
//! Err(e) => match e {
|
|
//! // The Error enum provides details about what exactly happened.
|
|
//! // You can also just use its `Debug`, `Display` or `Error` traits
|
|
//! Error::HttpError(_)
|
|
//! |Error::MissingAPIKey
|
|
//! |Error::MissingToken(_)
|
|
//! |Error::Cancelled
|
|
//! |Error::UploadSizeLimitExceeded(_, _)
|
|
//! |Error::Failure(_)
|
|
//! |Error::BadRequest(_)
|
|
//! |Error::FieldClash(_)
|
|
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
//! },
|
|
//! Ok(res) => println!("Success: {:?}", res),
|
|
//! }
|
|
//! # }
|
|
//! ```
|
|
//! ## Handling Errors
|
|
//!
|
|
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
|
//! the doit() methods, or handed as possibly intermediate results to either the
|
|
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
|
|
//!
|
|
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
|
//! makes the system potentially resilient to all kinds of errors.
|
|
//!
|
|
//! ## Uploads and Downloads
|
|
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
|
//! read by you to obtain the media.
|
|
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
|
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
|
//! this call: `.param("alt", "media")`.
|
|
//!
|
|
//! Methods supporting uploads can do so using up to 2 different protocols:
|
|
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
|
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
|
//!
|
|
//! ## Customization and Callbacks
|
|
//!
|
|
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
|
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
|
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
|
//! retry on failure.
|
|
//!
|
|
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
|
//!
|
|
//! ## Optional Parts in Server-Requests
|
|
//!
|
|
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
|
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
|
//! are valid.
|
|
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
|
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
|
//!
|
|
//! ## Builder Arguments
|
|
//!
|
|
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
|
//! These will always take a single argument, for which the following statements are true.
|
|
//!
|
|
//! * [PODs][wiki-pod] are handed by copy
|
|
//! * strings are passed as `&str`
|
|
//! * [request values](trait.RequestValue.html) are moved
|
|
//!
|
|
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
|
//!
|
|
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
|
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
|
//! [google-go-api]: https://github.com/google/google-api-go-client
|
|
//!
|
|
//!
|
|
|
|
// Unused attributes happen thanks to defined, but unused structures
|
|
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
|
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
|
// unused imports in fully featured APIs. Same with unused_mut ... .
|
|
#![allow(unused_imports, unused_mut, dead_code)]
|
|
|
|
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
|
// DO NOT EDIT !
|
|
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
extern crate hyper;
|
|
extern crate serde;
|
|
extern crate serde_json;
|
|
extern crate yup_oauth2 as oauth2;
|
|
extern crate mime;
|
|
extern crate url;
|
|
|
|
mod cmn;
|
|
|
|
use std::collections::HashMap;
|
|
use std::cell::RefCell;
|
|
use std::borrow::BorrowMut;
|
|
use std::default::Default;
|
|
use std::collections::BTreeMap;
|
|
use serde_json as json;
|
|
use std::io;
|
|
use std::fs;
|
|
use std::mem;
|
|
use std::thread::sleep;
|
|
use std::time::Duration;
|
|
|
|
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part,
|
|
ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
|
|
Resource, ErrorResponse, remove_json_null_values};
|
|
|
|
|
|
// ##############
|
|
// 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,
|
|
|
|
/// Manage your Google API service configuration
|
|
ServiceManagement,
|
|
|
|
/// View your data across Google Cloud Platform services
|
|
CloudPlatformReadOnly,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
|
|
Scope::ServiceManagement => "https://www.googleapis.com/auth/service.management",
|
|
Scope::CloudPlatformReadOnly => "https://www.googleapis.com/auth/cloud-platform.read-only",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::CloudPlatform
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all ServiceUsage related resource activities
|
|
///
|
|
/// # Examples
|
|
///
|
|
/// Instantiate a new hub
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_serviceusage1 as serviceusage1;
|
|
/// use serviceusage1::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use serviceusage1::ServiceUsage;
|
|
///
|
|
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
|
/// // `client_secret`, among other things.
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
|
/// // unless you replace `None` with the desired Flow.
|
|
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
|
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
|
/// // retrieve them from storage.
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.operations().list()
|
|
/// .page_token("takimata")
|
|
/// .page_size(-70)
|
|
/// .name("amet.")
|
|
/// .filter("erat")
|
|
/// .doit();
|
|
///
|
|
/// match result {
|
|
/// Err(e) => match e {
|
|
/// // The Error enum provides details about what exactly happened.
|
|
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
|
/// Error::HttpError(_)
|
|
/// |Error::MissingAPIKey
|
|
/// |Error::MissingToken(_)
|
|
/// |Error::Cancelled
|
|
/// |Error::UploadSizeLimitExceeded(_, _)
|
|
/// |Error::Failure(_)
|
|
/// |Error::BadRequest(_)
|
|
/// |Error::FieldClash(_)
|
|
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
|
/// },
|
|
/// Ok(res) => println!("Success: {:?}", res),
|
|
/// }
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceUsage<C, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
_base_url: String,
|
|
_root_url: String,
|
|
}
|
|
|
|
impl<'a, C, A> Hub for ServiceUsage<C, A> {}
|
|
|
|
impl<'a, C, A> ServiceUsage<C, A>
|
|
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> ServiceUsage<C, A> {
|
|
ServiceUsage {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/1.0.7".to_string(),
|
|
_base_url: "https://serviceusage.googleapis.com/".to_string(),
|
|
_root_url: "https://serviceusage.googleapis.com/".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn operations(&'a self) -> OperationMethods<'a, C, A> {
|
|
OperationMethods { hub: &self }
|
|
}
|
|
pub fn services(&'a self) -> ServiceMethods<'a, C, A> {
|
|
ServiceMethods { hub: &self }
|
|
}
|
|
|
|
/// Set the user-agent header field to use in all requests to the server.
|
|
/// It defaults to `google-api-rust-client/1.0.7`.
|
|
///
|
|
/// Returns the previously set user-agent.
|
|
pub fn user_agent(&mut self, agent_name: String) -> String {
|
|
mem::replace(&mut self._user_agent, agent_name)
|
|
}
|
|
|
|
/// Set the base url to use in all requests to the server.
|
|
/// It defaults to `https://serviceusage.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set base url.
|
|
pub fn base_url(&mut self, new_base_url: String) -> String {
|
|
mem::replace(&mut self._base_url, new_base_url)
|
|
}
|
|
|
|
/// Set the root url to use in all requests to the server.
|
|
/// It defaults to `https://serviceusage.googleapis.com/`.
|
|
///
|
|
/// Returns the previously set root url.
|
|
pub fn root_url(&mut self, new_root_url: String) -> String {
|
|
mem::replace(&mut self._root_url, new_root_url)
|
|
}
|
|
}
|
|
|
|
|
|
// ############
|
|
// SCHEMAS ###
|
|
// ##########
|
|
/// Quota configuration helps to achieve fairness and budgeting in service
|
|
/// usage.
|
|
///
|
|
/// The quota configuration works this way:
|
|
/// - The service configuration defines a set of metrics.
|
|
/// - For API calls, the quota.metric_rules maps methods to metrics with
|
|
/// corresponding costs.
|
|
/// - The quota.limits defines limits on the metrics, which will be used for
|
|
/// quota checks at runtime.
|
|
///
|
|
/// An example quota configuration in yaml format:
|
|
///
|
|
/// quota:
|
|
/// limits:
|
|
///
|
|
/// - name: apiWriteQpsPerProject
|
|
/// metric: library.googleapis.com/write_calls
|
|
/// unit: "1/min/{project}" # rate limit for consumer projects
|
|
/// values:
|
|
/// STANDARD: 10000
|
|
///
|
|
///
|
|
/// # The metric rules bind all methods to the read_calls metric,
|
|
/// # except for the UpdateBook and DeleteBook methods. These two methods
|
|
/// # are mapped to the write_calls metric, with the UpdateBook method
|
|
/// # consuming at twice rate as the DeleteBook method.
|
|
/// metric_rules:
|
|
/// - selector: "*"
|
|
/// metric_costs:
|
|
/// library.googleapis.com/read_calls: 1
|
|
/// - selector: google.example.library.v1.LibraryService.UpdateBook
|
|
/// metric_costs:
|
|
/// library.googleapis.com/write_calls: 2
|
|
/// - selector: google.example.library.v1.LibraryService.DeleteBook
|
|
/// metric_costs:
|
|
/// library.googleapis.com/write_calls: 1
|
|
///
|
|
/// Corresponding Metric definition:
|
|
///
|
|
/// metrics:
|
|
/// - name: library.googleapis.com/read_calls
|
|
/// display_name: Read requests
|
|
/// metric_kind: DELTA
|
|
/// value_type: INT64
|
|
///
|
|
/// - name: library.googleapis.com/write_calls
|
|
/// display_name: Write requests
|
|
/// metric_kind: DELTA
|
|
/// value_type: INT64
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Quota {
|
|
/// List of `MetricRule` definitions, each one mapping a selected method to one
|
|
/// or more metrics.
|
|
#[serde(rename="metricRules")]
|
|
pub metric_rules: Option<Vec<MetricRule>>,
|
|
/// List of `QuotaLimit` definitions for the service.
|
|
pub limits: Option<Vec<QuotaLimit>>,
|
|
}
|
|
|
|
impl Part for Quota {}
|
|
|
|
|
|
/// `Authentication` defines the authentication configuration for an API.
|
|
///
|
|
/// Example for an API targeted for external use:
|
|
///
|
|
/// name: calendar.googleapis.com
|
|
/// authentication:
|
|
/// providers:
|
|
/// - id: google_calendar_auth
|
|
/// jwks_uri: https://www.googleapis.com/oauth2/v1/certs
|
|
/// issuer: https://securetoken.google.com
|
|
/// rules:
|
|
/// - selector: "*"
|
|
/// requirements:
|
|
/// provider_id: google_calendar_auth
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Authentication {
|
|
/// A list of authentication rules that apply to individual API methods.
|
|
///
|
|
/// **NOTE:** All service configuration rules follow "last one wins" order.
|
|
pub rules: Option<Vec<AuthenticationRule>>,
|
|
/// Defines a set of authentication providers that a service supports.
|
|
pub providers: Option<Vec<AuthProvider>>,
|
|
}
|
|
|
|
impl Part for Authentication {}
|
|
|
|
|
|
/// `QuotaLimit` defines a specific limit that applies over a specified duration
|
|
/// for a limit type. There can be at most one limit for a duration and limit
|
|
/// type combination defined within a `QuotaGroup`.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct QuotaLimit {
|
|
/// User-visible display name for this limit.
|
|
/// Optional. If not set, the UI will provide a default display name based on
|
|
/// the quota configuration. This field can be used to override the default
|
|
/// display name generated from the configuration.
|
|
#[serde(rename="displayName")]
|
|
pub display_name: Option<String>,
|
|
/// Optional. User-visible, extended description for this quota limit.
|
|
/// Should be used only when more context is needed to understand this limit
|
|
/// than provided by the limit's display name (see: `display_name`).
|
|
pub description: Option<String>,
|
|
/// Default number of tokens that can be consumed during the specified
|
|
/// duration. This is the number of tokens assigned when a client
|
|
/// application developer activates the service for his/her project.
|
|
///
|
|
/// Specifying a value of 0 will block all requests. This can be used if you
|
|
/// are provisioning quota to selected consumers and blocking others.
|
|
/// Similarly, a value of -1 will indicate an unlimited quota. No other
|
|
/// negative values are allowed.
|
|
///
|
|
/// Used by group-based quotas only.
|
|
#[serde(rename="defaultLimit")]
|
|
pub default_limit: Option<String>,
|
|
/// The name of the metric this quota limit applies to. The quota limits with
|
|
/// the same metric will be checked together during runtime. The metric must be
|
|
/// defined within the service config.
|
|
pub metric: Option<String>,
|
|
/// Tiered limit values. You must specify this as a key:value pair, with an
|
|
/// integer value that is the maximum number of requests allowed for the
|
|
/// specified unit. Currently only STANDARD is supported.
|
|
pub values: Option<HashMap<String, String>>,
|
|
/// Maximum number of tokens that can be consumed during the specified
|
|
/// duration. Client application developers can override the default limit up
|
|
/// to this maximum. If specified, this value cannot be set to a value less
|
|
/// than the default limit. If not specified, it is set to the default limit.
|
|
///
|
|
/// To allow clients to apply overrides with no upper bound, set this to -1,
|
|
/// indicating unlimited maximum quota.
|
|
///
|
|
/// Used by group-based quotas only.
|
|
#[serde(rename="maxLimit")]
|
|
pub max_limit: Option<String>,
|
|
/// Duration of this limit in textual notation. Example: "100s", "24h", "1d".
|
|
/// For duration longer than a day, only multiple of days is supported. We
|
|
/// support only "100s" and "1d" for now. Additional support will be added in
|
|
/// the future. "0" indicates indefinite duration.
|
|
///
|
|
/// Used by group-based quotas only.
|
|
pub duration: Option<String>,
|
|
/// Free tier value displayed in the Developers Console for this limit.
|
|
/// The free tier is the number of tokens that will be subtracted from the
|
|
/// billed amount when billing is enabled.
|
|
/// This field can only be set on a limit with duration "1d", in a billable
|
|
/// group; it is invalid on any other limit. If this field is not set, it
|
|
/// defaults to 0, indicating that there is no free tier for this service.
|
|
///
|
|
/// Used by group-based quotas only.
|
|
#[serde(rename="freeTier")]
|
|
pub free_tier: Option<String>,
|
|
/// Specify the unit of the quota limit. It uses the same syntax as
|
|
/// Metric.unit. The supported unit kinds are determined by the quota
|
|
/// backend system.
|
|
///
|
|
/// Here are some examples:
|
|
/// * "1/min/{project}" for quota per minute per project.
|
|
///
|
|
/// Note: the order of unit components is insignificant.
|
|
/// The "1" at the beginning is required to follow the metric unit syntax.
|
|
pub unit: Option<String>,
|
|
/// Name of the quota limit.
|
|
///
|
|
/// The name must be provided, and it must be unique within the service. The
|
|
/// name can only include alphanumeric characters as well as '-'.
|
|
///
|
|
/// The maximum length of the limit name is 64 characters.
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for QuotaLimit {}
|
|
|
|
|
|
/// Method represents a method of an API interface.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Method {
|
|
/// A URL of the input message type.
|
|
#[serde(rename="requestTypeUrl")]
|
|
pub request_type_url: Option<String>,
|
|
/// If true, the response is streamed.
|
|
#[serde(rename="responseStreaming")]
|
|
pub response_streaming: Option<bool>,
|
|
/// Any metadata attached to the method.
|
|
pub options: Option<Vec<Option>>,
|
|
/// The simple name of this method.
|
|
pub name: Option<String>,
|
|
/// The URL of the output message type.
|
|
#[serde(rename="responseTypeUrl")]
|
|
pub response_type_url: Option<String>,
|
|
/// If true, the request is streamed.
|
|
#[serde(rename="requestStreaming")]
|
|
pub request_streaming: Option<bool>,
|
|
/// The source syntax of this method.
|
|
pub syntax: Option<String>,
|
|
}
|
|
|
|
impl Part for Method {}
|
|
|
|
|
|
/// A generic empty message that you can re-use to avoid defining duplicated
|
|
/// empty messages in your APIs. A typical example is to use it as the request
|
|
/// or the response type of an API method. For instance:
|
|
///
|
|
/// service Foo {
|
|
/// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
/// }
|
|
///
|
|
/// The JSON representation for `Empty` is empty JSON object `{}`.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [delete operations](struct.OperationDeleteCall.html) (response)
|
|
/// * [cancel operations](struct.OperationCancelCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Empty { _never_set: Option<bool> }
|
|
|
|
impl ResponseResult for Empty {}
|
|
|
|
|
|
/// The `Status` type defines a logical error model that is suitable for different
|
|
/// programming environments, including REST APIs and RPC APIs. It is used by
|
|
/// [gRPC](https://github.com/grpc). The error model is designed to be:
|
|
///
|
|
/// - Simple to use and understand for most users
|
|
/// - Flexible enough to meet unexpected needs
|
|
///
|
|
/// # Overview
|
|
///
|
|
/// The `Status` message contains three pieces of data: error code, error message,
|
|
/// and error details. The error code should be an enum value of
|
|
/// google.rpc.Code, but it may accept additional error codes if needed. The
|
|
/// error message should be a developer-facing English message that helps
|
|
/// developers *understand* and *resolve* the error. If a localized user-facing
|
|
/// error message is needed, put the localized message in the error details or
|
|
/// localize it in the client. The optional error details may contain arbitrary
|
|
/// information about the error. There is a predefined set of error detail types
|
|
/// in the package `google.rpc` that can be used for common error conditions.
|
|
///
|
|
/// # Language mapping
|
|
///
|
|
/// The `Status` message is the logical representation of the error model, but it
|
|
/// is not necessarily the actual wire format. When the `Status` message is
|
|
/// exposed in different client libraries and different wire protocols, it can be
|
|
/// mapped differently. For example, it will likely be mapped to some exceptions
|
|
/// in Java, but more likely mapped to some error codes in C.
|
|
///
|
|
/// # Other uses
|
|
///
|
|
/// The error model and the `Status` message can be used in a variety of
|
|
/// environments, either with or without APIs, to provide a
|
|
/// consistent developer experience across different environments.
|
|
///
|
|
/// Example uses of this error model include:
|
|
///
|
|
/// - Partial errors. If a service needs to return partial errors to the client,
|
|
/// it may embed the `Status` in the normal response to indicate the partial
|
|
/// errors.
|
|
///
|
|
/// - Workflow errors. A typical workflow has multiple steps. Each step may
|
|
/// have a `Status` message for error reporting.
|
|
///
|
|
/// - Batch operations. If a client uses batch request and batch response, the
|
|
/// `Status` message should be used directly inside batch response, one for
|
|
/// each error sub-response.
|
|
///
|
|
/// - Asynchronous operations. If an API call embeds asynchronous operation
|
|
/// results in its response, the status of those operations should be
|
|
/// represented directly using the `Status` message.
|
|
///
|
|
/// - Logging. If some API errors are stored in logs, the message `Status` could
|
|
/// be used directly after any stripping needed for security/privacy reasons.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Status {
|
|
/// A developer-facing error message, which should be in English. Any
|
|
/// user-facing error message should be localized and sent in the
|
|
/// google.rpc.Status.details field, or localized by the client.
|
|
pub message: Option<String>,
|
|
/// The status code, which should be an enum value of google.rpc.Code.
|
|
pub code: Option<i32>,
|
|
/// A list of messages that carry the error details. There is a common set of
|
|
/// message types for APIs to use.
|
|
pub details: Option<Vec<HashMap<String, String>>>,
|
|
}
|
|
|
|
impl Part for Status {}
|
|
|
|
|
|
/// Configuration for an anthentication provider, including support for
|
|
/// [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AuthProvider {
|
|
/// URL of the provider's public key set to validate signature of the JWT. See
|
|
/// [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
|
|
/// Optional if the key set document:
|
|
/// - can be retrieved from
|
|
/// [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html
|
|
/// of the issuer.
|
|
/// - can be inferred from the email domain of the issuer (e.g. a Google service account).
|
|
///
|
|
/// Example: https://www.googleapis.com/oauth2/v1/certs
|
|
#[serde(rename="jwksUri")]
|
|
pub jwks_uri: Option<String>,
|
|
/// The list of JWT
|
|
/// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
|
|
/// that are allowed to access. A JWT containing any of these audiences will
|
|
/// be accepted. When this setting is absent, only JWTs with audience
|
|
/// "https://Service_name/API_name"
|
|
/// will be accepted. For example, if no audiences are in the setting,
|
|
/// LibraryService API will only accept JWTs with the following audience
|
|
/// "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
|
|
///
|
|
/// Example:
|
|
///
|
|
/// audiences: bookstore_android.apps.googleusercontent.com,
|
|
/// bookstore_web.apps.googleusercontent.com
|
|
pub audiences: Option<String>,
|
|
/// The unique identifier of the auth provider. It will be referred to by
|
|
/// `AuthRequirement.provider_id`.
|
|
///
|
|
/// Example: "bookstore_auth".
|
|
pub id: Option<String>,
|
|
/// Redirect URL if JWT token is required but no present or is expired.
|
|
/// Implement authorizationUrl of securityDefinitions in OpenAPI spec.
|
|
#[serde(rename="authorizationUrl")]
|
|
pub authorization_url: Option<String>,
|
|
/// Identifies the principal that issued the JWT. See
|
|
/// https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1
|
|
/// Usually a URL or an email address.
|
|
///
|
|
/// Example: https://securetoken.google.com
|
|
/// Example: 1234567-compute@developer.gserviceaccount.com
|
|
pub issuer: Option<String>,
|
|
}
|
|
|
|
impl Part for AuthProvider {}
|
|
|
|
|
|
/// Bind API methods to metrics. Binding a method to a metric causes that
|
|
/// metric's configured quota behaviors to apply to the method call.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct MetricRule {
|
|
/// Metrics to update when the selected methods are called, and the associated
|
|
/// cost applied to each metric.
|
|
///
|
|
/// The key of the map is the metric name, and the values are the amount
|
|
/// increased for the metric against which the quota limits are defined.
|
|
/// The value must not be negative.
|
|
#[serde(rename="metricCosts")]
|
|
pub metric_costs: Option<HashMap<String, String>>,
|
|
/// Selects the methods to which this rule applies.
|
|
///
|
|
/// Refer to selector for syntax details.
|
|
pub selector: Option<String>,
|
|
}
|
|
|
|
impl Part for MetricRule {}
|
|
|
|
|
|
/// Response message for the `ListServices` 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 services](struct.ServiceListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListServicesResponse {
|
|
/// The available services for the requested project.
|
|
pub services: Option<Vec<GoogleApiServiceusageV1Service>>,
|
|
/// Token that can be passed to `ListServices` to resume a paginated
|
|
/// query.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for ListServicesResponse {}
|
|
|
|
|
|
/// Request message for the `BatchEnableServices` 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*).
|
|
///
|
|
/// * [batch enable services](struct.ServiceBatchEnableCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct BatchEnableServicesRequest {
|
|
/// The identifiers of the services to enable on the project.
|
|
///
|
|
/// A valid identifier would be:
|
|
/// serviceusage.googleapis.com
|
|
///
|
|
/// Enabling services requires that each service is public or is shared with
|
|
/// the user enabling the service.
|
|
///
|
|
/// Two or more services must be specified. To enable a single service,
|
|
/// use the `EnableService` method instead.
|
|
///
|
|
/// A single request can enable a maximum of 20 services at a time. If more
|
|
/// than 20 services are specified, the request will fail, and no state changes
|
|
/// will occur.
|
|
#[serde(rename="serviceIds")]
|
|
pub service_ids: Option<Vec<String>>,
|
|
}
|
|
|
|
impl RequestValue for BatchEnableServicesRequest {}
|
|
|
|
|
|
/// Request message for the `EnableService` 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*).
|
|
///
|
|
/// * [enable services](struct.ServiceEnableCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EnableServiceRequest { _never_set: Option<bool> }
|
|
|
|
impl RequestValue for EnableServiceRequest {}
|
|
|
|
|
|
/// A documentation rule provides information about individual API elements.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct DocumentationRule {
|
|
/// Description of the selected API(s).
|
|
pub description: Option<String>,
|
|
/// Deprecation description of the selected element(s). It can be provided if an
|
|
/// element is marked as `deprecated`.
|
|
#[serde(rename="deprecationDescription")]
|
|
pub deprecation_description: Option<String>,
|
|
/// The selector is a comma-separated list of patterns. Each pattern is a
|
|
/// qualified name of the element which may end in "*", indicating a wildcard.
|
|
/// Wildcards are only allowed at the end and for a whole component of the
|
|
/// qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To
|
|
/// specify a default for all applicable elements, the whole pattern "*"
|
|
/// is used.
|
|
pub selector: Option<String>,
|
|
}
|
|
|
|
impl Part for DocumentationRule {}
|
|
|
|
|
|
/// Usage configuration rules for the service.
|
|
///
|
|
/// NOTE: Under development.
|
|
///
|
|
///
|
|
/// Use this rule to configure unregistered calls for the service. Unregistered
|
|
/// calls are calls that do not contain consumer project identity.
|
|
/// (Example: calls that do not contain an API key).
|
|
/// By default, API methods do not allow unregistered calls, and each method call
|
|
/// must be identified by a consumer project identity. Use this rule to
|
|
/// allow/disallow unregistered calls.
|
|
///
|
|
/// Example of an API that wants to allow unregistered calls for entire service.
|
|
///
|
|
/// usage:
|
|
/// rules:
|
|
/// - selector: "*"
|
|
/// allow_unregistered_calls: true
|
|
///
|
|
/// Example of a method that wants to allow unregistered calls.
|
|
///
|
|
/// usage:
|
|
/// rules:
|
|
/// - selector: "google.example.library.v1.LibraryService.CreateBook"
|
|
/// allow_unregistered_calls: true
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct UsageRule {
|
|
/// If true, the selected method should skip service control and the control
|
|
/// plane features, such as quota and billing, will not be available.
|
|
/// This flag is used by Google Cloud Endpoints to bypass checks for internal
|
|
/// methods, such as service health check methods.
|
|
#[serde(rename="skipServiceControl")]
|
|
pub skip_service_control: Option<bool>,
|
|
/// If true, the selected method allows unregistered calls, e.g. calls
|
|
/// that don't identify any user or application.
|
|
#[serde(rename="allowUnregisteredCalls")]
|
|
pub allow_unregistered_calls: Option<bool>,
|
|
/// Selects the methods to which this rule applies. Use '*' to indicate all
|
|
/// methods in all APIs.
|
|
///
|
|
/// Refer to selector for syntax details.
|
|
pub selector: Option<String>,
|
|
}
|
|
|
|
impl Part for UsageRule {}
|
|
|
|
|
|
/// This resource represents a long-running operation that is the result of a
|
|
/// network API call.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [get operations](struct.OperationGetCall.html) (response)
|
|
/// * [cancel operations](struct.OperationCancelCall.html) (none)
|
|
/// * [batch enable services](struct.ServiceBatchEnableCall.html) (response)
|
|
/// * [enable services](struct.ServiceEnableCall.html) (response)
|
|
/// * [list operations](struct.OperationListCall.html) (none)
|
|
/// * [delete operations](struct.OperationDeleteCall.html) (none)
|
|
/// * [disable services](struct.ServiceDisableCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Operation {
|
|
/// The error result of the operation in case of failure or cancellation.
|
|
pub error: Option<Status>,
|
|
/// If the value is `false`, it means the operation is still in progress.
|
|
/// If `true`, the operation is completed, and either `error` or `response` is
|
|
/// available.
|
|
pub done: Option<bool>,
|
|
/// The normal response of the operation in case of success. If the original
|
|
/// method returns no data on success, such as `Delete`, the response is
|
|
/// `google.protobuf.Empty`. If the original method is standard
|
|
/// `Get`/`Create`/`Update`, the response should be the resource. For other
|
|
/// methods, the response should have the type `XxxResponse`, where `Xxx`
|
|
/// is the original method name. For example, if the original method name
|
|
/// is `TakeSnapshot()`, the inferred response type is
|
|
/// `TakeSnapshotResponse`.
|
|
pub response: Option<HashMap<String, String>>,
|
|
/// The server-assigned name, which is only unique within the same service that
|
|
/// originally returns it. If you use the default HTTP mapping, the
|
|
/// `name` should have the format of `operations/some/unique/name`.
|
|
pub name: Option<String>,
|
|
/// Service-specific metadata associated with the operation. It typically
|
|
/// contains progress information and common metadata such as create time.
|
|
/// Some services might not provide such metadata. Any method that returns a
|
|
/// long-running operation should document the metadata type, if any.
|
|
pub metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl Resource for Operation {}
|
|
impl ResponseResult for Operation {}
|
|
|
|
|
|
/// A service that is available for use by the consumer.
|
|
///
|
|
/// # Activities
|
|
///
|
|
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
|
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
|
///
|
|
/// * [get services](struct.ServiceGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleApiServiceusageV1Service {
|
|
/// Whether or not the service has been enabled for use by the consumer.
|
|
pub state: Option<String>,
|
|
/// The service configuration of the available service.
|
|
/// Some fields may be filtered out of the configuration in responses to
|
|
/// the `ListServices` method. These fields are present only in responses to
|
|
/// the `GetService` method.
|
|
pub config: Option<GoogleApiServiceusageV1ServiceConfig>,
|
|
/// The resource name of the consumer and service.
|
|
///
|
|
/// A valid name would be:
|
|
/// - projects/123/services/serviceusage.googleapis.com
|
|
pub name: Option<String>,
|
|
/// The resource name of the consumer.
|
|
///
|
|
/// A valid name would be:
|
|
/// - projects/123
|
|
pub parent: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for GoogleApiServiceusageV1Service {}
|
|
|
|
|
|
/// OAuth scopes are a way to define data and permissions on data. For example,
|
|
/// there are scopes defined for "Read-only access to Google Calendar" and
|
|
/// "Access to Cloud Platform". Users can consent to a scope for an application,
|
|
/// giving it permission to access that data on their behalf.
|
|
///
|
|
/// OAuth scope specifications should be fairly coarse grained; a user will need
|
|
/// to see and understand the text description of what your scope means.
|
|
///
|
|
/// In most cases: use one or at most two OAuth scopes for an entire family of
|
|
/// products. If your product has multiple APIs, you should probably be sharing
|
|
/// the OAuth scope across all of those APIs.
|
|
///
|
|
/// When you need finer grained OAuth consent screens: talk with your product
|
|
/// management about how developers will use them in practice.
|
|
///
|
|
/// Please note that even though each of the canonical scopes is enough for a
|
|
/// request to be accepted and passed to the backend, a request can still fail
|
|
/// due to the backend requiring additional scopes or permissions.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct OAuthRequirements {
|
|
/// The list of publicly documented OAuth scopes that are allowed access. An
|
|
/// OAuth token containing any of these scopes will be accepted.
|
|
///
|
|
/// Example:
|
|
///
|
|
/// canonical_scopes: https://www.googleapis.com/auth/calendar,
|
|
/// https://www.googleapis.com/auth/calendar.read
|
|
#[serde(rename="canonicalScopes")]
|
|
pub canonical_scopes: Option<String>,
|
|
}
|
|
|
|
impl Part for OAuthRequirements {}
|
|
|
|
|
|
/// Request message for the `DisableService` 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*).
|
|
///
|
|
/// * [disable services](struct.ServiceDisableCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct DisableServiceRequest {
|
|
/// Indicates if services that are enabled and which depend on this service
|
|
/// should also be disabled. If not set, an error will be generated if any
|
|
/// enabled services depend on the service to be disabled. When set, the
|
|
/// service, and any enabled services that depend on it, will be disabled
|
|
/// together.
|
|
#[serde(rename="disableDependentServices")]
|
|
pub disable_dependent_services: Option<bool>,
|
|
}
|
|
|
|
impl RequestValue for DisableServiceRequest {}
|
|
|
|
|
|
/// A protocol buffer option, which can be attached to a message, field,
|
|
/// enumeration, etc.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Option {
|
|
/// The option's name. For protobuf built-in options (options defined in
|
|
/// descriptor.proto), this is the short name. For example, `"map_entry"`.
|
|
/// For custom options, it should be the fully-qualified name. For example,
|
|
/// `"google.api.http"`.
|
|
pub name: Option<String>,
|
|
/// The option's value packed in an Any message. If the value is a primitive,
|
|
/// the corresponding wrapper type defined in google/protobuf/wrappers.proto
|
|
/// should be used. If the value is an enum, it should be stored as an int32
|
|
/// value using the google.protobuf.Int32Value type.
|
|
pub value: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl Part for Option {}
|
|
|
|
|
|
/// Configuration controlling usage of a service.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Usage {
|
|
/// A list of usage rules that apply to individual API methods.
|
|
///
|
|
/// **NOTE:** All service configuration rules follow "last one wins" order.
|
|
pub rules: Option<Vec<UsageRule>>,
|
|
/// The full resource name of a channel used for sending notifications to the
|
|
/// service producer.
|
|
///
|
|
/// Google Service Management currently only supports
|
|
/// [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification
|
|
/// channel. To use Google Cloud Pub/Sub as the channel, this must be the name
|
|
/// of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format
|
|
/// documented in https://cloud.google.com/pubsub/docs/overview.
|
|
#[serde(rename="producerNotificationChannel")]
|
|
pub producer_notification_channel: Option<String>,
|
|
/// Requirements that must be satisfied before a consumer project can use the
|
|
/// service. Each requirement is of the form <service.name>/<requirement-id>;
|
|
/// for example 'serviceusage.googleapis.com/billing-enabled'.
|
|
pub requirements: Option<Vec<String>>,
|
|
}
|
|
|
|
impl Part for Usage {}
|
|
|
|
|
|
/// `SourceContext` represents information about the source of a
|
|
/// protobuf element, like the file in which it is defined.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct SourceContext {
|
|
/// The path-qualified name of the .proto file that contained the associated
|
|
/// protobuf element. For example: `"google/protobuf/source_context.proto"`.
|
|
#[serde(rename="fileName")]
|
|
pub file_name: Option<String>,
|
|
}
|
|
|
|
impl Part for SourceContext {}
|
|
|
|
|
|
/// The configuration of the service.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct GoogleApiServiceusageV1ServiceConfig {
|
|
/// The DNS address at which this service is available.
|
|
///
|
|
/// An example DNS address would be:
|
|
/// `calendar.googleapis.com`.
|
|
pub name: Option<String>,
|
|
/// A list of API interfaces exported by this service. Contains only the names,
|
|
/// versions, and method names of the interfaces.
|
|
pub apis: Option<Vec<Api>>,
|
|
/// Additional API documentation. Contains only the summary and the
|
|
/// documentation URL.
|
|
pub documentation: Option<Documentation>,
|
|
/// Quota configuration.
|
|
pub quota: Option<Quota>,
|
|
/// Auth configuration. Contains only the OAuth rules.
|
|
pub authentication: Option<Authentication>,
|
|
/// Configuration controlling usage of this service.
|
|
pub usage: Option<Usage>,
|
|
/// The product title for this service.
|
|
pub title: Option<String>,
|
|
/// Configuration for network endpoints. Contains only the names and aliases
|
|
/// of the endpoints.
|
|
pub endpoints: Option<Vec<Endpoint>>,
|
|
}
|
|
|
|
impl Part for GoogleApiServiceusageV1ServiceConfig {}
|
|
|
|
|
|
/// Declares an API Interface to be included in this interface. The including
|
|
/// interface must redeclare all the methods from the included interface, but
|
|
/// documentation and options are inherited as follows:
|
|
///
|
|
/// - If after comment and whitespace stripping, the documentation
|
|
/// string of the redeclared method is empty, it will be inherited
|
|
/// from the original method.
|
|
///
|
|
/// - Each annotation belonging to the service config (http,
|
|
/// visibility) which is not set in the redeclared method will be
|
|
/// inherited.
|
|
///
|
|
/// - If an http annotation is inherited, the path pattern will be
|
|
/// modified as follows. Any version prefix will be replaced by the
|
|
/// version of the including interface plus the root path if
|
|
/// specified.
|
|
///
|
|
/// Example of a simple mixin:
|
|
///
|
|
/// package google.acl.v1;
|
|
/// service AccessControl {
|
|
/// // Get the underlying ACL object.
|
|
/// rpc GetAcl(GetAclRequest) returns (Acl) {
|
|
/// option (google.api.http).get = "/v1/{resource=**}:getAcl";
|
|
/// }
|
|
/// }
|
|
///
|
|
/// package google.storage.v2;
|
|
/// service Storage {
|
|
/// // rpc GetAcl(GetAclRequest) returns (Acl);
|
|
///
|
|
/// // Get a data record.
|
|
/// rpc GetData(GetDataRequest) returns (Data) {
|
|
/// option (google.api.http).get = "/v2/{resource=**}";
|
|
/// }
|
|
/// }
|
|
///
|
|
/// Example of a mixin configuration:
|
|
///
|
|
/// apis:
|
|
/// - name: google.storage.v2.Storage
|
|
/// mixins:
|
|
/// - name: google.acl.v1.AccessControl
|
|
///
|
|
/// The mixin construct implies that all methods in `AccessControl` are
|
|
/// also declared with same name and request/response types in
|
|
/// `Storage`. A documentation generator or annotation processor will
|
|
/// see the effective `Storage.GetAcl` method after inherting
|
|
/// documentation and annotations as follows:
|
|
///
|
|
/// service Storage {
|
|
/// // Get the underlying ACL object.
|
|
/// rpc GetAcl(GetAclRequest) returns (Acl) {
|
|
/// option (google.api.http).get = "/v2/{resource=**}:getAcl";
|
|
/// }
|
|
/// ...
|
|
/// }
|
|
///
|
|
/// Note how the version in the path pattern changed from `v1` to `v2`.
|
|
///
|
|
/// If the `root` field in the mixin is specified, it should be a
|
|
/// relative path under which inherited HTTP paths are placed. Example:
|
|
///
|
|
/// apis:
|
|
/// - name: google.storage.v2.Storage
|
|
/// mixins:
|
|
/// - name: google.acl.v1.AccessControl
|
|
/// root: acls
|
|
///
|
|
/// This implies the following inherited HTTP annotation:
|
|
///
|
|
/// service Storage {
|
|
/// // Get the underlying ACL object.
|
|
/// rpc GetAcl(GetAclRequest) returns (Acl) {
|
|
/// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
|
|
/// }
|
|
/// ...
|
|
/// }
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Mixin {
|
|
/// If non-empty specifies a path under which inherited HTTP paths
|
|
/// are rooted.
|
|
pub root: Option<String>,
|
|
/// The fully qualified name of the interface which is included.
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for Mixin {}
|
|
|
|
|
|
/// `Endpoint` describes a network endpoint that serves a set of APIs.
|
|
/// A service may expose any number of endpoints, and all endpoints share the
|
|
/// same service configuration, such as quota configuration and monitoring
|
|
/// configuration.
|
|
///
|
|
/// Example service configuration:
|
|
///
|
|
/// name: library-example.googleapis.com
|
|
/// endpoints:
|
|
/// # Below entry makes 'google.example.library.v1.Library'
|
|
/// # API be served from endpoint address library-example.googleapis.com.
|
|
/// # It also allows HTTP OPTIONS calls to be passed to the backend, for
|
|
/// # it to decide whether the subsequent cross-origin request is
|
|
/// # allowed to proceed.
|
|
/// - name: library-example.googleapis.com
|
|
/// allow_cors: true
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Endpoint {
|
|
/// Allowing
|
|
/// [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka
|
|
/// cross-domain traffic, would allow the backends served from this endpoint to
|
|
/// receive and respond to HTTP OPTIONS requests. The response will be used by
|
|
/// the browser to determine whether the subsequent cross-origin request is
|
|
/// allowed to proceed.
|
|
#[serde(rename="allowCors")]
|
|
pub allow_cors: Option<bool>,
|
|
/// DEPRECATED: This field is no longer supported. Instead of using aliases,
|
|
/// please specify multiple google.api.Endpoint for each of the intended
|
|
/// aliases.
|
|
///
|
|
/// Additional names that this endpoint will be hosted on.
|
|
pub aliases: Option<Vec<String>>,
|
|
/// The list of features enabled on this endpoint.
|
|
pub features: Option<Vec<String>>,
|
|
/// The canonical name of this endpoint.
|
|
pub name: Option<String>,
|
|
/// The specification of an Internet routable address of API frontend that will
|
|
/// handle requests to this [API Endpoint](https://cloud.google.com/apis/design/glossary).
|
|
/// It should be either a valid IPv4 address or a fully-qualified domain name.
|
|
/// For example, "8.8.8.8" or "myservice.appspot.com".
|
|
pub target: Option<String>,
|
|
}
|
|
|
|
impl Part for Endpoint {}
|
|
|
|
|
|
/// `Documentation` provides the information for describing a service.
|
|
///
|
|
/// Example:
|
|
/// <pre><code>documentation:
|
|
/// summary: >
|
|
/// The Google Calendar API gives access
|
|
/// to most calendar features.
|
|
/// pages:
|
|
/// - name: Overview
|
|
/// content: (== include google/foo/overview.md ==)
|
|
/// - name: Tutorial
|
|
/// content: (== include google/foo/tutorial.md ==)
|
|
/// subpages;
|
|
/// - name: Java
|
|
/// content: (== include google/foo/tutorial_java.md ==)
|
|
/// rules:
|
|
/// - selector: google.calendar.Calendar.Get
|
|
/// description: >
|
|
/// ...
|
|
/// - selector: google.calendar.Calendar.Put
|
|
/// description: >
|
|
/// ...
|
|
/// </code></pre>
|
|
/// Documentation is provided in markdown syntax. In addition to
|
|
/// standard markdown features, definition lists, tables and fenced
|
|
/// code blocks are supported. Section headers can be provided and are
|
|
/// interpreted relative to the section nesting of the context where
|
|
/// a documentation fragment is embedded.
|
|
///
|
|
/// Documentation from the IDL is merged with documentation defined
|
|
/// via the config at normalization time, where documentation provided
|
|
/// by config rules overrides IDL provided.
|
|
///
|
|
/// A number of constructs specific to the API platform are supported
|
|
/// in documentation text.
|
|
///
|
|
/// In order to reference a proto element, the following
|
|
/// notation can be used:
|
|
/// <pre><code>[fully.qualified.proto.name][]</code></pre>
|
|
/// To override the display text used for the link, this can be used:
|
|
/// <pre><code>[display text][fully.qualified.proto.name]</code></pre>
|
|
/// Text can be excluded from doc using the following notation:
|
|
/// <pre><code>(-- internal comment --)</code></pre>
|
|
///
|
|
/// A few directives are available in documentation. Note that
|
|
/// directives must appear on a single line to be properly
|
|
/// identified. The `include` directive includes a markdown file from
|
|
/// an external source:
|
|
/// <pre><code>(== include path/to/file ==)</code></pre>
|
|
/// The `resource_for` directive marks a message to be the resource of
|
|
/// a collection in REST view. If it is not specified, tools attempt
|
|
/// to infer the resource from the operations in a collection:
|
|
/// <pre><code>(== resource_for v1.shelves.books ==)</code></pre>
|
|
/// The directive `suppress_warning` does not directly affect documentation
|
|
/// and is documented together with service config validation.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Documentation {
|
|
/// A list of documentation rules that apply to individual API elements.
|
|
///
|
|
/// **NOTE:** All service configuration rules follow "last one wins" order.
|
|
pub rules: Option<Vec<DocumentationRule>>,
|
|
/// The URL to the root of documentation.
|
|
#[serde(rename="documentationRootUrl")]
|
|
pub documentation_root_url: Option<String>,
|
|
/// A short summary of what the service does. Can only be provided by
|
|
/// plain text.
|
|
pub summary: Option<String>,
|
|
/// The top level pages for the documentation set.
|
|
pub pages: Option<Vec<Page>>,
|
|
/// Declares a single overview page. For example:
|
|
/// <pre><code>documentation:
|
|
/// summary: ...
|
|
/// overview: (== include overview.md ==)
|
|
/// </code></pre>
|
|
/// This is a shortcut for the following declaration (using pages style):
|
|
/// <pre><code>documentation:
|
|
/// summary: ...
|
|
/// pages:
|
|
/// - name: Overview
|
|
/// content: (== include overview.md ==)
|
|
/// </code></pre>
|
|
/// Note: you cannot specify both `overview` field and `pages` field.
|
|
pub overview: Option<String>,
|
|
}
|
|
|
|
impl Part for Documentation {}
|
|
|
|
|
|
/// User-defined authentication requirements, including support for
|
|
/// [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AuthRequirement {
|
|
/// id from authentication provider.
|
|
///
|
|
/// Example:
|
|
///
|
|
/// provider_id: bookstore_auth
|
|
#[serde(rename="providerId")]
|
|
pub provider_id: Option<String>,
|
|
/// NOTE: This will be deprecated soon, once AuthProvider.audiences is
|
|
/// implemented and accepted in all the runtime components.
|
|
///
|
|
/// The list of JWT
|
|
/// [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
|
|
/// that are allowed to access. A JWT containing any of these audiences will
|
|
/// be accepted. When this setting is absent, only JWTs with audience
|
|
/// "https://Service_name/API_name"
|
|
/// will be accepted. For example, if no audiences are in the setting,
|
|
/// LibraryService API will only accept JWTs with the following audience
|
|
/// "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
|
|
///
|
|
/// Example:
|
|
///
|
|
/// audiences: bookstore_android.apps.googleusercontent.com,
|
|
/// bookstore_web.apps.googleusercontent.com
|
|
pub audiences: Option<String>,
|
|
}
|
|
|
|
impl Part for AuthRequirement {}
|
|
|
|
|
|
/// Represents a documentation page. A page can contain subpages to represent
|
|
/// nested documentation set structure.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Page {
|
|
/// The Markdown content of the page. You can use <code>(== include {path} ==)</code>
|
|
/// to include content from a Markdown file.
|
|
pub content: Option<String>,
|
|
/// Subpages of this page. The order of subpages specified here will be
|
|
/// honored in the generated docset.
|
|
pub subpages: Option<Vec<Page>>,
|
|
/// The name of the page. It will be used as an identity of the page to
|
|
/// generate URI of the page, text of the link to this page in navigation,
|
|
/// etc. The full page name (start from the root page name to this page
|
|
/// concatenated with `.`) can be used as reference to the page in your
|
|
/// documentation. For example:
|
|
/// <pre><code>pages:
|
|
/// - name: Tutorial
|
|
/// content: (== include tutorial.md ==)
|
|
/// subpages:
|
|
/// - name: Java
|
|
/// content: (== include tutorial_java.md ==)
|
|
/// </code></pre>
|
|
/// You can reference `Java` page using Markdown reference link syntax:
|
|
/// `Java`.
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl Part for Page {}
|
|
|
|
|
|
/// The response message for Operations.ListOperations.
|
|
///
|
|
/// # 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 operations](struct.OperationListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListOperationsResponse {
|
|
/// The standard List next-page token.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// A list of operations that matches the specified filter in the request.
|
|
pub operations: Option<Vec<Operation>>,
|
|
}
|
|
|
|
impl ResponseResult for ListOperationsResponse {}
|
|
|
|
|
|
/// Api is a light-weight descriptor for an API Interface.
|
|
///
|
|
/// Interfaces are also described as "protocol buffer services" in some contexts,
|
|
/// such as by the "service" keyword in a .proto file, but they are different
|
|
/// from API Services, which represent a concrete implementation of an interface
|
|
/// as opposed to simply a description of methods and bindings. They are also
|
|
/// sometimes simply referred to as "APIs" in other contexts, such as the name of
|
|
/// this message itself. See https://cloud.google.com/apis/design/glossary for
|
|
/// detailed terminology.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Api {
|
|
/// A version string for this interface. If specified, must have the form
|
|
/// `major-version.minor-version`, as in `1.10`. If the minor version is
|
|
/// omitted, it defaults to zero. If the entire version field is empty, the
|
|
/// major version is derived from the package name, as outlined below. If the
|
|
/// field is not empty, the version in the package name will be verified to be
|
|
/// consistent with what is provided here.
|
|
///
|
|
/// The versioning schema uses [semantic
|
|
/// versioning](http://semver.org) where the major version number
|
|
/// indicates a breaking change and the minor version an additive,
|
|
/// non-breaking change. Both version numbers are signals to users
|
|
/// what to expect from different versions, and should be carefully
|
|
/// chosen based on the product plan.
|
|
///
|
|
/// The major version is also reflected in the package name of the
|
|
/// interface, which must end in `v<major-version>`, as in
|
|
/// `google.feature.v1`. For major versions 0 and 1, the suffix can
|
|
/// be omitted. Zero major versions must only be used for
|
|
/// experimental, non-GA interfaces.
|
|
///
|
|
pub version: Option<String>,
|
|
/// The methods of this interface, in unspecified order.
|
|
pub methods: Option<Vec<Method>>,
|
|
/// The fully qualified name of this interface, including package name
|
|
/// followed by the interface's simple name.
|
|
pub name: Option<String>,
|
|
/// Source context for the protocol buffer service represented by this
|
|
/// message.
|
|
#[serde(rename="sourceContext")]
|
|
pub source_context: Option<SourceContext>,
|
|
/// Included interfaces. See Mixin.
|
|
pub mixins: Option<Vec<Mixin>>,
|
|
/// Any metadata attached to the interface.
|
|
pub options: Option<Vec<Option>>,
|
|
/// The source syntax of the service.
|
|
pub syntax: Option<String>,
|
|
}
|
|
|
|
impl Part for Api {}
|
|
|
|
|
|
/// The request message for Operations.CancelOperation.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [cancel operations](struct.OperationCancelCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CancelOperationRequest { _never_set: Option<bool> }
|
|
|
|
impl RequestValue for CancelOperationRequest {}
|
|
|
|
|
|
/// Authentication rules for the service.
|
|
///
|
|
/// By default, if a method has any authentication requirements, every request
|
|
/// must include a valid credential matching one of the requirements.
|
|
/// It's an error to include more than one kind of credential in a single
|
|
/// request.
|
|
///
|
|
/// If a method doesn't have any auth requirements, request credentials will be
|
|
/// ignored.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AuthenticationRule {
|
|
/// The requirements for OAuth credentials.
|
|
pub oauth: Option<OAuthRequirements>,
|
|
/// Requirements for additional authentication providers.
|
|
pub requirements: Option<Vec<AuthRequirement>>,
|
|
/// If true, the service accepts API keys without any other credential.
|
|
#[serde(rename="allowWithoutCredential")]
|
|
pub allow_without_credential: Option<bool>,
|
|
/// Selects the methods to which this rule applies.
|
|
///
|
|
/// Refer to selector for syntax details.
|
|
pub selector: Option<String>,
|
|
}
|
|
|
|
impl Part for AuthenticationRule {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *operation* resources.
|
|
/// It is not used directly, but through the `ServiceUsage` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_serviceusage1 as serviceusage1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use serviceusage1::ServiceUsage;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `cancel(...)`, `delete(...)`, `get(...)` and `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.operations();
|
|
/// # }
|
|
/// ```
|
|
pub struct OperationMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for OperationMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> OperationMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the latest state of a long-running operation. Clients can use this
|
|
/// method to poll the operation result at intervals as recommended by the API
|
|
/// service.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The name of the operation resource.
|
|
pub fn get(&self, name: &str) -> OperationGetCall<'a, C, A> {
|
|
OperationGetCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Starts asynchronous cancellation on a long-running operation. The server
|
|
/// makes a best effort to cancel the operation, but success is not
|
|
/// guaranteed. If the server doesn't support this method, it returns
|
|
/// `google.rpc.Code.UNIMPLEMENTED`. Clients can use
|
|
/// Operations.GetOperation or
|
|
/// other methods to check whether the cancellation succeeded or whether the
|
|
/// operation completed despite cancellation. On successful cancellation,
|
|
/// the operation is not deleted; instead, it becomes an operation with
|
|
/// an Operation.error value with a google.rpc.Status.code of 1,
|
|
/// corresponding to `Code.CANCELLED`.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - The name of the operation resource to be cancelled.
|
|
pub fn cancel(&self, request: CancelOperationRequest, name: &str) -> OperationCancelCall<'a, C, A> {
|
|
OperationCancelCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists operations that match the specified filter in the request. If the
|
|
/// server doesn't support this method, it returns `UNIMPLEMENTED`.
|
|
///
|
|
/// NOTE: the `name` binding allows API services to override the binding
|
|
/// to use different resource name schemes, such as `users/*/operations`. To
|
|
/// override the binding, API services can add a binding such as
|
|
/// `"/v1/{name=users/*}/operations"` to their service configuration.
|
|
/// For backwards compatibility, the default name includes the operations
|
|
/// collection id, however overriding users must ensure the name binding
|
|
/// is the parent resource, without the operations collection id.
|
|
pub fn list(&self) -> OperationListCall<'a, C, A> {
|
|
OperationListCall {
|
|
hub: self.hub,
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_name: Default::default(),
|
|
_filter: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Deletes a long-running operation. This method indicates that the client is
|
|
/// no longer interested in the operation result. It does not cancel the
|
|
/// operation. If the server doesn't support this method, it returns
|
|
/// `google.rpc.Code.UNIMPLEMENTED`.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The name of the operation resource to be deleted.
|
|
pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C, A> {
|
|
OperationDeleteCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// A builder providing access to all methods supported on *service* resources.
|
|
/// It is not used directly, but through the `ServiceUsage` hub.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// extern crate hyper;
|
|
/// extern crate hyper_rustls;
|
|
/// extern crate yup_oauth2 as oauth2;
|
|
/// extern crate google_serviceusage1 as serviceusage1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use serviceusage1::ServiceUsage;
|
|
///
|
|
/// let secret: ApplicationSecret = Default::default();
|
|
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// <MemoryStorage as Default>::default(), None);
|
|
/// let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
|
/// // like `batch_enable(...)`, `disable(...)`, `enable(...)`, `get(...)` and `list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.services();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for ServiceMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Enable multiple services on a project. The operation is atomic: if enabling
|
|
/// any service fails, then the entire batch fails, and no state changes occur.
|
|
///
|
|
/// Operation<response: BatchEnableServicesResponse>
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Parent to enable services on.
|
|
/// An example name would be:
|
|
/// `projects/123`
|
|
/// where `123` is the project number (not project ID).
|
|
/// The `BatchEnableServices` method currently only supports projects.
|
|
pub fn batch_enable(&self, request: BatchEnableServicesRequest, parent: &str) -> ServiceBatchEnableCall<'a, C, A> {
|
|
ServiceBatchEnableCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_parent: parent.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Enable a service so that it can be used with a project.
|
|
///
|
|
/// Operation<response: EnableServiceResponse>
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the consumer and service to enable the service on.
|
|
/// The `EnableService` and `DisableService` methods currently only support
|
|
/// projects.
|
|
/// Enabling a service requires that the service is public or is shared with
|
|
/// the user enabling the service.
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
pub fn enable(&self, request: EnableServiceRequest, name: &str) -> ServiceEnableCall<'a, C, A> {
|
|
ServiceEnableCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Returns the service configuration and enabled state for a given service.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Name of the consumer and service to get the `ConsumerState` for.
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
pub fn get(&self, name: &str) -> ServiceGetCall<'a, C, A> {
|
|
ServiceGetCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Disable a service so that it can no longer be used with a project.
|
|
/// This prevents unintended usage that may cause unexpected billing
|
|
/// charges or security leaks.
|
|
///
|
|
/// It is not valid to call the disable method on a service that is not
|
|
/// currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
|
|
/// the target service is not currently enabled.
|
|
///
|
|
/// Operation<response: DisableServiceResponse>
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Name of the consumer and service to disable the service on.
|
|
/// The enable and disable methods currently only support projects.
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
pub fn disable(&self, request: DisableServiceRequest, name: &str) -> ServiceDisableCall<'a, C, A> {
|
|
ServiceDisableCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// List all services available to the specified project, and the current
|
|
/// state of those services with respect to the project. The list includes
|
|
/// all public services, all services for which the calling user has the
|
|
/// `servicemanagement.services.bind` permission, and all services that have
|
|
/// already been enabled on the project. The list can be filtered to
|
|
/// only include services in a specific state, for example to only include
|
|
/// services enabled on the project.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Parent to search for services on.
|
|
/// An example name would be:
|
|
/// `projects/123`
|
|
/// where `123` is the project number (not project ID).
|
|
pub fn list(&self, parent: &str) -> ServiceListCall<'a, C, A> {
|
|
ServiceListCall {
|
|
hub: self.hub,
|
|
_parent: parent.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_filter: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Gets the latest state of a long-running operation. Clients can use this
|
|
/// method to poll the operation result at intervals as recommended by the API
|
|
/// service.
|
|
///
|
|
/// A builder for the *get* method supported by a *operation* resource.
|
|
/// It is not used directly, but through a `OperationMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.operations().get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct OperationGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for OperationGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> OperationGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.operations.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// The name of the operation resource.
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperationGetCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> OperationGetCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Starts asynchronous cancellation on a long-running operation. The server
|
|
/// makes a best effort to cancel the operation, but success is not
|
|
/// guaranteed. If the server doesn't support this method, it returns
|
|
/// `google.rpc.Code.UNIMPLEMENTED`. Clients can use
|
|
/// Operations.GetOperation or
|
|
/// other methods to check whether the cancellation succeeded or whether the
|
|
/// operation completed despite cancellation. On successful cancellation,
|
|
/// the operation is not deleted; instead, it becomes an operation with
|
|
/// an Operation.error value with a google.rpc.Status.code of 1,
|
|
/// corresponding to `Code.CANCELLED`.
|
|
///
|
|
/// A builder for the *cancel* method supported by a *operation* resource.
|
|
/// It is not used directly, but through a `OperationMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// use serviceusage1::CancelOperationRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = CancelOperationRequest::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.operations().cancel(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct OperationCancelCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_request: CancelOperationRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for OperationCancelCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> OperationCancelCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.operations.cancel",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// The name of the operation resource to be cancelled.
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperationCancelCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> OperationCancelCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Lists operations that match the specified filter in the request. If the
|
|
/// server doesn't support this method, it returns `UNIMPLEMENTED`.
|
|
///
|
|
/// NOTE: the `name` binding allows API services to override the binding
|
|
/// to use different resource name schemes, such as `users/*/operations`. To
|
|
/// override the binding, API services can add a binding such as
|
|
/// `"/v1/{name=users/*}/operations"` to their service configuration.
|
|
/// For backwards compatibility, the default name includes the operations
|
|
/// collection id, however overriding users must ensure the name binding
|
|
/// is the parent resource, without the operations collection id.
|
|
///
|
|
/// A builder for the *list* method supported by a *operation* resource.
|
|
/// It is not used directly, but through a `OperationMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.operations().list()
|
|
/// .page_token("nonumy")
|
|
/// .page_size(-19)
|
|
/// .name("gubergren")
|
|
/// .filter("sadipscing")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct OperationListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_name: Option<String>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for OperationListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> OperationListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ListOperationsResponse)> {
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.operations.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_size {
|
|
params.push(("pageSize", value.to_string()));
|
|
}
|
|
if let Some(value) = self._name {
|
|
params.push(("name", value.to_string()));
|
|
}
|
|
if let Some(value) = self._filter {
|
|
params.push(("filter", value.to_string()));
|
|
}
|
|
for &field in ["alt", "pageToken", "pageSize", "name", "filter"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/operations";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// The standard list page token.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The standard list page size.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// The name of the operation's parent resource.
|
|
///
|
|
/// Sets the *name* query property to the given value.
|
|
pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C, A> {
|
|
self._name = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The standard list filter.
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C, A> {
|
|
self._filter = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperationListCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> OperationListCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Deletes a long-running operation. This method indicates that the client is
|
|
/// no longer interested in the operation result. It does not cancel the
|
|
/// operation. If the server doesn't support this method, it returns
|
|
/// `google.rpc.Code.UNIMPLEMENTED`.
|
|
///
|
|
/// A builder for the *delete* method supported by a *operation* resource.
|
|
/// It is not used directly, but through a `OperationMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.operations().delete("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct OperationDeleteCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for OperationDeleteCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> OperationDeleteCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Empty)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.operations.delete",
|
|
http_method: hyper::method::Method::Delete });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.access_token });
|
|
let mut req_result = {
|
|
let mut client = &mut *self.hub.client.borrow_mut();
|
|
let mut req = client.borrow_mut().request(hyper::method::Method::Delete, &url)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// The name of the operation resource to be deleted.
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> OperationDeleteCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> OperationDeleteCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Enable multiple services on a project. The operation is atomic: if enabling
|
|
/// any service fails, then the entire batch fails, and no state changes occur.
|
|
///
|
|
/// Operation<response: BatchEnableServicesResponse>
|
|
///
|
|
/// A builder for the *batchEnable* method supported by a *service* resource.
|
|
/// It is not used directly, but through a `ServiceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// use serviceusage1::BatchEnableServicesRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = BatchEnableServicesRequest::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.services().batch_enable(req, "parent")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceBatchEnableCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_request: BatchEnableServicesRequest,
|
|
_parent: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ServiceBatchEnableCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceBatchEnableCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.services.batchEnable",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
|
params.push(("parent", self._parent.to_string()));
|
|
for &field in ["alt", "parent"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/services:batchEnable";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["parent"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: BatchEnableServicesRequest) -> ServiceBatchEnableCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Parent to enable services on.
|
|
///
|
|
/// An example name would be:
|
|
/// `projects/123`
|
|
/// where `123` is the project number (not project ID).
|
|
///
|
|
/// The `BatchEnableServices` method currently only supports projects.
|
|
///
|
|
/// Sets the *parent* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn parent(mut self, new_value: &str) -> ServiceBatchEnableCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ServiceBatchEnableCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ServiceBatchEnableCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> ServiceBatchEnableCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Enable a service so that it can be used with a project.
|
|
///
|
|
/// Operation<response: EnableServiceResponse>
|
|
///
|
|
/// A builder for the *enable* method supported by a *service* resource.
|
|
/// It is not used directly, but through a `ServiceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// use serviceusage1::EnableServiceRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = EnableServiceRequest::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.services().enable(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceEnableCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_request: EnableServiceRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ServiceEnableCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceEnableCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.services.enable",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: EnableServiceRequest) -> ServiceEnableCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the consumer and service to enable the service on.
|
|
///
|
|
/// The `EnableService` and `DisableService` methods currently only support
|
|
/// projects.
|
|
///
|
|
/// Enabling a service requires that the service is public or is shared with
|
|
/// the user enabling the service.
|
|
///
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> ServiceEnableCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ServiceEnableCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ServiceEnableCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> ServiceEnableCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Returns the service configuration and enabled state for a given service.
|
|
///
|
|
/// A builder for the *get* method supported by a *service* resource.
|
|
/// It is not used directly, but through a `ServiceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.services().get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ServiceGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceGetCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, GoogleApiServiceusageV1Service)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.services.get",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Name of the consumer and service to get the `ConsumerState` for.
|
|
///
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> ServiceGetCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ServiceGetCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ServiceGetCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> ServiceGetCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// Disable a service so that it can no longer be used with a project.
|
|
/// This prevents unintended usage that may cause unexpected billing
|
|
/// charges or security leaks.
|
|
///
|
|
/// It is not valid to call the disable method on a service that is not
|
|
/// currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
|
|
/// the target service is not currently enabled.
|
|
///
|
|
/// Operation<response: DisableServiceResponse>
|
|
///
|
|
/// A builder for the *disable* method supported by a *service* resource.
|
|
/// It is not used directly, but through a `ServiceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// use serviceusage1::DisableServiceRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // As the method needs a request, you would usually fill it with the desired information
|
|
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let mut req = DisableServiceRequest::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.services().disable(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceDisableCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_request: DisableServiceRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ServiceDisableCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceDisableCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, Operation)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.services.disable",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
|
|
params.push(("name", self._name.to_string()));
|
|
for &field in ["alt", "name"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["name"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
|
let mut request_value_reader =
|
|
{
|
|
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
|
json::to_writer(&mut dst, &value).unwrap();
|
|
dst
|
|
};
|
|
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
|
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
/// Sets the *request* property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn request(mut self, new_value: DisableServiceRequest) -> ServiceDisableCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Name of the consumer and service to disable the service on.
|
|
///
|
|
/// The enable and disable methods currently only support projects.
|
|
///
|
|
/// An example name would be:
|
|
/// `projects/123/services/serviceusage.googleapis.com`
|
|
/// where `123` is the project number (not project ID).
|
|
///
|
|
/// Sets the *name* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn name(mut self, new_value: &str) -> ServiceDisableCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ServiceDisableCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ServiceDisableCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> ServiceDisableCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
/// List all services available to the specified project, and the current
|
|
/// state of those services with respect to the project. The list includes
|
|
/// all public services, all services for which the calling user has the
|
|
/// `servicemanagement.services.bind` permission, and all services that have
|
|
/// already been enabled on the project. The list can be filtered to
|
|
/// only include services in a specific state, for example to only include
|
|
/// services enabled on the project.
|
|
///
|
|
/// A builder for the *list* method supported by a *service* resource.
|
|
/// It is not used directly, but through a `ServiceMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_serviceusage1 as serviceusage1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use serviceusage1::ServiceUsage;
|
|
///
|
|
/// # let secret: ApplicationSecret = Default::default();
|
|
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
|
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
|
/// # <MemoryStorage as Default>::default(), None);
|
|
/// # let mut hub = ServiceUsage::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.services().list("parent")
|
|
/// .page_token("et")
|
|
/// .page_size(-41)
|
|
/// .filter("ipsum")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ServiceListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a ServiceUsage<C, A>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_filter: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ServiceListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ServiceListCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
|
|
/// Perform the operation you have build so far.
|
|
pub fn doit(mut self) -> Result<(hyper::client::Response, ListServicesResponse)> {
|
|
use url::percent_encoding::{percent_encode, DEFAULT_ENCODE_SET};
|
|
use std::io::{Read, Seek};
|
|
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
|
let mut dd = DefaultDelegate;
|
|
let mut dlg: &mut Delegate = match self._delegate {
|
|
Some(d) => d,
|
|
None => &mut dd
|
|
};
|
|
dlg.begin(MethodInfo { id: "serviceusage.services.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
|
|
params.push(("parent", self._parent.to_string()));
|
|
if let Some(value) = self._page_token {
|
|
params.push(("pageToken", value.to_string()));
|
|
}
|
|
if let Some(value) = self._page_size {
|
|
params.push(("pageSize", value.to_string()));
|
|
}
|
|
if let Some(value) = self._filter {
|
|
params.push(("filter", value.to_string()));
|
|
}
|
|
for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/services";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
|
let mut replace_with = String::new();
|
|
for &(name, ref value) in params.iter() {
|
|
if name == param_name {
|
|
replace_with = value.to_string();
|
|
break;
|
|
}
|
|
}
|
|
if find_this.as_bytes()[1] == '+' as u8 {
|
|
replace_with = percent_encode(replace_with.as_bytes(), DEFAULT_ENCODE_SET);
|
|
}
|
|
url = url.replace(find_this, &replace_with);
|
|
}
|
|
{
|
|
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
|
for param_name in ["parent"].iter() {
|
|
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
|
indices_for_removal.push(index);
|
|
}
|
|
}
|
|
for &index in indices_for_removal.iter() {
|
|
params.remove(index);
|
|
}
|
|
}
|
|
|
|
if params.len() > 0 {
|
|
url.push('?');
|
|
url.push_str(&url::form_urlencoded::serialize(params));
|
|
}
|
|
|
|
|
|
|
|
loop {
|
|
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
|
Ok(token) => token,
|
|
Err(err) => {
|
|
match dlg.token(&*err) {
|
|
Some(token) => token,
|
|
None => {
|
|
dlg.finished(false);
|
|
return Err(Error::MissingToken(err))
|
|
}
|
|
}
|
|
}
|
|
};
|
|
let auth_header = Authorization(Bearer { token: token.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)
|
|
.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 Err(Error::HttpError(err))
|
|
}
|
|
Ok(mut res) => {
|
|
if !res.status.is_success() {
|
|
let mut json_err = String::new();
|
|
res.read_to_string(&mut json_err).unwrap();
|
|
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
|
json::from_str(&json_err).ok(),
|
|
json::from_str(&json_err).ok()) {
|
|
sleep(d);
|
|
continue;
|
|
}
|
|
dlg.finished(false);
|
|
return match json::from_str::<ErrorResponse>(&json_err){
|
|
Err(_) => Err(Error::Failure(res)),
|
|
Ok(serr) => Err(Error::BadRequest(serr))
|
|
}
|
|
}
|
|
let result_value = {
|
|
let mut json_response = String::new();
|
|
res.read_to_string(&mut json_response).unwrap();
|
|
match json::from_str(&json_response) {
|
|
Ok(decoded) => (res, decoded),
|
|
Err(err) => {
|
|
dlg.response_json_decode_error(&json_response, &err);
|
|
return Err(Error::JsonDecodeError(json_response, err));
|
|
}
|
|
}
|
|
};
|
|
|
|
dlg.finished(true);
|
|
return Ok(result_value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Parent to search for services on.
|
|
///
|
|
/// An example name would be:
|
|
/// `projects/123`
|
|
/// where `123` is the project number (not project ID).
|
|
///
|
|
/// Sets the *parent* path property to the given value.
|
|
///
|
|
/// Even though the property as already been set when instantiating this call,
|
|
/// we provide this method for API completeness.
|
|
pub fn parent(mut self, new_value: &str) -> ServiceListCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Token identifying which result to start with, which is returned by a
|
|
/// previous list call.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ServiceListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Requested size of the next page of data.
|
|
/// Requested page size cannot exceed 200.
|
|
/// If not set, the default page size is 50.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ServiceListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// Only list services that conform to the given filter.
|
|
/// The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> ServiceListCall<'a, C, A> {
|
|
self._filter = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ServiceListCall<'a, C, A> {
|
|
self._delegate = Some(new_value);
|
|
self
|
|
}
|
|
|
|
/// Set any additional parameter of the query string used in the request.
|
|
/// It should be used to set parameters which are not yet available through their own
|
|
/// setters.
|
|
///
|
|
/// Please note that this method must not be used to set any of the known paramters
|
|
/// which have their own setter method. If done anyway, the request will fail.
|
|
///
|
|
/// # Additional Parameters
|
|
///
|
|
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *access_token* (query-string) - OAuth access token.
|
|
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
|
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
|
/// * *callback* (query-string) - JSONP
|
|
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
|
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
|
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
|
/// * *alt* (query-string) - Data format for response.
|
|
/// * *$.xgafv* (query-string) - V1 error format.
|
|
pub fn param<T>(mut self, name: T, value: T) -> ServiceListCall<'a, C, A>
|
|
where T: AsRef<str> {
|
|
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
|
self
|
|
}
|
|
|
|
/// Identifies the authorization scope for the method you are building.
|
|
///
|
|
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
|
/// `Scope::CloudPlatform`.
|
|
///
|
|
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
|
/// tokens for more than one scope.
|
|
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
|
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
|
/// function for details).
|
|
///
|
|
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
|
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
|
/// sufficient, a read-write scope will do as well.
|
|
pub fn add_scope<T, S>(mut self, scope: T) -> ServiceListCall<'a, C, A>
|
|
where T: Into<Option<S>>,
|
|
S: AsRef<str> {
|
|
match scope.into() {
|
|
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
|
None => None,
|
|
};
|
|
self
|
|
}
|
|
}
|
|
|
|
|