mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-01 00:51:17 +01:00
8407 lines
376 KiB
Rust
8407 lines
376 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 *Cloud KMS* crate version *1.0.7+20171201*, where *20171201* is the exact revision of the *cloudkms:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.7*.
|
|
//!
|
|
//! Everything else about the *Cloud KMS* *v1* API can be found at the
|
|
//! [official documentation site](https://cloud.google.com/kms/).
|
|
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/cloudkms1).
|
|
//! # Features
|
|
//!
|
|
//! Handle the following *Resources* with ease from the central [hub](struct.CloudKMS.html) ...
|
|
//!
|
|
//! * projects
|
|
//! * [*locations get*](struct.ProjectLocationGetCall.html), [*locations key rings create*](struct.ProjectLocationKeyRingCreateCall.html), [*locations key rings crypto keys create*](struct.ProjectLocationKeyRingCryptoKeyCreateCall.html), [*locations key rings crypto keys crypto key versions create*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall.html), [*locations key rings crypto keys crypto key versions destroy*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall.html), [*locations key rings crypto keys crypto key versions get*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall.html), [*locations key rings crypto keys crypto key versions list*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall.html), [*locations key rings crypto keys crypto key versions patch*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall.html), [*locations key rings crypto keys crypto key versions restore*](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall.html), [*locations key rings crypto keys decrypt*](struct.ProjectLocationKeyRingCryptoKeyDecryptCall.html), [*locations key rings crypto keys encrypt*](struct.ProjectLocationKeyRingCryptoKeyEncryptCall.html), [*locations key rings crypto keys get*](struct.ProjectLocationKeyRingCryptoKeyGetCall.html), [*locations key rings crypto keys get iam policy*](struct.ProjectLocationKeyRingCryptoKeyGetIamPolicyCall.html), [*locations key rings crypto keys list*](struct.ProjectLocationKeyRingCryptoKeyListCall.html), [*locations key rings crypto keys patch*](struct.ProjectLocationKeyRingCryptoKeyPatchCall.html), [*locations key rings crypto keys set iam policy*](struct.ProjectLocationKeyRingCryptoKeySetIamPolicyCall.html), [*locations key rings crypto keys test iam permissions*](struct.ProjectLocationKeyRingCryptoKeyTestIamPermissionCall.html), [*locations key rings crypto keys update primary version*](struct.ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall.html), [*locations key rings get*](struct.ProjectLocationKeyRingGetCall.html), [*locations key rings get iam policy*](struct.ProjectLocationKeyRingGetIamPolicyCall.html), [*locations key rings list*](struct.ProjectLocationKeyRingListCall.html), [*locations key rings set iam policy*](struct.ProjectLocationKeyRingSetIamPolicyCall.html), [*locations key rings test iam permissions*](struct.ProjectLocationKeyRingTestIamPermissionCall.html) and [*locations list*](struct.ProjectLocationListCall.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.CloudKMS.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.projects().locations_key_rings_crypto_keys_crypto_key_versions_destroy(...).doit()
|
|
//! let r = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_get(...).doit()
|
|
//! let r = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(...).doit()
|
|
//! let r = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_restore(...).doit()
|
|
//! let r = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_create(...).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-cloudkms1 = "*"
|
|
//! ```
|
|
//!
|
|
//! ## A complete example
|
|
//!
|
|
//! ```test_harness,no_run
|
|
//! extern crate hyper;
|
|
//! extern crate hyper_rustls;
|
|
//! extern crate yup_oauth2 as oauth2;
|
|
//! extern crate google_cloudkms1 as cloudkms1;
|
|
//! use cloudkms1::CryptoKeyVersion;
|
|
//! use cloudkms1::{Result, Error};
|
|
//! # #[test] fn egal() {
|
|
//! use std::default::Default;
|
|
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
//! use cloudkms1::CloudKMS;
|
|
//!
|
|
//! // 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 = CloudKMS::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 = CryptoKeyVersion::default();
|
|
//!
|
|
//! // You can configure optional parameters by calling the respective setters at will, and
|
|
//! // execute the final call using `doit()`.
|
|
//! // Values shown here are possibly random and not representative !
|
|
//! let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
|
|
//! .update_mask("sed")
|
|
//! .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,
|
|
}
|
|
|
|
impl AsRef<str> for Scope {
|
|
fn as_ref(&self) -> &str {
|
|
match *self {
|
|
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Default for Scope {
|
|
fn default() -> Scope {
|
|
Scope::CloudPlatform
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ########
|
|
// HUB ###
|
|
// ######
|
|
|
|
/// Central instance to access all CloudKMS 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_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::CryptoKeyVersion;
|
|
/// use cloudkms1::{Result, Error};
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use cloudkms1::CloudKMS;
|
|
///
|
|
/// // 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 = CloudKMS::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 = CryptoKeyVersion::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
|
|
/// .update_mask("dolores")
|
|
/// .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 CloudKMS<C, A> {
|
|
client: RefCell<C>,
|
|
auth: RefCell<A>,
|
|
_user_agent: String,
|
|
_base_url: String,
|
|
_root_url: String,
|
|
}
|
|
|
|
impl<'a, C, A> Hub for CloudKMS<C, A> {}
|
|
|
|
impl<'a, C, A> CloudKMS<C, A>
|
|
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
|
|
|
pub fn new(client: C, authenticator: A) -> CloudKMS<C, A> {
|
|
CloudKMS {
|
|
client: RefCell::new(client),
|
|
auth: RefCell::new(authenticator),
|
|
_user_agent: "google-api-rust-client/1.0.7".to_string(),
|
|
_base_url: "https://cloudkms.googleapis.com/".to_string(),
|
|
_root_url: "https://cloudkms.googleapis.com/".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn projects(&'a self) -> ProjectMethods<'a, C, A> {
|
|
ProjectMethods { 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://cloudkms.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://cloudkms.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 ###
|
|
// ##########
|
|
/// Response message for KeyManagementService.ListCryptoKeys.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys list projects](struct.ProjectLocationKeyRingCryptoKeyListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListCryptoKeysResponse {
|
|
/// A token to retrieve next page of results. Pass this value in
|
|
/// ListCryptoKeysRequest.page_token to retrieve the next page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// The list of CryptoKeys.
|
|
#[serde(rename="cryptoKeys")]
|
|
pub crypto_keys: Option<Vec<CryptoKey>>,
|
|
/// The total number of CryptoKeys that matched the query.
|
|
#[serde(rename="totalSize")]
|
|
pub total_size: Option<i32>,
|
|
}
|
|
|
|
impl ResponseResult for ListCryptoKeysResponse {}
|
|
|
|
|
|
/// Provides the configuration for logging a type of permissions.
|
|
/// Example:
|
|
///
|
|
/// {
|
|
/// "audit_log_configs": [
|
|
/// {
|
|
/// "log_type": "DATA_READ",
|
|
/// "exempted_members": [
|
|
/// "user:foo@gmail.com"
|
|
/// ]
|
|
/// },
|
|
/// {
|
|
/// "log_type": "DATA_WRITE",
|
|
/// }
|
|
/// ]
|
|
/// }
|
|
///
|
|
/// This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting
|
|
/// foo@gmail.com from DATA_READ logging.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AuditLogConfig {
|
|
/// Specifies the identities that do not cause logging for this type of
|
|
/// permission.
|
|
/// Follows the same format of Binding.members.
|
|
#[serde(rename="exemptedMembers")]
|
|
pub exempted_members: Option<Vec<String>>,
|
|
/// The log type that this config enables.
|
|
#[serde(rename="logType")]
|
|
pub log_type: Option<String>,
|
|
}
|
|
|
|
impl Part for AuditLogConfig {}
|
|
|
|
|
|
/// Request message for KeyManagementService.Encrypt.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys encrypt projects](struct.ProjectLocationKeyRingCryptoKeyEncryptCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EncryptRequest {
|
|
/// Required. The data to encrypt. Must be no larger than 64KiB.
|
|
pub plaintext: Option<String>,
|
|
/// Optional data that, if specified, must also be provided during decryption
|
|
/// through DecryptRequest.additional_authenticated_data. Must be no
|
|
/// larger than 64KiB.
|
|
#[serde(rename="additionalAuthenticatedData")]
|
|
pub additional_authenticated_data: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for EncryptRequest {}
|
|
|
|
|
|
/// Request message for `TestIamPermissions` 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*).
|
|
///
|
|
/// * [locations key rings test iam permissions projects](struct.ProjectLocationKeyRingTestIamPermissionCall.html) (request)
|
|
/// * [locations key rings crypto keys test iam permissions projects](struct.ProjectLocationKeyRingCryptoKeyTestIamPermissionCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TestIamPermissionsRequest {
|
|
/// The set of permissions to check for the `resource`. Permissions with
|
|
/// wildcards (such as '*' or 'storage.*') are not allowed. For more
|
|
/// information see
|
|
/// [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
|
pub permissions: Option<Vec<String>>,
|
|
}
|
|
|
|
impl RequestValue for TestIamPermissionsRequest {}
|
|
|
|
|
|
/// Request message for `SetIamPolicy` 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*).
|
|
///
|
|
/// * [locations key rings crypto keys set iam policy projects](struct.ProjectLocationKeyRingCryptoKeySetIamPolicyCall.html) (request)
|
|
/// * [locations key rings set iam policy projects](struct.ProjectLocationKeyRingSetIamPolicyCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct SetIamPolicyRequest {
|
|
/// REQUIRED: The complete policy to be applied to the `resource`. The size of
|
|
/// the policy is limited to a few 10s of KB. An empty policy is a
|
|
/// valid policy but certain Cloud Platform services (such as Projects)
|
|
/// might reject them.
|
|
pub policy: Option<Policy>,
|
|
/// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
|
|
/// the fields in the mask will be modified. If no mask is provided, the
|
|
/// following default mask is used:
|
|
/// paths: "bindings, etag"
|
|
/// This field is only used by Cloud IAM.
|
|
#[serde(rename="updateMask")]
|
|
pub update_mask: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for SetIamPolicyRequest {}
|
|
|
|
|
|
/// A KeyRing is a toplevel logical grouping of CryptoKeys.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings create projects](struct.ProjectLocationKeyRingCreateCall.html) (request|response)
|
|
/// * [locations key rings get projects](struct.ProjectLocationKeyRingGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct KeyRing {
|
|
/// Output only. The resource name for the KeyRing in the format
|
|
/// `projects/*/locations/*/keyRings/*`.
|
|
pub name: Option<String>,
|
|
/// Output only. The time at which this KeyRing was created.
|
|
#[serde(rename="createTime")]
|
|
pub create_time: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for KeyRing {}
|
|
impl ResponseResult for KeyRing {}
|
|
|
|
|
|
/// A CryptoKeyVersion represents an individual cryptographic key, and the
|
|
/// associated key material.
|
|
///
|
|
/// It can be used for cryptographic operations either directly, or via its
|
|
/// parent CryptoKey, in which case the server will choose the appropriate
|
|
/// version for the operation.
|
|
///
|
|
/// For security reasons, the raw cryptographic key material represented by a
|
|
/// CryptoKeyVersion can never be viewed or exported. It can only be used to
|
|
/// encrypt or decrypt data when an authorized user or application invokes Cloud
|
|
/// KMS.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys crypto key versions destroy projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall.html) (response)
|
|
/// * [locations key rings crypto keys crypto key versions get projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall.html) (response)
|
|
/// * [locations key rings crypto keys crypto key versions patch projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall.html) (request|response)
|
|
/// * [locations key rings crypto keys crypto key versions restore projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall.html) (response)
|
|
/// * [locations key rings crypto keys crypto key versions create projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CryptoKeyVersion {
|
|
/// The current state of the CryptoKeyVersion.
|
|
pub state: Option<String>,
|
|
/// Output only. The time at which this CryptoKeyVersion was created.
|
|
#[serde(rename="createTime")]
|
|
pub create_time: Option<String>,
|
|
/// Output only. The resource name for this CryptoKeyVersion in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
|
|
pub name: Option<String>,
|
|
/// Output only. The time this CryptoKeyVersion's key material is scheduled
|
|
/// for destruction. Only present if state is
|
|
/// DESTROY_SCHEDULED.
|
|
#[serde(rename="destroyTime")]
|
|
pub destroy_time: Option<String>,
|
|
/// Output only. The time this CryptoKeyVersion's key material was
|
|
/// destroyed. Only present if state is
|
|
/// DESTROYED.
|
|
#[serde(rename="destroyEventTime")]
|
|
pub destroy_event_time: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for CryptoKeyVersion {}
|
|
impl ResponseResult for CryptoKeyVersion {}
|
|
|
|
|
|
/// Response message for KeyManagementService.ListKeyRings.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings list projects](struct.ProjectLocationKeyRingListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListKeyRingsResponse {
|
|
/// A token to retrieve next page of results. Pass this value in
|
|
/// ListKeyRingsRequest.page_token to retrieve the next page of results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// The total number of KeyRings that matched the query.
|
|
#[serde(rename="totalSize")]
|
|
pub total_size: Option<i32>,
|
|
/// The list of KeyRings.
|
|
#[serde(rename="keyRings")]
|
|
pub key_rings: Option<Vec<KeyRing>>,
|
|
}
|
|
|
|
impl ResponseResult for ListKeyRingsResponse {}
|
|
|
|
|
|
/// The response message for Locations.ListLocations.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations list projects](struct.ProjectLocationListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListLocationsResponse {
|
|
/// The standard List next-page token.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// A list of locations that matches the specified filter in the request.
|
|
pub locations: Option<Vec<Location>>,
|
|
}
|
|
|
|
impl ResponseResult for ListLocationsResponse {}
|
|
|
|
|
|
/// A resource that represents Google Cloud Platform location.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations get projects](struct.ProjectLocationGetCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Location {
|
|
/// Cross-service attributes for the location. For example
|
|
///
|
|
/// {"cloud.googleapis.com/region": "us-east1"}
|
|
pub labels: Option<HashMap<String, String>>,
|
|
/// The canonical id for this location. For example: `"us-east1"`.
|
|
#[serde(rename="locationId")]
|
|
pub location_id: Option<String>,
|
|
/// Resource name for the location, which may vary between implementations.
|
|
/// For example: `"projects/example-project/locations/us-east1"`
|
|
pub name: Option<String>,
|
|
/// Service-specific metadata. For example the available capacity at the given
|
|
/// location.
|
|
pub metadata: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
impl ResponseResult for Location {}
|
|
|
|
|
|
/// Defines an Identity and Access Management (IAM) policy. It is used to
|
|
/// specify access control policies for Cloud Platform resources.
|
|
///
|
|
///
|
|
/// A `Policy` consists of a list of `bindings`. A `Binding` binds a list of
|
|
/// `members` to a `role`, where the members can be user accounts, Google groups,
|
|
/// Google domains, and service accounts. A `role` is a named list of permissions
|
|
/// defined by IAM.
|
|
///
|
|
/// **Example**
|
|
///
|
|
/// {
|
|
/// "bindings": [
|
|
/// {
|
|
/// "role": "roles/owner",
|
|
/// "members": [
|
|
/// "user:mike@example.com",
|
|
/// "group:admins@example.com",
|
|
/// "domain:google.com",
|
|
/// "serviceAccount:my-other-app@appspot.gserviceaccount.com",
|
|
/// ]
|
|
/// },
|
|
/// {
|
|
/// "role": "roles/viewer",
|
|
/// "members": ["user:sean@example.com"]
|
|
/// }
|
|
/// ]
|
|
/// }
|
|
///
|
|
/// For a description of IAM and its features, see the
|
|
/// [IAM developer's guide](https://cloud.google.com/iam).
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys get iam policy projects](struct.ProjectLocationKeyRingCryptoKeyGetIamPolicyCall.html) (response)
|
|
/// * [locations key rings get iam policy projects](struct.ProjectLocationKeyRingGetIamPolicyCall.html) (response)
|
|
/// * [locations key rings crypto keys set iam policy projects](struct.ProjectLocationKeyRingCryptoKeySetIamPolicyCall.html) (response)
|
|
/// * [locations key rings set iam policy projects](struct.ProjectLocationKeyRingSetIamPolicyCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Policy {
|
|
/// Associates a list of `members` to a `role`.
|
|
/// `bindings` with no members will result in an error.
|
|
pub bindings: Option<Vec<Binding>>,
|
|
/// `etag` is used for optimistic concurrency control as a way to help
|
|
/// prevent simultaneous updates of a policy from overwriting each other.
|
|
/// It is strongly suggested that systems make use of the `etag` in the
|
|
/// read-modify-write cycle to perform policy updates in order to avoid race
|
|
/// conditions: An `etag` is returned in the response to `getIamPolicy`, and
|
|
/// systems are expected to put that etag in the request to `setIamPolicy` to
|
|
/// ensure that their change will be applied to the same version of the policy.
|
|
///
|
|
/// If no `etag` is provided in the call to `setIamPolicy`, then the existing
|
|
/// policy is overwritten blindly.
|
|
pub etag: Option<String>,
|
|
/// Version of the `Policy`. The default version is 0.
|
|
pub version: Option<i32>,
|
|
/// no description provided
|
|
#[serde(rename="iamOwned")]
|
|
pub iam_owned: Option<bool>,
|
|
/// Specifies cloud audit logging configuration for this policy.
|
|
#[serde(rename="auditConfigs")]
|
|
pub audit_configs: Option<Vec<AuditConfig>>,
|
|
}
|
|
|
|
impl ResponseResult for Policy {}
|
|
|
|
|
|
/// Response message for KeyManagementService.Decrypt.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys decrypt projects](struct.ProjectLocationKeyRingCryptoKeyDecryptCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct DecryptResponse {
|
|
/// The decrypted data originally supplied in EncryptRequest.plaintext.
|
|
pub plaintext: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for DecryptResponse {}
|
|
|
|
|
|
/// Response message for KeyManagementService.ListCryptoKeyVersions.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys crypto key versions list projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ListCryptoKeyVersionsResponse {
|
|
/// A token to retrieve next page of results. Pass this value in
|
|
/// ListCryptoKeyVersionsRequest.page_token to retrieve the next page of
|
|
/// results.
|
|
#[serde(rename="nextPageToken")]
|
|
pub next_page_token: Option<String>,
|
|
/// The total number of CryptoKeyVersions that matched the
|
|
/// query.
|
|
#[serde(rename="totalSize")]
|
|
pub total_size: Option<i32>,
|
|
/// The list of CryptoKeyVersions.
|
|
#[serde(rename="cryptoKeyVersions")]
|
|
pub crypto_key_versions: Option<Vec<CryptoKeyVersion>>,
|
|
}
|
|
|
|
impl ResponseResult for ListCryptoKeyVersionsResponse {}
|
|
|
|
|
|
/// A CryptoKey represents a logical key that can be used for cryptographic
|
|
/// operations.
|
|
///
|
|
/// A CryptoKey is made up of one or more versions, which
|
|
/// represent the actual key material used in cryptographic operations.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys get projects](struct.ProjectLocationKeyRingCryptoKeyGetCall.html) (response)
|
|
/// * [locations key rings crypto keys update primary version projects](struct.ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall.html) (response)
|
|
/// * [locations key rings crypto keys create projects](struct.ProjectLocationKeyRingCryptoKeyCreateCall.html) (request|response)
|
|
/// * [locations key rings crypto keys patch projects](struct.ProjectLocationKeyRingCryptoKeyPatchCall.html) (request|response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CryptoKey {
|
|
/// Labels with user-defined metadata. For more information, see
|
|
/// [Labeling Keys](/kms/docs/labeling-keys).
|
|
pub labels: Option<HashMap<String, String>>,
|
|
/// Output only. The resource name for this CryptoKey in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
|
|
pub name: Option<String>,
|
|
/// At next_rotation_time, the Key Management Service will automatically:
|
|
///
|
|
/// 1. Create a new version of this CryptoKey.
|
|
/// 2. Mark the new version as primary.
|
|
///
|
|
/// Key rotations performed manually via
|
|
/// CreateCryptoKeyVersion and
|
|
/// UpdateCryptoKeyPrimaryVersion
|
|
/// do not affect next_rotation_time.
|
|
#[serde(rename="nextRotationTime")]
|
|
pub next_rotation_time: Option<String>,
|
|
/// next_rotation_time will be advanced by this period when the service
|
|
/// automatically rotates a key. Must be at least one day.
|
|
///
|
|
/// If rotation_period is set, next_rotation_time must also be set.
|
|
#[serde(rename="rotationPeriod")]
|
|
pub rotation_period: Option<String>,
|
|
/// Output only. A copy of the "primary" CryptoKeyVersion that will be used
|
|
/// by Encrypt when this CryptoKey is given
|
|
/// in EncryptRequest.name.
|
|
///
|
|
/// The CryptoKey's primary version can be updated via
|
|
/// UpdateCryptoKeyPrimaryVersion.
|
|
pub primary: Option<CryptoKeyVersion>,
|
|
/// Output only. The time at which this CryptoKey was created.
|
|
#[serde(rename="createTime")]
|
|
pub create_time: Option<String>,
|
|
/// The immutable purpose of this CryptoKey. Currently, the only acceptable
|
|
/// purpose is ENCRYPT_DECRYPT.
|
|
pub purpose: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for CryptoKey {}
|
|
impl ResponseResult for CryptoKey {}
|
|
|
|
|
|
/// Response message for `TestIamPermissions` 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*).
|
|
///
|
|
/// * [locations key rings test iam permissions projects](struct.ProjectLocationKeyRingTestIamPermissionCall.html) (response)
|
|
/// * [locations key rings crypto keys test iam permissions projects](struct.ProjectLocationKeyRingCryptoKeyTestIamPermissionCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct TestIamPermissionsResponse {
|
|
/// A subset of `TestPermissionsRequest.permissions` that the caller is
|
|
/// allowed.
|
|
pub permissions: Option<Vec<String>>,
|
|
}
|
|
|
|
impl ResponseResult for TestIamPermissionsResponse {}
|
|
|
|
|
|
/// Request message for KeyManagementService.RestoreCryptoKeyVersion.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys crypto key versions restore projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RestoreCryptoKeyVersionRequest { _never_set: Option<bool> }
|
|
|
|
impl RequestValue for RestoreCryptoKeyVersionRequest {}
|
|
|
|
|
|
/// Response message for KeyManagementService.Encrypt.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys encrypt projects](struct.ProjectLocationKeyRingCryptoKeyEncryptCall.html) (response)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EncryptResponse {
|
|
/// The encrypted data.
|
|
pub ciphertext: Option<String>,
|
|
/// The resource name of the CryptoKeyVersion used in encryption.
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl ResponseResult for EncryptResponse {}
|
|
|
|
|
|
/// Request message for KeyManagementService.DestroyCryptoKeyVersion.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys crypto key versions destroy projects](struct.ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct DestroyCryptoKeyVersionRequest { _never_set: Option<bool> }
|
|
|
|
impl RequestValue for DestroyCryptoKeyVersionRequest {}
|
|
|
|
|
|
/// Associates `members` with a `role`.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Binding {
|
|
/// Role that is assigned to `members`.
|
|
/// For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
|
|
/// Required
|
|
pub role: Option<String>,
|
|
/// The condition that is associated with this binding.
|
|
/// NOTE: an unsatisfied condition will not allow user access via current
|
|
/// binding. Different bindings, including their conditions, are examined
|
|
/// independently.
|
|
/// This field is GOOGLE_INTERNAL.
|
|
pub condition: Option<Expr>,
|
|
/// Specifies the identities requesting access for a Cloud Platform resource.
|
|
/// `members` can have the following values:
|
|
///
|
|
/// * `allUsers`: A special identifier that represents anyone who is
|
|
/// on the internet; with or without a Google account.
|
|
///
|
|
/// * `allAuthenticatedUsers`: A special identifier that represents anyone
|
|
/// who is authenticated with a Google account or a service account.
|
|
///
|
|
/// * `user:{emailid}`: An email address that represents a specific Google
|
|
/// account. For example, `alice@gmail.com` or `joe@example.com`.
|
|
///
|
|
///
|
|
/// * `serviceAccount:{emailid}`: An email address that represents a service
|
|
/// account. For example, `my-other-app@appspot.gserviceaccount.com`.
|
|
///
|
|
/// * `group:{emailid}`: An email address that represents a Google group.
|
|
/// For example, `admins@example.com`.
|
|
///
|
|
///
|
|
/// * `domain:{domain}`: A Google Apps domain name that represents all the
|
|
/// users of that domain. For example, `google.com` or `example.com`.
|
|
///
|
|
///
|
|
pub members: Option<Vec<String>>,
|
|
}
|
|
|
|
impl Part for Binding {}
|
|
|
|
|
|
/// Request message for KeyManagementService.UpdateCryptoKeyPrimaryVersion.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys update primary version projects](struct.ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct UpdateCryptoKeyPrimaryVersionRequest {
|
|
/// The id of the child CryptoKeyVersion to use as primary.
|
|
#[serde(rename="cryptoKeyVersionId")]
|
|
pub crypto_key_version_id: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for UpdateCryptoKeyPrimaryVersionRequest {}
|
|
|
|
|
|
/// Request message for KeyManagementService.Decrypt.
|
|
///
|
|
/// # 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*).
|
|
///
|
|
/// * [locations key rings crypto keys decrypt projects](struct.ProjectLocationKeyRingCryptoKeyDecryptCall.html) (request)
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct DecryptRequest {
|
|
/// Required. The encrypted data originally returned in
|
|
/// EncryptResponse.ciphertext.
|
|
pub ciphertext: Option<String>,
|
|
/// Optional data that must match the data originally supplied in
|
|
/// EncryptRequest.additional_authenticated_data.
|
|
#[serde(rename="additionalAuthenticatedData")]
|
|
pub additional_authenticated_data: Option<String>,
|
|
}
|
|
|
|
impl RequestValue for DecryptRequest {}
|
|
|
|
|
|
/// Represents an expression text. Example:
|
|
///
|
|
/// title: "User account presence"
|
|
/// description: "Determines whether the request has a user account"
|
|
/// expression: "size(request.user) > 0"
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Expr {
|
|
/// An optional title for the expression, i.e. a short string describing
|
|
/// its purpose. This can be used e.g. in UIs which allow to enter the
|
|
/// expression.
|
|
pub title: Option<String>,
|
|
/// Textual representation of an expression in
|
|
/// Common Expression Language syntax.
|
|
///
|
|
/// The application context of the containing message determines which
|
|
/// well-known feature set of CEL is supported.
|
|
pub expression: Option<String>,
|
|
/// An optional string indicating the location of the expression for error
|
|
/// reporting, e.g. a file name and a position in the file.
|
|
pub location: Option<String>,
|
|
/// An optional description of the expression. This is a longer text which
|
|
/// describes the expression, e.g. when hovered over it in a UI.
|
|
pub description: Option<String>,
|
|
}
|
|
|
|
impl Part for Expr {}
|
|
|
|
|
|
/// Specifies the audit configuration for a service.
|
|
/// The configuration determines which permission types are logged, and what
|
|
/// identities, if any, are exempted from logging.
|
|
/// An AuditConfig must have one or more AuditLogConfigs.
|
|
///
|
|
/// If there are AuditConfigs for both `allServices` and a specific service,
|
|
/// the union of the two AuditConfigs is used for that service: the log_types
|
|
/// specified in each AuditConfig are enabled, and the exempted_members in each
|
|
/// AuditConfig are exempted.
|
|
///
|
|
/// Example Policy with multiple AuditConfigs:
|
|
///
|
|
/// {
|
|
/// "audit_configs": [
|
|
/// {
|
|
/// "service": "allServices"
|
|
/// "audit_log_configs": [
|
|
/// {
|
|
/// "log_type": "DATA_READ",
|
|
/// "exempted_members": [
|
|
/// "user:foo@gmail.com"
|
|
/// ]
|
|
/// },
|
|
/// {
|
|
/// "log_type": "DATA_WRITE",
|
|
/// },
|
|
/// {
|
|
/// "log_type": "ADMIN_READ",
|
|
/// }
|
|
/// ]
|
|
/// },
|
|
/// {
|
|
/// "service": "fooservice.googleapis.com"
|
|
/// "audit_log_configs": [
|
|
/// {
|
|
/// "log_type": "DATA_READ",
|
|
/// },
|
|
/// {
|
|
/// "log_type": "DATA_WRITE",
|
|
/// "exempted_members": [
|
|
/// "user:bar@gmail.com"
|
|
/// ]
|
|
/// }
|
|
/// ]
|
|
/// }
|
|
/// ]
|
|
/// }
|
|
///
|
|
/// For fooservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ
|
|
/// logging. It also exempts foo@gmail.com from DATA_READ logging, and
|
|
/// bar@gmail.com from DATA_WRITE logging.
|
|
///
|
|
/// This type is not used in any activity, and only used as *part* of another schema.
|
|
///
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct AuditConfig {
|
|
/// no description provided
|
|
#[serde(rename="exemptedMembers")]
|
|
pub exempted_members: Option<Vec<String>>,
|
|
/// The configuration for logging of each type of permission.
|
|
/// Next ID: 4
|
|
#[serde(rename="auditLogConfigs")]
|
|
pub audit_log_configs: Option<Vec<AuditLogConfig>>,
|
|
/// Specifies a service that will be enabled for audit logging.
|
|
/// For example, `storage.googleapis.com`, `cloudsql.googleapis.com`.
|
|
/// `allServices` is a special value that covers all services.
|
|
pub service: Option<String>,
|
|
}
|
|
|
|
impl Part for AuditConfig {}
|
|
|
|
|
|
|
|
// ###################
|
|
// MethodBuilders ###
|
|
// #################
|
|
|
|
/// A builder providing access to all methods supported on *project* resources.
|
|
/// It is not used directly, but through the `CloudKMS` 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_cloudkms1 as cloudkms1;
|
|
///
|
|
/// # #[test] fn egal() {
|
|
/// use std::default::Default;
|
|
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// use cloudkms1::CloudKMS;
|
|
///
|
|
/// 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 = CloudKMS::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 `locations_get(...)`, `locations_key_rings_create(...)`, `locations_key_rings_crypto_keys_create(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_create(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_destroy(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_get(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_list(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_patch(...)`, `locations_key_rings_crypto_keys_crypto_key_versions_restore(...)`, `locations_key_rings_crypto_keys_decrypt(...)`, `locations_key_rings_crypto_keys_encrypt(...)`, `locations_key_rings_crypto_keys_get(...)`, `locations_key_rings_crypto_keys_get_iam_policy(...)`, `locations_key_rings_crypto_keys_list(...)`, `locations_key_rings_crypto_keys_patch(...)`, `locations_key_rings_crypto_keys_set_iam_policy(...)`, `locations_key_rings_crypto_keys_test_iam_permissions(...)`, `locations_key_rings_crypto_keys_update_primary_version(...)`, `locations_key_rings_get(...)`, `locations_key_rings_get_iam_policy(...)`, `locations_key_rings_list(...)`, `locations_key_rings_set_iam_policy(...)`, `locations_key_rings_test_iam_permissions(...)` and `locations_list(...)`
|
|
/// // to build up your call.
|
|
/// let rb = hub.projects();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectMethods<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
}
|
|
|
|
impl<'a, C, A> MethodsBuilder for ProjectMethods<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectMethods<'a, C, A> {
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Update a CryptoKeyVersion's metadata.
|
|
///
|
|
/// state may be changed between
|
|
/// ENABLED and
|
|
/// DISABLED using this
|
|
/// method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to
|
|
/// move between other states.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Output only. The resource name for this CryptoKeyVersion in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_patch(&self, request: CryptoKeyVersion, name: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Create a new KeyRing in a given Project and Location.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Required. The resource name of the location associated with the
|
|
/// KeyRings, in the format `projects/*/locations/*`.
|
|
pub fn locations_key_rings_create(&self, request: KeyRing, parent: &str) -> ProjectLocationKeyRingCreateCall<'a, C, A> {
|
|
ProjectLocationKeyRingCreateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_parent: parent.to_string(),
|
|
_key_ring_id: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists KeyRings.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The resource name of the location associated with the
|
|
/// KeyRings, in the format `projects/*/locations/*`.
|
|
pub fn locations_key_rings_list(&self, parent: &str) -> ProjectLocationKeyRingListCall<'a, C, A> {
|
|
ProjectLocationKeyRingListCall {
|
|
hub: self.hub,
|
|
_parent: parent.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Schedule a CryptoKeyVersion for destruction.
|
|
///
|
|
/// Upon calling this method, CryptoKeyVersion.state will be set to
|
|
/// DESTROY_SCHEDULED
|
|
/// and destroy_time will be set to a time 24
|
|
/// hours in the future, at which point the state
|
|
/// will be changed to
|
|
/// DESTROYED, and the key
|
|
/// material will be irrevocably destroyed.
|
|
///
|
|
/// Before the destroy_time is reached,
|
|
/// RestoreCryptoKeyVersion may be called to reverse the process.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - The resource name of the CryptoKeyVersion to destroy.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_destroy(&self, request: DestroyCryptoKeyVersionRequest, name: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall {
|
|
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:
|
|
///
|
|
/// Encrypts data, so that it can only be recovered by a call to Decrypt.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. The resource name of the CryptoKey or CryptoKeyVersion
|
|
/// to use for encryption.
|
|
/// If a CryptoKey is specified, the server will use its
|
|
/// primary version.
|
|
pub fn locations_key_rings_crypto_keys_encrypt(&self, request: EncryptRequest, name: &str) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyEncryptCall {
|
|
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 metadata for a given KeyRing.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The name of the KeyRing to get.
|
|
pub fn locations_key_rings_get(&self, name: &str) -> ProjectLocationKeyRingGetCall<'a, C, A> {
|
|
ProjectLocationKeyRingGetCall {
|
|
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:
|
|
///
|
|
/// Returns metadata for a given CryptoKey, as well as its
|
|
/// primary CryptoKeyVersion.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The name of the CryptoKey to get.
|
|
pub fn locations_key_rings_crypto_keys_get(&self, name: &str) -> ProjectLocationKeyRingCryptoKeyGetCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyGetCall {
|
|
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:
|
|
///
|
|
/// Lists information about the supported locations for this service.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The resource that owns the locations collection, if applicable.
|
|
pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C, A> {
|
|
ProjectLocationListCall {
|
|
hub: self.hub,
|
|
_name: name.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: 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:
|
|
///
|
|
/// Returns permissions that a caller has on the specified resource.
|
|
/// If the resource does not exist, this will return an empty set of
|
|
/// permissions, not a NOT_FOUND error.
|
|
///
|
|
/// Note: This operation is designed to be used for building permission-aware
|
|
/// UIs and command-line tools, not for authorization checking. This operation
|
|
/// may "fail open" without warning.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `resource` - REQUIRED: The resource for which the policy detail is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C, A> {
|
|
ProjectLocationKeyRingTestIamPermissionCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Gets the access control policy for a resource.
|
|
/// Returns an empty policy if the resource exists and does not have a policy
|
|
/// set.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `resource` - REQUIRED: The resource for which the policy is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_crypto_keys_get_iam_policy(&self, resource: &str) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyGetIamPolicyCall {
|
|
hub: self.hub,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Update the version of a CryptoKey that will be used in Encrypt
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - The resource name of the CryptoKey to update.
|
|
pub fn locations_key_rings_crypto_keys_update_primary_version(&self, request: UpdateCryptoKeyPrimaryVersionRequest, name: &str) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall {
|
|
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:
|
|
///
|
|
/// Update a CryptoKey.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Output only. The resource name for this CryptoKey in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
|
|
pub fn locations_key_rings_crypto_keys_patch(&self, request: CryptoKey, name: &str) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyPatchCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_name: name.to_string(),
|
|
_update_mask: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Decrypts data that was protected by Encrypt.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - Required. The resource name of the CryptoKey to use for decryption.
|
|
/// The server will choose the appropriate version.
|
|
pub fn locations_key_rings_crypto_keys_decrypt(&self, request: DecryptRequest, name: &str) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyDecryptCall {
|
|
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:
|
|
///
|
|
/// Gets the access control policy for a resource.
|
|
/// Returns an empty policy if the resource exists and does not have a policy
|
|
/// set.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `resource` - REQUIRED: The resource for which the policy is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_get_iam_policy(&self, resource: &str) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C, A> {
|
|
ProjectLocationKeyRingGetIamPolicyCall {
|
|
hub: self.hub,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Sets the access control policy on the specified resource. Replaces any
|
|
/// existing policy.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `resource` - REQUIRED: The resource for which the policy is being specified.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_set_iam_policy(&self, request: SetIamPolicyRequest, resource: &str) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C, A> {
|
|
ProjectLocationKeyRingSetIamPolicyCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Get information about a location.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - Resource name for the location.
|
|
pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C, A> {
|
|
ProjectLocationGetCall {
|
|
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:
|
|
///
|
|
/// Returns permissions that a caller has on the specified resource.
|
|
/// If the resource does not exist, this will return an empty set of
|
|
/// permissions, not a NOT_FOUND error.
|
|
///
|
|
/// Note: This operation is designed to be used for building permission-aware
|
|
/// UIs and command-line tools, not for authorization checking. This operation
|
|
/// may "fail open" without warning.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `resource` - REQUIRED: The resource for which the policy detail is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_crypto_keys_test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyTestIamPermissionCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists CryptoKeyVersions.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The resource name of the CryptoKey to list, in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_list(&self, parent: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall {
|
|
hub: self.hub,
|
|
_parent: parent.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Lists CryptoKeys.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `parent` - Required. The resource name of the KeyRing to list, in the format
|
|
/// `projects/*/locations/*/keyRings/*`.
|
|
pub fn locations_key_rings_crypto_keys_list(&self, parent: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyListCall {
|
|
hub: self.hub,
|
|
_parent: parent.to_string(),
|
|
_page_token: Default::default(),
|
|
_page_size: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Create a new CryptoKeyVersion in a CryptoKey.
|
|
///
|
|
/// The server will assign the next sequential id. If unset,
|
|
/// state will be set to
|
|
/// ENABLED.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Required. The name of the CryptoKey associated with
|
|
/// the CryptoKeyVersions.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_create(&self, request: CryptoKeyVersion, parent: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall {
|
|
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:
|
|
///
|
|
/// Returns metadata for a given CryptoKeyVersion.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `name` - The name of the CryptoKeyVersion to get.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_get(&self, name: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall {
|
|
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:
|
|
///
|
|
/// Sets the access control policy on the specified resource. Replaces any
|
|
/// existing policy.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `resource` - REQUIRED: The resource for which the policy is being specified.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
pub fn locations_key_rings_crypto_keys_set_iam_policy(&self, request: SetIamPolicyRequest, resource: &str) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeySetIamPolicyCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_resource: resource.to_string(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
|
|
/// Create a builder to help you perform the following task:
|
|
///
|
|
/// Restore a CryptoKeyVersion in the
|
|
/// DESTROY_SCHEDULED,
|
|
/// state.
|
|
///
|
|
/// Upon restoration of the CryptoKeyVersion, state
|
|
/// will be set to DISABLED,
|
|
/// and destroy_time will be cleared.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `name` - The resource name of the CryptoKeyVersion to restore.
|
|
pub fn locations_key_rings_crypto_keys_crypto_key_versions_restore(&self, request: RestoreCryptoKeyVersionRequest, name: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall {
|
|
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:
|
|
///
|
|
/// Create a new CryptoKey within a KeyRing.
|
|
///
|
|
/// CryptoKey.purpose is required.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `request` - No description provided.
|
|
/// * `parent` - Required. The name of the KeyRing associated with the
|
|
/// CryptoKeys.
|
|
pub fn locations_key_rings_crypto_keys_create(&self, request: CryptoKey, parent: &str) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A> {
|
|
ProjectLocationKeyRingCryptoKeyCreateCall {
|
|
hub: self.hub,
|
|
_request: request,
|
|
_parent: parent.to_string(),
|
|
_crypto_key_id: Default::default(),
|
|
_delegate: Default::default(),
|
|
_scopes: Default::default(),
|
|
_additional_params: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ###################
|
|
// CallBuilders ###
|
|
// #################
|
|
|
|
/// Update a CryptoKeyVersion's metadata.
|
|
///
|
|
/// state may be changed between
|
|
/// ENABLED and
|
|
/// DISABLED using this
|
|
/// method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to
|
|
/// move between other states.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.patch* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::CryptoKeyVersion;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = CryptoKeyVersion::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_patch(req, "name")
|
|
/// .update_mask("accusam")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: CryptoKeyVersion,
|
|
_name: String,
|
|
_update_mask: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'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, CryptoKeyVersion)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("name", self._name.to_string()));
|
|
if let Some(value) = self._update_mask {
|
|
params.push(("updateMask", value.to_string()));
|
|
}
|
|
for &field in ["alt", "name", "updateMask"].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));
|
|
}
|
|
|
|
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::Patch, &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: CryptoKeyVersion) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Output only. The resource name for this CryptoKeyVersion in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Required list of fields to be updated in this request.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'a, C, A> {
|
|
self._update_mask = 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionPatchCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Create a new KeyRing in a given Project and Location.
|
|
///
|
|
/// A builder for the *locations.keyRings.create* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::KeyRing;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = KeyRing::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_create(req, "parent")
|
|
/// .key_ring_id("justo")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCreateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: KeyRing,
|
|
_parent: String,
|
|
_key_ring_id: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCreateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCreateCall<'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, KeyRing)> {
|
|
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: "cloudkms.projects.locations.keyRings.create",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("parent", self._parent.to_string()));
|
|
if let Some(value) = self._key_ring_id {
|
|
params.push(("keyRingId", value.to_string()));
|
|
}
|
|
for &field in ["alt", "parent", "keyRingId"].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}/keyRings";
|
|
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: KeyRing) -> ProjectLocationKeyRingCreateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. The resource name of the location associated with the
|
|
/// KeyRings, in the format `projects/*/locations/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCreateCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Required. It must be unique within a location and match the regular
|
|
/// expression `[a-zA-Z0-9_-]{1,63}`
|
|
///
|
|
/// Sets the *key ring id* query property to the given value.
|
|
pub fn key_ring_id(mut self, new_value: &str) -> ProjectLocationKeyRingCreateCall<'a, C, A> {
|
|
self._key_ring_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectLocationKeyRingCreateCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCreateCall<'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) -> ProjectLocationKeyRingCreateCall<'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 KeyRings.
|
|
///
|
|
/// A builder for the *locations.keyRings.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_list("parent")
|
|
/// .page_token("erat")
|
|
/// .page_size(-35)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingListCall<'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, ListKeyRingsResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + 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()));
|
|
}
|
|
for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/keyRings";
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The resource name of the location associated with the
|
|
/// KeyRings, in the format `projects/*/locations/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingListCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional pagination token, returned earlier via
|
|
/// ListKeyRingsResponse.next_page_token.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional limit on the number of KeyRings to include in the
|
|
/// response. Further KeyRings can subsequently be obtained by
|
|
/// including the ListKeyRingsResponse.next_page_token in a subsequent
|
|
/// request. If unspecified, the server will pick an appropriate default.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectLocationKeyRingListCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingListCall<'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) -> ProjectLocationKeyRingListCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Schedule a CryptoKeyVersion for destruction.
|
|
///
|
|
/// Upon calling this method, CryptoKeyVersion.state will be set to
|
|
/// DESTROY_SCHEDULED
|
|
/// and destroy_time will be set to a time 24
|
|
/// hours in the future, at which point the state
|
|
/// will be changed to
|
|
/// DESTROYED, and the key
|
|
/// material will be irrevocably destroyed.
|
|
///
|
|
/// Before the destroy_time is reached,
|
|
/// RestoreCryptoKeyVersion may be called to reverse the process.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::DestroyCryptoKeyVersionRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = DestroyCryptoKeyVersionRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_destroy(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: DestroyCryptoKeyVersionRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'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, CryptoKeyVersion)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy",
|
|
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}:destroy";
|
|
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: DestroyCryptoKeyVersionRequest) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// The resource name of the CryptoKeyVersion to destroy.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionDestroyCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Encrypts data, so that it can only be recovered by a call to Decrypt.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.encrypt* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::EncryptRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = EncryptRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_encrypt(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: EncryptRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyEncryptCall<'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, EncryptResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt",
|
|
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}:encrypt";
|
|
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: EncryptRequest) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. The resource name of the CryptoKey or CryptoKeyVersion
|
|
/// to use for encryption.
|
|
///
|
|
/// If a CryptoKey is specified, the server will use its
|
|
/// primary version.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'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) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'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) -> ProjectLocationKeyRingCryptoKeyEncryptCall<'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 metadata for a given KeyRing.
|
|
///
|
|
/// A builder for the *locations.keyRings.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingGetCall<'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, KeyRing)> {
|
|
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: "cloudkms.projects.locations.keyRings.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 KeyRing to get.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingGetCall<'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) -> ProjectLocationKeyRingGetCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingGetCall<'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) -> ProjectLocationKeyRingGetCall<'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 metadata for a given CryptoKey, as well as its
|
|
/// primary CryptoKeyVersion.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_crypto_keys_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyGetCall<'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, CryptoKey)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.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 CryptoKey to get.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyGetCall<'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) -> ProjectLocationKeyRingCryptoKeyGetCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyGetCall<'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) -> ProjectLocationKeyRingCryptoKeyGetCall<'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 information about the supported locations for this service.
|
|
///
|
|
/// A builder for the *locations.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_list("name")
|
|
/// .page_token("aliquyam")
|
|
/// .page_size(-66)
|
|
/// .filter("no")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_name: 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 ProjectLocationListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationListCall<'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, ListLocationsResponse)> {
|
|
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: "cloudkms.projects.locations.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((6 + self._additional_params.len()));
|
|
params.push(("name", self._name.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", "name", "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/{+name}/locations";
|
|
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 resource that owns the locations collection, if applicable.
|
|
///
|
|
/// 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) -> ProjectLocationListCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// The standard list page token.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'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) -> ProjectLocationListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// The standard list filter.
|
|
///
|
|
/// Sets the *filter* query property to the given value.
|
|
pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'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) -> ProjectLocationListCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationListCall<'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) -> ProjectLocationListCall<'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 permissions that a caller has on the specified resource.
|
|
/// If the resource does not exist, this will return an empty set of
|
|
/// permissions, not a NOT_FOUND error.
|
|
///
|
|
/// Note: This operation is designed to be used for building permission-aware
|
|
/// UIs and command-line tools, not for authorization checking. This operation
|
|
/// may "fail open" without warning.
|
|
///
|
|
/// A builder for the *locations.keyRings.testIamPermissions* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::TestIamPermissionsRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = TestIamPermissionsRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_test_iam_permissions(req, "resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingTestIamPermissionCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: TestIamPermissionsRequest,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingTestIamPermissionCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingTestIamPermissionCall<'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, TestIamPermissionsResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.testIamPermissions",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:testIamPermissions";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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: TestIamPermissionsRequest) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// REQUIRED: The resource for which the policy detail is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingTestIamPermissionCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingTestIamPermissionCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingTestIamPermissionCall<'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) -> ProjectLocationKeyRingTestIamPermissionCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the access control policy for a resource.
|
|
/// Returns an empty policy if the resource exists and does not have a policy
|
|
/// set.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.getIamPolicy* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_crypto_keys_get_iam_policy("resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'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, Policy)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:getIamPolicy";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// REQUIRED: The resource for which the policy is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'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) -> ProjectLocationKeyRingCryptoKeyGetIamPolicyCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Update the version of a CryptoKey that will be used in Encrypt
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.updatePrimaryVersion* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::UpdateCryptoKeyPrimaryVersionRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = UpdateCryptoKeyPrimaryVersionRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_update_primary_version(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: UpdateCryptoKeyPrimaryVersionRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'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, CryptoKey)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion",
|
|
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}:updatePrimaryVersion";
|
|
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: UpdateCryptoKeyPrimaryVersionRequest) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// The resource name of the CryptoKey to update.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'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) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'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) -> ProjectLocationKeyRingCryptoKeyUpdatePrimaryVersionCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Update a CryptoKey.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.patch* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::CryptoKey;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = CryptoKey::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_patch(req, "name")
|
|
/// .update_mask("diam")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: CryptoKey,
|
|
_name: String,
|
|
_update_mask: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyPatchCall<'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, CryptoKey)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.patch",
|
|
http_method: hyper::method::Method::Patch });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("name", self._name.to_string()));
|
|
if let Some(value) = self._update_mask {
|
|
params.push(("updateMask", value.to_string()));
|
|
}
|
|
for &field in ["alt", "name", "updateMask"].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));
|
|
}
|
|
|
|
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::Patch, &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: CryptoKey) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Output only. The resource name for this CryptoKey in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A> {
|
|
self._name = new_value.to_string();
|
|
self
|
|
}
|
|
/// Required list of fields to be updated in this request.
|
|
///
|
|
/// Sets the *update mask* query property to the given value.
|
|
pub fn update_mask(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyPatchCall<'a, C, A> {
|
|
self._update_mask = 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) -> ProjectLocationKeyRingCryptoKeyPatchCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyPatchCall<'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) -> ProjectLocationKeyRingCryptoKeyPatchCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Decrypts data that was protected by Encrypt.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.decrypt* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::DecryptRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = DecryptRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_decrypt(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: DecryptRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyDecryptCall<'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, DecryptResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt",
|
|
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}:decrypt";
|
|
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: DecryptRequest) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. The resource name of the CryptoKey to use for decryption.
|
|
/// The server will choose the appropriate version.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'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) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'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) -> ProjectLocationKeyRingCryptoKeyDecryptCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Gets the access control policy for a resource.
|
|
/// Returns an empty policy if the resource exists and does not have a policy
|
|
/// set.
|
|
///
|
|
/// A builder for the *locations.keyRings.getIamPolicy* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_get_iam_policy("resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingGetIamPolicyCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingGetIamPolicyCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingGetIamPolicyCall<'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, Policy)> {
|
|
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: "cloudkms.projects.locations.keyRings.getIamPolicy",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((3 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:getIamPolicy";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// REQUIRED: The resource for which the policy is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingGetIamPolicyCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingGetIamPolicyCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingGetIamPolicyCall<'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) -> ProjectLocationKeyRingGetIamPolicyCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the access control policy on the specified resource. Replaces any
|
|
/// existing policy.
|
|
///
|
|
/// A builder for the *locations.keyRings.setIamPolicy* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::SetIamPolicyRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = SetIamPolicyRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_set_iam_policy(req, "resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingSetIamPolicyCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: SetIamPolicyRequest,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingSetIamPolicyCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingSetIamPolicyCall<'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, Policy)> {
|
|
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: "cloudkms.projects.locations.keyRings.setIamPolicy",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:setIamPolicy";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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: SetIamPolicyRequest) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// REQUIRED: The resource for which the policy is being specified.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingSetIamPolicyCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingSetIamPolicyCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingSetIamPolicyCall<'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) -> ProjectLocationKeyRingSetIamPolicyCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Get information about a location.
|
|
///
|
|
/// A builder for the *locations.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationGetCall<'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, Location)> {
|
|
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: "cloudkms.projects.locations.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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Resource name for the location.
|
|
///
|
|
/// 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) -> ProjectLocationGetCall<'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) -> ProjectLocationGetCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationGetCall<'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) -> ProjectLocationGetCall<'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 permissions that a caller has on the specified resource.
|
|
/// If the resource does not exist, this will return an empty set of
|
|
/// permissions, not a NOT_FOUND error.
|
|
///
|
|
/// Note: This operation is designed to be used for building permission-aware
|
|
/// UIs and command-line tools, not for authorization checking. This operation
|
|
/// may "fail open" without warning.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.testIamPermissions* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::TestIamPermissionsRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = TestIamPermissionsRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_test_iam_permissions(req, "resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: TestIamPermissionsRequest,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'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, TestIamPermissionsResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:testIamPermissions";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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: TestIamPermissionsRequest) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// REQUIRED: The resource for which the policy detail is being requested.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'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) -> ProjectLocationKeyRingCryptoKeyTestIamPermissionCall<'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 CryptoKeyVersions.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_crypto_keys_crypto_key_versions_list("parent")
|
|
/// .page_token("Lorem")
|
|
/// .page_size(-75)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'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, ListCryptoKeyVersionsResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + 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()));
|
|
}
|
|
for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeyVersions";
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The resource name of the CryptoKey to list, in the format
|
|
/// `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional pagination token, returned earlier via
|
|
/// ListCryptoKeyVersionsResponse.next_page_token.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional limit on the number of CryptoKeyVersions to
|
|
/// include in the response. Further CryptoKeyVersions can
|
|
/// subsequently be obtained by including the
|
|
/// ListCryptoKeyVersionsResponse.next_page_token in a subsequent request.
|
|
/// If unspecified, the server will pick an appropriate default.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionListCall<'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 CryptoKeys.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.list* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_crypto_keys_list("parent")
|
|
/// .page_token("sadipscing")
|
|
/// .page_size(-48)
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyListCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_parent: String,
|
|
_page_token: Option<String>,
|
|
_page_size: Option<i32>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyListCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyListCall<'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, ListCryptoKeysResponse)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.list",
|
|
http_method: hyper::method::Method::Get });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + 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()));
|
|
}
|
|
for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
|
|
if self._additional_params.contains_key(field) {
|
|
dlg.finished(false);
|
|
return Err(Error::FieldClash(field));
|
|
}
|
|
}
|
|
for (name, value) in self._additional_params.iter() {
|
|
params.push((&name, value.clone()));
|
|
}
|
|
|
|
params.push(("alt", "json".to_string()));
|
|
|
|
let mut url = self.hub._base_url.clone() + "v1/{+parent}/cryptoKeys";
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// Required. The resource name of the KeyRing to list, in the format
|
|
/// `projects/*/locations/*/keyRings/*`.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Optional pagination token, returned earlier via
|
|
/// ListCryptoKeysResponse.next_page_token.
|
|
///
|
|
/// Sets the *page token* query property to the given value.
|
|
pub fn page_token(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C, A> {
|
|
self._page_token = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// Optional limit on the number of CryptoKeys to include in the
|
|
/// response. Further CryptoKeys can subsequently be obtained by
|
|
/// including the ListCryptoKeysResponse.next_page_token in a subsequent
|
|
/// request. If unspecified, the server will pick an appropriate default.
|
|
///
|
|
/// Sets the *page size* query property to the given value.
|
|
pub fn page_size(mut self, new_value: i32) -> ProjectLocationKeyRingCryptoKeyListCall<'a, C, A> {
|
|
self._page_size = Some(new_value);
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectLocationKeyRingCryptoKeyListCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyListCall<'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) -> ProjectLocationKeyRingCryptoKeyListCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Create a new CryptoKeyVersion in a CryptoKey.
|
|
///
|
|
/// The server will assign the next sequential id. If unset,
|
|
/// state will be set to
|
|
/// ENABLED.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.create* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::CryptoKeyVersion;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = CryptoKeyVersion::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_create(req, "parent")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: CryptoKeyVersion,
|
|
_parent: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'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, CryptoKeyVersion)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create",
|
|
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}/cryptoKeyVersions";
|
|
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: CryptoKeyVersion) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. The name of the CryptoKey associated with
|
|
/// the CryptoKeyVersions.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionCreateCall<'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 metadata for a given CryptoKeyVersion.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.get* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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.projects().locations_key_rings_crypto_keys_crypto_key_versions_get("name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'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, CryptoKeyVersion)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.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 CryptoKeyVersion to get.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionGetCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Sets the access control policy on the specified resource. Replaces any
|
|
/// existing policy.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.setIamPolicy* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::SetIamPolicyRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = SetIamPolicyRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_set_iam_policy(req, "resource")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: SetIamPolicyRequest,
|
|
_resource: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'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, Policy)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
|
params.push(("resource", self._resource.to_string()));
|
|
for &field in ["alt", "resource"].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/{+resource}:setIamPolicy";
|
|
if self._scopes.len() == 0 {
|
|
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string(), ());
|
|
}
|
|
|
|
for &(find_this, param_name) in [("{+resource}", "resource")].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 ["resource"].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: SetIamPolicyRequest) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// REQUIRED: The resource for which the policy is being specified.
|
|
/// See the operation documentation for the appropriate value for this field.
|
|
///
|
|
/// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'a, C, A> {
|
|
self._resource = 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) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'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) -> ProjectLocationKeyRingCryptoKeySetIamPolicyCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Restore a CryptoKeyVersion in the
|
|
/// DESTROY_SCHEDULED,
|
|
/// state.
|
|
///
|
|
/// Upon restoration of the CryptoKeyVersion, state
|
|
/// will be set to DISABLED,
|
|
/// and destroy_time will be cleared.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.cryptoKeyVersions.restore* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::RestoreCryptoKeyVersionRequest;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = RestoreCryptoKeyVersionRequest::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_crypto_key_versions_restore(req, "name")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: RestoreCryptoKeyVersionRequest,
|
|
_name: String,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'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, CryptoKeyVersion)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore",
|
|
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}:restore";
|
|
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: RestoreCryptoKeyVersionRequest) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// The resource name of the CryptoKeyVersion to restore.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'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) -> ProjectLocationKeyRingCryptoKeyCryptoKeyVersionRestoreCall<'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
|
|
}
|
|
}
|
|
|
|
|
|
/// Create a new CryptoKey within a KeyRing.
|
|
///
|
|
/// CryptoKey.purpose is required.
|
|
///
|
|
/// A builder for the *locations.keyRings.cryptoKeys.create* method supported by a *project* resource.
|
|
/// It is not used directly, but through a `ProjectMethods` instance.
|
|
///
|
|
/// # Example
|
|
///
|
|
/// Instantiate a resource method builder
|
|
///
|
|
/// ```test_harness,no_run
|
|
/// # extern crate hyper;
|
|
/// # extern crate hyper_rustls;
|
|
/// # extern crate yup_oauth2 as oauth2;
|
|
/// # extern crate google_cloudkms1 as cloudkms1;
|
|
/// use cloudkms1::CryptoKey;
|
|
/// # #[test] fn egal() {
|
|
/// # use std::default::Default;
|
|
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
|
/// # use cloudkms1::CloudKMS;
|
|
///
|
|
/// # 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 = CloudKMS::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 = CryptoKey::default();
|
|
///
|
|
/// // You can configure optional parameters by calling the respective setters at will, and
|
|
/// // execute the final call using `doit()`.
|
|
/// // Values shown here are possibly random and not representative !
|
|
/// let result = hub.projects().locations_key_rings_crypto_keys_create(req, "parent")
|
|
/// .crypto_key_id("eirmod")
|
|
/// .doit();
|
|
/// # }
|
|
/// ```
|
|
pub struct ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A>
|
|
where C: 'a, A: 'a {
|
|
|
|
hub: &'a CloudKMS<C, A>,
|
|
_request: CryptoKey,
|
|
_parent: String,
|
|
_crypto_key_id: Option<String>,
|
|
_delegate: Option<&'a mut Delegate>,
|
|
_additional_params: HashMap<String, String>,
|
|
_scopes: BTreeMap<String, ()>
|
|
}
|
|
|
|
impl<'a, C, A> CallBuilder for ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A> {}
|
|
|
|
impl<'a, C, A> ProjectLocationKeyRingCryptoKeyCreateCall<'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, CryptoKey)> {
|
|
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: "cloudkms.projects.locations.keyRings.cryptoKeys.create",
|
|
http_method: hyper::method::Method::Post });
|
|
let mut params: Vec<(&str, String)> = Vec::with_capacity((5 + self._additional_params.len()));
|
|
params.push(("parent", self._parent.to_string()));
|
|
if let Some(value) = self._crypto_key_id {
|
|
params.push(("cryptoKeyId", value.to_string()));
|
|
}
|
|
for &field in ["alt", "parent", "cryptoKeyId"].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}/cryptoKeys";
|
|
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: CryptoKey) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A> {
|
|
self._request = new_value;
|
|
self
|
|
}
|
|
/// Required. The name of the KeyRing associated with the
|
|
/// CryptoKeys.
|
|
///
|
|
/// 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) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A> {
|
|
self._parent = new_value.to_string();
|
|
self
|
|
}
|
|
/// Required. It must be unique within a KeyRing and match the regular
|
|
/// expression `[a-zA-Z0-9_-]{1,63}`
|
|
///
|
|
/// Sets the *crypto key id* query property to the given value.
|
|
pub fn crypto_key_id(mut self, new_value: &str) -> ProjectLocationKeyRingCryptoKeyCreateCall<'a, C, A> {
|
|
self._crypto_key_id = Some(new_value.to_string());
|
|
self
|
|
}
|
|
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
|
/// while executing the actual API request.
|
|
///
|
|
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
|
///
|
|
/// Sets the *delegate* property to the given value.
|
|
pub fn delegate(mut self, new_value: &'a mut Delegate) -> ProjectLocationKeyRingCryptoKeyCreateCall<'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").
|
|
/// * *pp* (query-boolean) - Pretty-print response.
|
|
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
|
/// * *bearer_token* (query-string) - OAuth bearer token.
|
|
/// * *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) -> ProjectLocationKeyRingCryptoKeyCreateCall<'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) -> ProjectLocationKeyRingCryptoKeyCreateCall<'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
|
|
}
|
|
}
|
|
|
|
|