mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-11 05:51:49 +01:00
9466 lines
414 KiB
Rust
9466 lines
414 KiB
Rust
use std::collections::HashMap;
|
||
use std::cell::RefCell;
|
||
use std::default::Default;
|
||
use std::collections::BTreeSet;
|
||
use std::error::Error as StdError;
|
||
use serde_json as json;
|
||
use std::io;
|
||
use std::fs;
|
||
use std::mem;
|
||
|
||
use hyper::client::connect;
|
||
use tokio::io::{AsyncRead, AsyncWrite};
|
||
use tokio::time::sleep;
|
||
use tower_service;
|
||
use serde::{Serialize, Deserialize};
|
||
|
||
use crate::{client, client::GetToken, client::serde_with};
|
||
|
||
// ##############
|
||
// UTILITIES ###
|
||
// ############
|
||
|
||
/// Identifies the an OAuth2 authorization scope.
|
||
/// A scope is needed when requesting an
|
||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||
#[derive(PartialEq, Eq, Hash)]
|
||
pub enum Scope {
|
||
/// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
|
||
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 CloudFilestore related resource activities
|
||
///
|
||
/// # Examples
|
||
///
|
||
/// Instantiate a new hub
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Backup;
|
||
/// use file1_beta1::{Result, Error};
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
||
/// // `client_secret`, among other things.
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
||
/// // unless you replace `None` with the desired Flow.
|
||
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
||
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
||
/// // retrieve them from storage.
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Backup::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_backups_create(req, "parent")
|
||
/// .backup_id("At")
|
||
/// .doit().await;
|
||
///
|
||
/// match result {
|
||
/// Err(e) => match e {
|
||
/// // The Error enum provides details about what exactly happened.
|
||
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
||
/// Error::HttpError(_)
|
||
/// |Error::Io(_)
|
||
/// |Error::MissingAPIKey
|
||
/// |Error::MissingToken(_)
|
||
/// |Error::Cancelled
|
||
/// |Error::UploadSizeLimitExceeded(_, _)
|
||
/// |Error::Failure(_)
|
||
/// |Error::BadRequest(_)
|
||
/// |Error::FieldClash(_)
|
||
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
||
/// },
|
||
/// Ok(res) => println!("Success: {:?}", res),
|
||
/// }
|
||
/// # }
|
||
/// ```
|
||
#[derive(Clone)]
|
||
pub struct CloudFilestore<S> {
|
||
pub client: hyper::Client<S, hyper::body::Body>,
|
||
pub auth: Box<dyn client::GetToken>,
|
||
_user_agent: String,
|
||
_base_url: String,
|
||
_root_url: String,
|
||
}
|
||
|
||
impl<'a, S> client::Hub for CloudFilestore<S> {}
|
||
|
||
impl<'a, S> CloudFilestore<S> {
|
||
|
||
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> CloudFilestore<S> {
|
||
CloudFilestore {
|
||
client,
|
||
auth: Box::new(auth),
|
||
_user_agent: "google-api-rust-client/5.0.3".to_string(),
|
||
_base_url: "https://file.googleapis.com/".to_string(),
|
||
_root_url: "https://file.googleapis.com/".to_string(),
|
||
}
|
||
}
|
||
|
||
pub fn projects(&'a self) -> ProjectMethods<'a, S> {
|
||
ProjectMethods { hub: &self }
|
||
}
|
||
|
||
/// Set the user-agent header field to use in all requests to the server.
|
||
/// It defaults to `google-api-rust-client/5.0.3`.
|
||
///
|
||
/// 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://file.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://file.googleapis.com/`.
|
||
///
|
||
/// Returns the previously set root url.
|
||
pub fn root_url(&mut self, new_root_url: String) -> String {
|
||
mem::replace(&mut self._root_url, new_root_url)
|
||
}
|
||
}
|
||
|
||
|
||
// ############
|
||
// SCHEMAS ###
|
||
// ##########
|
||
/// A Filestore backup.
|
||
///
|
||
/// # 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 backups create projects](ProjectLocationBackupCreateCall) (request)
|
||
/// * [locations backups get projects](ProjectLocationBackupGetCall) (response)
|
||
/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Backup {
|
||
/// Output only. Capacity of the source file share when the backup was created.
|
||
#[serde(rename="capacityGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub capacity_gb: Option<i64>,
|
||
/// Output only. The time when the backup was created.
|
||
#[serde(rename="createTime")]
|
||
|
||
pub create_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
||
/// A description of the backup with 2048 characters or less. Requests with longer descriptions will be rejected.
|
||
|
||
pub description: Option<String>,
|
||
/// Output only. Amount of bytes that will be downloaded if the backup is restored
|
||
#[serde(rename="downloadBytes")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub download_bytes: Option<i64>,
|
||
/// Immutable. KMS key name used for data encryption.
|
||
#[serde(rename="kmsKeyName")]
|
||
|
||
pub kms_key_name: Option<String>,
|
||
/// Resource labels to represent user provided metadata.
|
||
|
||
pub labels: Option<HashMap<String, String>>,
|
||
/// Output only. The resource name of the backup, in the format `projects/{project_id}/locations/{location_id}/backups/{backup_id}`.
|
||
|
||
pub name: Option<String>,
|
||
/// Output only. Reserved for future use.
|
||
#[serde(rename="satisfiesPzs")]
|
||
|
||
pub satisfies_pzs: Option<bool>,
|
||
/// Name of the file share in the source Filestore instance that the backup is created from.
|
||
#[serde(rename="sourceFileShare")]
|
||
|
||
pub source_file_share: Option<String>,
|
||
/// The resource name of the source Filestore instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`, used to create this backup.
|
||
#[serde(rename="sourceInstance")]
|
||
|
||
pub source_instance: Option<String>,
|
||
/// Output only. The service tier of the source Filestore instance that this backup is created from.
|
||
#[serde(rename="sourceInstanceTier")]
|
||
|
||
pub source_instance_tier: Option<String>,
|
||
/// Output only. The backup state.
|
||
|
||
pub state: Option<String>,
|
||
/// Output only. The size of the storage used by the backup. As backups share storage, this number is expected to change with backup creation/deletion.
|
||
#[serde(rename="storageBytes")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub storage_bytes: Option<i64>,
|
||
}
|
||
|
||
impl client::RequestValue for Backup {}
|
||
impl client::ResponseResult for Backup {}
|
||
|
||
|
||
/// The request message for Operations.CancelOperation.
|
||
///
|
||
/// # Activities
|
||
///
|
||
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
||
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
||
///
|
||
/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct CancelOperationRequest { _never_set: Option<bool> }
|
||
|
||
impl client::RequestValue for CancelOperationRequest {}
|
||
|
||
|
||
/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
|
||
///
|
||
/// # 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 operations cancel projects](ProjectLocationOperationCancelCall) (response)
|
||
/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Empty { _never_set: Option<bool> }
|
||
|
||
impl client::ResponseResult for Empty {}
|
||
|
||
|
||
/// File share configuration for the instance.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct FileShareConfig {
|
||
/// File share capacity in gigabytes (GB). Filestore defines 1 GB as 1024^3 bytes.
|
||
#[serde(rename="capacityGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub capacity_gb: Option<i64>,
|
||
/// The name of the file share (must be 32 characters or less for Enterprise and High Scale SSD tiers and 16 characters or less for all other tiers).
|
||
|
||
pub name: Option<String>,
|
||
/// Nfs Export Options. There is a limit of 10 export options per file share.
|
||
#[serde(rename="nfsExportOptions")]
|
||
|
||
pub nfs_export_options: Option<Vec<NfsExportOptions>>,
|
||
/// The resource name of the backup, in the format `projects/{project_id}/locations/{location_id}/backups/{backup_id}`, that this file share has been restored from.
|
||
#[serde(rename="sourceBackup")]
|
||
|
||
pub source_backup: Option<String>,
|
||
}
|
||
|
||
impl client::Part for FileShareConfig {}
|
||
|
||
|
||
/// A Filestore instance.
|
||
///
|
||
/// # 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 instances create projects](ProjectLocationInstanceCreateCall) (request)
|
||
/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
|
||
/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Instance {
|
||
/// The storage capacity of the instance in gigabytes (GB = 1024^3 bytes). This capacity can be increased up to `max_capacity_gb` GB in multipliers of `capacity_step_size_gb` GB.
|
||
#[serde(rename="capacityGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub capacity_gb: Option<i64>,
|
||
/// Output only. The increase/decrease capacity step size.
|
||
#[serde(rename="capacityStepSizeGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub capacity_step_size_gb: Option<i64>,
|
||
/// Output only. The time when the instance was created.
|
||
#[serde(rename="createTime")]
|
||
|
||
pub create_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
||
/// The description of the instance (2048 characters or less).
|
||
|
||
pub description: Option<String>,
|
||
/// Server-specified ETag for the instance resource to prevent simultaneous updates from overwriting each other.
|
||
|
||
pub etag: Option<String>,
|
||
/// File system shares on the instance. For this version, only a single file share is supported.
|
||
#[serde(rename="fileShares")]
|
||
|
||
pub file_shares: Option<Vec<FileShareConfig>>,
|
||
/// KMS key name used for data encryption.
|
||
#[serde(rename="kmsKeyName")]
|
||
|
||
pub kms_key_name: Option<String>,
|
||
/// Resource labels to represent user provided metadata.
|
||
|
||
pub labels: Option<HashMap<String, String>>,
|
||
/// Output only. The max capacity of the instance.
|
||
#[serde(rename="maxCapacityGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub max_capacity_gb: Option<i64>,
|
||
/// Output only. The max number of shares allowed.
|
||
#[serde(rename="maxShareCount")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub max_share_count: Option<i64>,
|
||
/// Indicates whether this instance uses a multi-share configuration with which it can have more than one file-share or none at all. File-shares are added, updated and removed through the separate file-share APIs.
|
||
#[serde(rename="multiShareEnabled")]
|
||
|
||
pub multi_share_enabled: Option<bool>,
|
||
/// Output only. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
|
||
|
||
pub name: Option<String>,
|
||
/// VPC networks to which the instance is connected. For this version, only a single network is supported.
|
||
|
||
pub networks: Option<Vec<NetworkConfig>>,
|
||
/// Immutable. The protocol indicates the access protocol for all shares in the instance. This field is immutable and it cannot be changed after the instance has been created. Default value: `NFS_V3`.
|
||
|
||
pub protocol: Option<String>,
|
||
/// Output only. Reserved for future use.
|
||
#[serde(rename="satisfiesPzs")]
|
||
|
||
pub satisfies_pzs: Option<bool>,
|
||
/// Output only. The instance state.
|
||
|
||
pub state: Option<String>,
|
||
/// Output only. Additional information about the instance state, if available.
|
||
#[serde(rename="statusMessage")]
|
||
|
||
pub status_message: Option<String>,
|
||
/// Output only. Field indicates all the reasons the instance is in "SUSPENDED" state.
|
||
#[serde(rename="suspensionReasons")]
|
||
|
||
pub suspension_reasons: Option<Vec<String>>,
|
||
/// The service tier of the instance.
|
||
|
||
pub tier: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for Instance {}
|
||
impl client::ResponseResult for Instance {}
|
||
|
||
|
||
/// ListBackupsResponse is the result of ListBackupsRequest.
|
||
///
|
||
/// # 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 backups list projects](ProjectLocationBackupListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListBackupsResponse {
|
||
/// A list of backups in the project for the specified location. If the `{location}` value in the request is "-", the response contains a list of backups from all locations. If any location is unreachable, the response will only return backups in reachable locations and the "unreachable" field will be populated with a list of unreachable locations.
|
||
|
||
pub backups: Option<Vec<Backup>>,
|
||
/// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
/// Locations that could not be reached.
|
||
|
||
pub unreachable: Option<Vec<String>>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListBackupsResponse {}
|
||
|
||
|
||
/// ListInstancesResponse is the result of ListInstancesRequest.
|
||
///
|
||
/// # 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 instances list projects](ProjectLocationInstanceListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListInstancesResponse {
|
||
/// A list of instances in the project for the specified location. If the `{location}` value in the request is "-", the response contains a list of instances from all locations. If any location is unreachable, the response will only return instances in reachable locations and the "unreachable" field will be populated with a list of unreachable locations.
|
||
|
||
pub instances: Option<Vec<Instance>>,
|
||
/// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
/// Locations that could not be reached.
|
||
|
||
pub unreachable: Option<Vec<String>>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListInstancesResponse {}
|
||
|
||
|
||
/// 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](ProjectLocationListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListLocationsResponse {
|
||
/// A list of locations that matches the specified filter in the request.
|
||
|
||
pub locations: Option<Vec<Location>>,
|
||
/// The standard List next-page token.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListLocationsResponse {}
|
||
|
||
|
||
/// The response message for Operations.ListOperations.
|
||
///
|
||
/// # Activities
|
||
///
|
||
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
||
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
||
///
|
||
/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListOperationsResponse {
|
||
/// The standard List next-page token.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
/// A list of operations that matches the specified filter in the request.
|
||
|
||
pub operations: Option<Vec<Operation>>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListOperationsResponse {}
|
||
|
||
|
||
/// ListSharesResponse is the result of ListSharesRequest.
|
||
///
|
||
/// # 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 instances shares list projects](ProjectLocationInstanceShareListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListSharesResponse {
|
||
/// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
/// A list of shares in the project for the specified instance.
|
||
|
||
pub shares: Option<Vec<Share>>,
|
||
/// Locations that could not be reached.
|
||
|
||
pub unreachable: Option<Vec<String>>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListSharesResponse {}
|
||
|
||
|
||
/// ListSnapshotsResponse is the result of ListSnapshotsRequest.
|
||
///
|
||
/// # 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 instances snapshots list projects](ProjectLocationInstanceSnapshotListCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct ListSnapshotsResponse {
|
||
/// The token you can use to retrieve the next page of results. Not returned if there are no more results in the list.
|
||
#[serde(rename="nextPageToken")]
|
||
|
||
pub next_page_token: Option<String>,
|
||
/// A list of snapshots in the project for the specified instance.
|
||
|
||
pub snapshots: Option<Vec<Snapshot>>,
|
||
}
|
||
|
||
impl client::ResponseResult for ListSnapshotsResponse {}
|
||
|
||
|
||
/// 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](ProjectLocationGetCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Location {
|
||
/// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
|
||
#[serde(rename="displayName")]
|
||
|
||
pub display_name: Option<String>,
|
||
/// 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>,
|
||
/// Service-specific metadata. For example the available capacity at the given location.
|
||
|
||
pub metadata: Option<HashMap<String, json::Value>>,
|
||
/// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
|
||
|
||
pub name: Option<String>,
|
||
}
|
||
|
||
impl client::ResponseResult for Location {}
|
||
|
||
|
||
/// Network configuration for the instance.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct NetworkConfig {
|
||
/// The network connect mode of the Filestore instance. If not provided, the connect mode defaults to DIRECT_PEERING.
|
||
#[serde(rename="connectMode")]
|
||
|
||
pub connect_mode: Option<String>,
|
||
/// Output only. IPv4 addresses in the format `{octet1}.{octet2}.{octet3}.{octet4}` or IPv6 addresses in the format `{block1}:{block2}:{block3}:{block4}:{block5}:{block6}:{block7}:{block8}`.
|
||
#[serde(rename="ipAddresses")]
|
||
|
||
pub ip_addresses: Option<Vec<String>>,
|
||
/// Internet protocol versions for which the instance has IP addresses assigned. For this version, only MODE_IPV4 is supported.
|
||
|
||
pub modes: Option<Vec<String>>,
|
||
/// The name of the Google Compute Engine [VPC network](https://cloud.google.com/vpc/docs/vpc) to which the instance is connected.
|
||
|
||
pub network: Option<String>,
|
||
/// Optional, reserved_ip_range can have one of the following two types of values. * CIDR range value when using DIRECT_PEERING connect mode. * [Allocated IP address range](https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address) when using PRIVATE_SERVICE_ACCESS connect mode. When the name of an allocated IP address range is specified, it must be one of the ranges associated with the private service access connection. When specified as a direct CIDR value, it must be a /29 CIDR block for Basic tier, a /24 CIDR block for High Scale tier, or a /26 CIDR block for Enterprise tier in one of the [internal IP address ranges](https://www.arin.net/reference/research/statistics/address_filters/) that identifies the range of IP addresses reserved for this instance. For example, 10.0.0.0/29, 192.168.0.0/24, or 192.168.0.0/26, respectively. The range you specify can't overlap with either existing subnets or assigned IP address ranges for other Filestore instances in the selected VPC network.
|
||
#[serde(rename="reservedIpRange")]
|
||
|
||
pub reserved_ip_range: Option<String>,
|
||
}
|
||
|
||
impl client::Part for NetworkConfig {}
|
||
|
||
|
||
/// NFS export options specifications.
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct NfsExportOptions {
|
||
/// Either READ_ONLY, for allowing only read requests on the exported directory, or READ_WRITE, for allowing both read and write requests. The default is READ_WRITE.
|
||
#[serde(rename="accessMode")]
|
||
|
||
pub access_mode: Option<String>,
|
||
/// An integer representing the anonymous group id with a default value of 65534. Anon_gid may only be set with squash_mode of ROOT_SQUASH. An error will be returned if this field is specified for other squash_mode settings.
|
||
#[serde(rename="anonGid")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub anon_gid: Option<i64>,
|
||
/// An integer representing the anonymous user id with a default value of 65534. Anon_uid may only be set with squash_mode of ROOT_SQUASH. An error will be returned if this field is specified for other squash_mode settings.
|
||
#[serde(rename="anonUid")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub anon_uid: Option<i64>,
|
||
/// List of either an IPv4 addresses in the format `{octet1}.{octet2}.{octet3}.{octet4}` or CIDR ranges in the format `{octet1}.{octet2}.{octet3}.{octet4}/{mask size}` which may mount the file share. Overlapping IP ranges are not allowed, both within and across NfsExportOptions. An error will be returned. The limit is 64 IP ranges/addresses for each FileShareConfig among all NfsExportOptions.
|
||
#[serde(rename="ipRanges")]
|
||
|
||
pub ip_ranges: Option<Vec<String>>,
|
||
/// Either NO_ROOT_SQUASH, for allowing root access on the exported directory, or ROOT_SQUASH, for not allowing root access. The default is NO_ROOT_SQUASH.
|
||
#[serde(rename="squashMode")]
|
||
|
||
pub squash_mode: Option<String>,
|
||
}
|
||
|
||
impl client::Part for NfsExportOptions {}
|
||
|
||
|
||
/// This resource represents a long-running operation that is the result of a network API call.
|
||
///
|
||
/// # Activities
|
||
///
|
||
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
||
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
||
///
|
||
/// * [locations backups create projects](ProjectLocationBackupCreateCall) (response)
|
||
/// * [locations backups delete projects](ProjectLocationBackupDeleteCall) (response)
|
||
/// * [locations backups patch projects](ProjectLocationBackupPatchCall) (response)
|
||
/// * [locations instances shares create projects](ProjectLocationInstanceShareCreateCall) (response)
|
||
/// * [locations instances shares delete projects](ProjectLocationInstanceShareDeleteCall) (response)
|
||
/// * [locations instances shares patch projects](ProjectLocationInstanceSharePatchCall) (response)
|
||
/// * [locations instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (response)
|
||
/// * [locations instances snapshots delete projects](ProjectLocationInstanceSnapshotDeleteCall) (response)
|
||
/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (response)
|
||
/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
|
||
/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
|
||
/// * [locations instances patch projects](ProjectLocationInstancePatchCall) (response)
|
||
/// * [locations instances restore projects](ProjectLocationInstanceRestoreCall) (response)
|
||
/// * [locations instances revert projects](ProjectLocationInstanceRevertCall) (response)
|
||
/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Operation {
|
||
/// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
|
||
|
||
pub done: Option<bool>,
|
||
/// The error result of the operation in case of failure or cancellation.
|
||
|
||
pub error: Option<Status>,
|
||
/// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
|
||
|
||
pub metadata: Option<HashMap<String, json::Value>>,
|
||
/// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
|
||
|
||
pub name: Option<String>,
|
||
/// The normal response of the operation in case of success. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
|
||
|
||
pub response: Option<HashMap<String, json::Value>>,
|
||
}
|
||
|
||
impl client::ResponseResult for Operation {}
|
||
|
||
|
||
/// RestoreInstanceRequest restores an existing instance’s file share from a backup.
|
||
///
|
||
/// # 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 instances restore projects](ProjectLocationInstanceRestoreCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct RestoreInstanceRequest {
|
||
/// Required. Name of the file share in the Filestore instance that the backup is being restored to.
|
||
#[serde(rename="fileShare")]
|
||
|
||
pub file_share: Option<String>,
|
||
/// The resource name of the backup, in the format `projects/{project_id}/locations/{location_id}/backups/{backup_id}`.
|
||
#[serde(rename="sourceBackup")]
|
||
|
||
pub source_backup: Option<String>,
|
||
/// The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/snapshots/{snapshot_id}`.
|
||
#[serde(rename="sourceSnapshot")]
|
||
|
||
pub source_snapshot: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for RestoreInstanceRequest {}
|
||
|
||
|
||
/// RevertInstanceRequest reverts the given instance’s file share to the specified snapshot.
|
||
///
|
||
/// # 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 instances revert projects](ProjectLocationInstanceRevertCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct RevertInstanceRequest {
|
||
/// Required. The snapshot resource ID, in the format 'my-snapshot', where the specified ID is the {snapshot_id} of the fully qualified name like projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}
|
||
#[serde(rename="targetSnapshotId")]
|
||
|
||
pub target_snapshot_id: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for RevertInstanceRequest {}
|
||
|
||
|
||
/// A Filestore share.
|
||
///
|
||
/// # 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 instances shares create projects](ProjectLocationInstanceShareCreateCall) (request)
|
||
/// * [locations instances shares get projects](ProjectLocationInstanceShareGetCall) (response)
|
||
/// * [locations instances shares patch projects](ProjectLocationInstanceSharePatchCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Share {
|
||
/// File share capacity in gigabytes (GB). Filestore defines 1 GB as 1024^3 bytes. Must be greater than 0.
|
||
#[serde(rename="capacityGb")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub capacity_gb: Option<i64>,
|
||
/// Output only. The time when the share was created.
|
||
#[serde(rename="createTime")]
|
||
|
||
pub create_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
||
/// A description of the share with 2048 characters or less. Requests with longer descriptions will be rejected.
|
||
|
||
pub description: Option<String>,
|
||
/// Resource labels to represent user provided metadata.
|
||
|
||
pub labels: Option<HashMap<String, String>>,
|
||
/// The mount name of the share. Must be 63 characters or less and consist of uppercase or lowercase letters, numbers, and underscores.
|
||
#[serde(rename="mountName")]
|
||
|
||
pub mount_name: Option<String>,
|
||
/// Output only. The resource name of the share, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/shares/{share_id}`.
|
||
|
||
pub name: Option<String>,
|
||
/// Nfs Export Options. There is a limit of 10 export options per file share.
|
||
#[serde(rename="nfsExportOptions")]
|
||
|
||
pub nfs_export_options: Option<Vec<NfsExportOptions>>,
|
||
/// Output only. The share state.
|
||
|
||
pub state: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for Share {}
|
||
impl client::ResponseResult for Share {}
|
||
|
||
|
||
/// A Filestore snapshot.
|
||
///
|
||
/// # 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 instances snapshots create projects](ProjectLocationInstanceSnapshotCreateCall) (request)
|
||
/// * [locations instances snapshots get projects](ProjectLocationInstanceSnapshotGetCall) (response)
|
||
/// * [locations instances snapshots patch projects](ProjectLocationInstanceSnapshotPatchCall) (request)
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Snapshot {
|
||
/// Output only. The time when the snapshot was created.
|
||
#[serde(rename="createTime")]
|
||
|
||
pub create_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
|
||
/// A description of the snapshot with 2048 characters or less. Requests with longer descriptions will be rejected.
|
||
|
||
pub description: Option<String>,
|
||
/// Output only. The amount of bytes needed to allocate a full copy of the snapshot content
|
||
#[serde(rename="filesystemUsedBytes")]
|
||
|
||
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
|
||
pub filesystem_used_bytes: Option<i64>,
|
||
/// Resource labels to represent user provided metadata.
|
||
|
||
pub labels: Option<HashMap<String, String>>,
|
||
/// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
|
||
|
||
pub name: Option<String>,
|
||
/// Output only. The snapshot state.
|
||
|
||
pub state: Option<String>,
|
||
}
|
||
|
||
impl client::RequestValue for Snapshot {}
|
||
impl client::ResponseResult for Snapshot {}
|
||
|
||
|
||
/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
|
||
///
|
||
/// This type is not used in any activity, and only used as *part* of another schema.
|
||
///
|
||
#[serde_with::serde_as(crate = "::client::serde_with")]
|
||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||
pub struct Status {
|
||
/// The status code, which should be an enum value of google.rpc.Code.
|
||
|
||
pub code: Option<i32>,
|
||
/// A list of messages that carry the error details. There is a common set of message types for APIs to use.
|
||
|
||
pub details: Option<Vec<HashMap<String, json::Value>>>,
|
||
/// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
|
||
|
||
pub message: Option<String>,
|
||
}
|
||
|
||
impl client::Part for Status {}
|
||
|
||
|
||
|
||
// ###################
|
||
// MethodBuilders ###
|
||
// #################
|
||
|
||
/// A builder providing access to all methods supported on *project* resources.
|
||
/// It is not used directly, but through the [`CloudFilestore`] hub.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// extern crate hyper;
|
||
/// extern crate hyper_rustls;
|
||
/// extern crate google_file1_beta1 as file1_beta1;
|
||
///
|
||
/// # async fn dox() {
|
||
/// use std::default::Default;
|
||
/// use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// secret,
|
||
/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// ).build().await.unwrap();
|
||
/// let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
|
||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||
/// // like `locations_backups_create(...)`, `locations_backups_delete(...)`, `locations_backups_get(...)`, `locations_backups_list(...)`, `locations_backups_patch(...)`, `locations_get(...)`, `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_get(...)`, `locations_instances_list(...)`, `locations_instances_patch(...)`, `locations_instances_restore(...)`, `locations_instances_revert(...)`, `locations_instances_shares_create(...)`, `locations_instances_shares_delete(...)`, `locations_instances_shares_get(...)`, `locations_instances_shares_list(...)`, `locations_instances_shares_patch(...)`, `locations_instances_snapshots_create(...)`, `locations_instances_snapshots_delete(...)`, `locations_instances_snapshots_get(...)`, `locations_instances_snapshots_list(...)`, `locations_instances_snapshots_patch(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
|
||
/// // to build up your call.
|
||
/// let rb = hub.projects();
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectMethods<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
}
|
||
|
||
impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
|
||
|
||
impl<'a, S> ProjectMethods<'a, S> {
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a backup.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The backup's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**.
|
||
pub fn locations_backups_create(&self, request: Backup, parent: &str) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
ProjectLocationBackupCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_backup_id: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a backup.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The backup resource name, in the format `projects/{project_id}/locations/{location}/backups/{backup_id}`
|
||
pub fn locations_backups_delete(&self, name: &str) -> ProjectLocationBackupDeleteCall<'a, S> {
|
||
ProjectLocationBackupDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a specific backup.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The backup resource name, in the format `projects/{project_id}/locations/{location}/backups/{backup_id}`.
|
||
pub fn locations_backups_get(&self, name: &str) -> ProjectLocationBackupGetCall<'a, S> {
|
||
ProjectLocationBackupGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists all backups in a project for either a specified location or for all locations.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The project and location for which to retrieve backup information, in the format `projects/{project_id}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**. To retrieve backup information for all locations, use "-" for the `{location}` value.
|
||
pub fn locations_backups_list(&self, parent: &str) -> ProjectLocationBackupListCall<'a, S> {
|
||
ProjectLocationBackupListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_order_by: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates the settings of a specific backup.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Output only. The resource name of the backup, in the format `projects/{project_id}/locations/{location_id}/backups/{backup_id}`.
|
||
pub fn locations_backups_patch(&self, request: Backup, name: &str) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
ProjectLocationBackupPatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_update_mask: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a share.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The Filestore Instance to create the share for, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
pub fn locations_instances_shares_create(&self, request: Share, parent: &str) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
ProjectLocationInstanceShareCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_share_id: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a share.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The share resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/share/{share_id}`
|
||
pub fn locations_instances_shares_delete(&self, name: &str) -> ProjectLocationInstanceShareDeleteCall<'a, S> {
|
||
ProjectLocationInstanceShareDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a specific share.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The share resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/shares/{share_id}`
|
||
pub fn locations_instances_shares_get(&self, name: &str) -> ProjectLocationInstanceShareGetCall<'a, S> {
|
||
ProjectLocationInstanceShareGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists all shares for a specified instance.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The instance for which to retrieve share information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
pub fn locations_instances_shares_list(&self, parent: &str) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
ProjectLocationInstanceShareListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_order_by: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates the settings of a specific share.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Output only. The resource name of the share, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/shares/{share_id}`.
|
||
pub fn locations_instances_shares_patch(&self, request: Share, name: &str) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
ProjectLocationInstanceSharePatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_update_mask: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates a snapshot.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
pub fn locations_instances_snapshots_create(&self, request: Snapshot, parent: &str) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
ProjectLocationInstanceSnapshotCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_snapshot_id: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a snapshot.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
|
||
pub fn locations_instances_snapshots_delete(&self, name: &str) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S> {
|
||
ProjectLocationInstanceSnapshotDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a specific snapshot.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
|
||
pub fn locations_instances_snapshots_get(&self, name: &str) -> ProjectLocationInstanceSnapshotGetCall<'a, S> {
|
||
ProjectLocationInstanceSnapshotGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists all snapshots in a project for either a specified location or for all locations.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
pub fn locations_instances_snapshots_list(&self, parent: &str) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
ProjectLocationInstanceSnapshotListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_order_by: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates the settings of a specific snapshot.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
|
||
pub fn locations_instances_snapshots_patch(&self, request: Snapshot, name: &str) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
ProjectLocationInstanceSnapshotPatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_update_mask: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Creates an instance. When creating from a backup, the capacity of the new instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `parent` - Required. The instance's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, locations map to Google Cloud zones, for example **us-west1-b**.
|
||
pub fn locations_instances_create(&self, request: Instance, parent: &str) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
ProjectLocationInstanceCreateCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_parent: parent.to_string(),
|
||
_instance_id: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes an instance.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
pub fn locations_instances_delete(&self, name: &str) -> ProjectLocationInstanceDeleteCall<'a, S> {
|
||
ProjectLocationInstanceDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_force: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the details of a specific instance.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, S> {
|
||
ProjectLocationInstanceGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists all instances in a project for either a specified location or for all locations.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `parent` - Required. The project and location for which to retrieve instance information, in the format `projects/{project_id}/locations/{location}`. In Cloud Filestore, locations map to Google Cloud zones, for example **us-west1-b**. To retrieve instance information for all locations, use "-" for the `{location}` value.
|
||
pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, S> {
|
||
ProjectLocationInstanceListCall {
|
||
hub: self.hub,
|
||
_parent: parent.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_order_by: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Updates the settings of a specific instance.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Output only. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
|
||
pub fn locations_instances_patch(&self, request: Instance, name: &str) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
ProjectLocationInstancePatchCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_update_mask: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Restores an existing instance's file share from a backup. The capacity of the instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
|
||
pub fn locations_instances_restore(&self, request: RestoreInstanceRequest, name: &str) -> ProjectLocationInstanceRestoreCall<'a, S> {
|
||
ProjectLocationInstanceRestoreCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Revert an existing instance's file system to a specified snapshot.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - Required. projects/{project_id}/locations/{location_id}/instances/{instance_id}. The resource name of the instance, in the format
|
||
pub fn locations_instances_revert(&self, request: RevertInstanceRequest, name: &str) -> ProjectLocationInstanceRevertCall<'a, S> {
|
||
ProjectLocationInstanceRevertCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `request` - No description provided.
|
||
/// * `name` - The name of the operation resource to be cancelled.
|
||
pub fn locations_operations_cancel(&self, request: CancelOperationRequest, name: &str) -> ProjectLocationOperationCancelCall<'a, S> {
|
||
ProjectLocationOperationCancelCall {
|
||
hub: self.hub,
|
||
_request: request,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - The name of the operation resource to be deleted.
|
||
pub fn locations_operations_delete(&self, name: &str) -> ProjectLocationOperationDeleteCall<'a, S> {
|
||
ProjectLocationOperationDeleteCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - The name of the operation resource.
|
||
pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, S> {
|
||
ProjectLocationOperationGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - The name of the operation's parent resource.
|
||
pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, S> {
|
||
ProjectLocationOperationListCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
|
||
/// Create a builder to help you perform the following task:
|
||
///
|
||
/// Gets information about a location.
|
||
///
|
||
/// # Arguments
|
||
///
|
||
/// * `name` - Resource name for the location.
|
||
pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, S> {
|
||
ProjectLocationGetCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: 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, S> {
|
||
ProjectLocationListCall {
|
||
hub: self.hub,
|
||
_name: name.to_string(),
|
||
_page_token: Default::default(),
|
||
_page_size: Default::default(),
|
||
_include_unrevealed_locations: Default::default(),
|
||
_filter: Default::default(),
|
||
_delegate: Default::default(),
|
||
_additional_params: Default::default(),
|
||
_scopes: Default::default(),
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ###################
|
||
// CallBuilders ###
|
||
// #################
|
||
|
||
/// Creates a backup.
|
||
///
|
||
/// A builder for the *locations.backups.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Backup;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Backup::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_backups_create(req, "parent")
|
||
/// .backup_id("sed")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationBackupCreateCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Backup,
|
||
_parent: String,
|
||
_backup_id: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationBackupCreateCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationBackupCreateCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.backups.create",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "parent", "backupId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._backup_id.as_ref() {
|
||
params.push("backupId", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/backups";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The backup's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**.
|
||
///
|
||
/// 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) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The ID to use for the backup. The ID must be unique within the specified project and location. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
|
||
///
|
||
/// Sets the *backup id* query property to the given value.
|
||
pub fn backup_id(mut self, new_value: &str) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
self._backup_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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupCreateCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationBackupCreateCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupCreateCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationBackupCreateCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a backup.
|
||
///
|
||
/// A builder for the *locations.backups.delete* method supported by a *project* resource.
|
||
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_backups_delete("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationBackupDeleteCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationBackupDeleteCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationBackupDeleteCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.backups.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::DELETE)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The backup resource name, in the format `projects/{project_id}/locations/{location}/backups/{backup_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationBackupDeleteCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationBackupDeleteCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupDeleteCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationBackupDeleteCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupDeleteCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationBackupDeleteCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets the details of a specific backup.
|
||
///
|
||
/// A builder for the *locations.backups.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_backups_get("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationBackupGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationBackupGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationBackupGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Backup)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.backups.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The backup resource name, in the format `projects/{project_id}/locations/{location}/backups/{backup_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationBackupGetCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationBackupGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationBackupGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationBackupGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Lists all backups in a project for either a specified location or for all locations.
|
||
///
|
||
/// A builder for the *locations.backups.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_backups_list("parent")
|
||
/// .page_token("duo")
|
||
/// .page_size(-55)
|
||
/// .order_by("gubergren")
|
||
/// .filter("Lorem")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationBackupListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_order_by: Option<String>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationBackupListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationBackupListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListBackupsResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.backups.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "parent", "pageToken", "pageSize", "orderBy", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(7 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._order_by.as_ref() {
|
||
params.push("orderBy", value);
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/backups";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The project and location for which to retrieve backup information, in the format `projects/{project_id}/locations/{location}`. In Filestore, backup locations map to Google Cloud regions, for example **us-west1**. To retrieve backup information for all locations, use "-" for the `{location}` value.
|
||
///
|
||
/// 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) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// The next_page_token value to use if there are additional results to retrieve for this list request.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of items to return.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._page_size = Some(new_value);
|
||
self
|
||
}
|
||
/// Sort results. Supported values are "name", "name desc" or "" (unsorted).
|
||
///
|
||
/// Sets the *order by* query property to the given value.
|
||
pub fn order_by(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._order_by = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// List filter.
|
||
///
|
||
/// Sets the *filter* query property to the given value.
|
||
pub fn filter(mut self, new_value: &str) -> ProjectLocationBackupListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationBackupListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationBackupListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates the settings of a specific backup.
|
||
///
|
||
/// A builder for the *locations.backups.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Backup;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Backup::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_backups_patch(req, "name")
|
||
/// .update_mask(&Default::default())
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationBackupPatchCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Backup,
|
||
_name: String,
|
||
_update_mask: Option<client::FieldMask>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationBackupPatchCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationBackupPatchCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.backups.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
|
||
for &field in ["alt", "name", "updateMask"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._update_mask.as_ref() {
|
||
params.push("updateMask", value.to_string());
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::PATCH)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Backup) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Output only. The resource name of the backup, in the format `projects/{project_id}/locations/{location_id}/backups/{backup_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. Mask of fields to update. At least one path must be supplied in this field.
|
||
///
|
||
/// Sets the *update mask* query property to the given value.
|
||
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
self._update_mask = 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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBackupPatchCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationBackupPatchCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBackupPatchCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationBackupPatchCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Creates a share.
|
||
///
|
||
/// A builder for the *locations.instances.shares.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Share;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Share::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_instances_shares_create(req, "parent")
|
||
/// .share_id("dolor")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceShareCreateCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Share,
|
||
_parent: String,
|
||
_share_id: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceShareCreateCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceShareCreateCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.shares.create",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "parent", "shareId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._share_id.as_ref() {
|
||
params.push("shareId", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/shares";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Share) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The Filestore Instance to create the share for, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
///
|
||
/// Sets the *parent* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The ID to use for the share. The ID must be unique within the specified instance. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
|
||
///
|
||
/// Sets the *share id* query property to the given value.
|
||
pub fn share_id(mut self, new_value: &str) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
self._share_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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceShareCreateCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceShareCreateCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceShareCreateCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceShareCreateCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a share.
|
||
///
|
||
/// A builder for the *locations.instances.shares.delete* method supported by a *project* resource.
|
||
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_shares_delete("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceShareDeleteCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceShareDeleteCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceShareDeleteCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.shares.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::DELETE)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The share resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/share/{share_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceShareDeleteCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceShareDeleteCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceShareDeleteCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceShareDeleteCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceShareDeleteCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceShareDeleteCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets the details of a specific share.
|
||
///
|
||
/// A builder for the *locations.instances.shares.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_shares_get("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceShareGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceShareGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceShareGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Share)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.shares.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The share resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/shares/{share_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceShareGetCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceShareGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceShareGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceShareGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceShareGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceShareGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Lists all shares for a specified instance.
|
||
///
|
||
/// A builder for the *locations.instances.shares.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_shares_list("parent")
|
||
/// .page_token("amet")
|
||
/// .page_size(-20)
|
||
/// .order_by("ipsum")
|
||
/// .filter("sed")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceShareListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_order_by: Option<String>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceShareListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceShareListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListSharesResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.shares.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "parent", "pageToken", "pageSize", "orderBy", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(7 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._order_by.as_ref() {
|
||
params.push("orderBy", value);
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/shares";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The instance for which to retrieve share information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
///
|
||
/// Sets the *parent* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// The next_page_token value to use if there are additional results to retrieve for this list request.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of items to return.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._page_size = Some(new_value);
|
||
self
|
||
}
|
||
/// Sort results. Supported values are "name", "name desc" or "" (unsorted).
|
||
///
|
||
/// Sets the *order by* query property to the given value.
|
||
pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._order_by = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// List filter.
|
||
///
|
||
/// Sets the *filter* query property to the given value.
|
||
pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceShareListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceShareListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceShareListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceShareListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates the settings of a specific share.
|
||
///
|
||
/// A builder for the *locations.instances.shares.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Share;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Share::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_instances_shares_patch(req, "name")
|
||
/// .update_mask(&Default::default())
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSharePatchCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Share,
|
||
_name: String,
|
||
_update_mask: Option<client::FieldMask>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSharePatchCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSharePatchCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.shares.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
|
||
for &field in ["alt", "name", "updateMask"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._update_mask.as_ref() {
|
||
params.push("updateMask", value.to_string());
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::PATCH)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Share) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Output only. The resource name of the share, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/shares/{share_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields: * "description" * "capacity_gb" * "labels" * "nfs_export_options"
|
||
///
|
||
/// Sets the *update mask* query property to the given value.
|
||
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
self._update_mask = 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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSharePatchCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSharePatchCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSharePatchCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSharePatchCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Creates a snapshot.
|
||
///
|
||
/// A builder for the *locations.instances.snapshots.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Snapshot;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Snapshot::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_instances_snapshots_create(req, "parent")
|
||
/// .snapshot_id("rebum.")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSnapshotCreateCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Snapshot,
|
||
_parent: String,
|
||
_snapshot_id: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSnapshotCreateCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSnapshotCreateCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.snapshots.create",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "parent", "snapshotId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._snapshot_id.as_ref() {
|
||
params.push("snapshotId", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/snapshots";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Snapshot) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The Filestore Instance to create the snapshots of, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
///
|
||
/// Sets the *parent* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The ID to use for the snapshot. The ID must be unique within the specified instance. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
|
||
///
|
||
/// Sets the *snapshot id* query property to the given value.
|
||
pub fn snapshot_id(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
self._snapshot_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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotCreateCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotCreateCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotCreateCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotCreateCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a snapshot.
|
||
///
|
||
/// A builder for the *locations.instances.snapshots.delete* method supported by a *project* resource.
|
||
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_snapshots_delete("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSnapshotDeleteCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSnapshotDeleteCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSnapshotDeleteCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.snapshots.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::DELETE)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotDeleteCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets the details of a specific snapshot.
|
||
///
|
||
/// A builder for the *locations.instances.snapshots.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_snapshots_get("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSnapshotGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSnapshotGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSnapshotGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Snapshot)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.snapshots.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The snapshot resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}/snapshots/{snapshot_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotGetCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSnapshotGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Lists all snapshots in a project for either a specified location or for all locations.
|
||
///
|
||
/// A builder for the *locations.instances.snapshots.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_snapshots_list("parent")
|
||
/// .page_token("est")
|
||
/// .page_size(-62)
|
||
/// .order_by("ea")
|
||
/// .filter("dolor")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSnapshotListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_order_by: Option<String>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSnapshotListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSnapshotListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListSnapshotsResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.snapshots.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "parent", "pageToken", "pageSize", "orderBy", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(7 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._order_by.as_ref() {
|
||
params.push("orderBy", value);
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/snapshots";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The instance for which to retrieve snapshot information, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
///
|
||
/// Sets the *parent* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// The next_page_token value to use if there are additional results to retrieve for this list request.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of items to return.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._page_size = Some(new_value);
|
||
self
|
||
}
|
||
/// Sort results. Supported values are "name", "name desc" or "" (unsorted).
|
||
///
|
||
/// Sets the *order by* query property to the given value.
|
||
pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._order_by = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// List filter.
|
||
///
|
||
/// Sets the *filter* query property to the given value.
|
||
pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates the settings of a specific snapshot.
|
||
///
|
||
/// A builder for the *locations.instances.snapshots.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Snapshot;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Snapshot::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_instances_snapshots_patch(req, "name")
|
||
/// .update_mask(&Default::default())
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceSnapshotPatchCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Snapshot,
|
||
_name: String,
|
||
_update_mask: Option<client::FieldMask>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceSnapshotPatchCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceSnapshotPatchCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.snapshots.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
|
||
for &field in ["alt", "name", "updateMask"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._update_mask.as_ref() {
|
||
params.push("updateMask", value.to_string());
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::PATCH)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Snapshot) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Output only. The resource name of the snapshot, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. Mask of fields to update. At least one path must be supplied in this field.
|
||
///
|
||
/// Sets the *update mask* query property to the given value.
|
||
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
self._update_mask = 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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSnapshotPatchCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceSnapshotPatchCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSnapshotPatchCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceSnapshotPatchCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Creates an instance. When creating from a backup, the capacity of the new instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
|
||
///
|
||
/// A builder for the *locations.instances.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Instance;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Instance::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_instances_create(req, "parent")
|
||
/// .instance_id("labore")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceCreateCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Instance,
|
||
_parent: String,
|
||
_instance_id: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceCreateCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceCreateCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.create",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "parent", "instanceId"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._instance_id.as_ref() {
|
||
params.push("instanceId", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/instances";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The instance's project and location, in the format `projects/{project_id}/locations/{location}`. In Filestore, locations map to Google Cloud zones, for example **us-west1-b**.
|
||
///
|
||
/// 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) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. The ID of the instance to create. The ID must be unique within the specified project and location. This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
|
||
///
|
||
/// Sets the *instance id* query property to the given value.
|
||
pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
self._instance_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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes an instance.
|
||
///
|
||
/// A builder for the *locations.instances.delete* method supported by a *project* resource.
|
||
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_delete("name")
|
||
/// .force(false)
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceDeleteCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_force: Option<bool>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceDeleteCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceDeleteCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
|
||
for &field in ["alt", "name", "force"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(4 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._force.as_ref() {
|
||
params.push("force", value.to_string());
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::DELETE)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// If set to true, any snapshots of the instance will also be deleted. (Otherwise, the request will only work if the instance has no snapshots.)
|
||
///
|
||
/// Sets the *force* query property to the given value.
|
||
pub fn force(mut self, new_value: bool) -> ProjectLocationInstanceDeleteCall<'a, S> {
|
||
self._force = 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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceDeleteCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets the details of a specific instance.
|
||
///
|
||
/// A builder for the *locations.instances.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_get("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Instance)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The instance resource name, in the format `projects/{project_id}/locations/{location}/instances/{instance_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Lists all instances in a project for either a specified location or for all locations.
|
||
///
|
||
/// A builder for the *locations.instances.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_instances_list("parent")
|
||
/// .page_token("Stet")
|
||
/// .page_size(-13)
|
||
/// .order_by("et")
|
||
/// .filter("sed")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_parent: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_order_by: Option<String>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListInstancesResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "parent", "pageToken", "pageSize", "orderBy", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(7 + self._additional_params.len());
|
||
params.push("parent", self._parent);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._order_by.as_ref() {
|
||
params.push("orderBy", value);
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/instances";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["parent"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// Required. The project and location for which to retrieve instance information, in the format `projects/{project_id}/locations/{location}`. In Cloud Filestore, locations map to Google Cloud zones, for example **us-west1-b**. To retrieve instance information for all locations, use "-" for the `{location}` value.
|
||
///
|
||
/// 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) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._parent = new_value.to_string();
|
||
self
|
||
}
|
||
/// The next_page_token value to use if there are additional results to retrieve for this list request.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of items to return.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._page_size = Some(new_value);
|
||
self
|
||
}
|
||
/// Sort results. Supported values are "name", "name desc" or "" (unsorted).
|
||
///
|
||
/// Sets the *order by* query property to the given value.
|
||
pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._order_by = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// List filter.
|
||
///
|
||
/// Sets the *filter* query property to the given value.
|
||
pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Updates the settings of a specific instance.
|
||
///
|
||
/// A builder for the *locations.instances.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::Instance;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = Instance::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_instances_patch(req, "name")
|
||
/// .update_mask(&Default::default())
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstancePatchCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: Instance,
|
||
_name: String,
|
||
_update_mask: Option<client::FieldMask>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstancePatchCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstancePatchCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.patch",
|
||
http_method: hyper::Method::PATCH });
|
||
|
||
for &field in ["alt", "name", "updateMask"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(5 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._update_mask.as_ref() {
|
||
params.push("updateMask", value.to_string());
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::PATCH)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: Instance) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Output only. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields: * "description" * "file_shares" * "labels"
|
||
///
|
||
/// Sets the *update mask* query property to the given value.
|
||
pub fn update_mask(mut self, new_value: client::FieldMask) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
self._update_mask = 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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstancePatchCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstancePatchCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstancePatchCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstancePatchCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Restores an existing instance's file share from a backup. The capacity of the instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).
|
||
///
|
||
/// A builder for the *locations.instances.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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::RestoreInstanceRequest;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = RestoreInstanceRequest::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_instances_restore(req, "name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceRestoreCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: RestoreInstanceRequest,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceRestoreCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceRestoreCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.restore",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(4 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:restore";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: RestoreInstanceRequest) -> ProjectLocationInstanceRestoreCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. The resource name of the instance, in the format `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRestoreCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceRestoreCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRestoreCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceRestoreCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRestoreCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceRestoreCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Revert an existing instance's file system to a specified snapshot.
|
||
///
|
||
/// A builder for the *locations.instances.revert* 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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::RevertInstanceRequest;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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 = RevertInstanceRequest::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_instances_revert(req, "name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationInstanceRevertCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: RevertInstanceRequest,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationInstanceRevertCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationInstanceRevertCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.instances.revert",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(4 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:revert";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: RevertInstanceRequest) -> ProjectLocationInstanceRevertCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// Required. projects/{project_id}/locations/{location_id}/instances/{instance_id}. The resource name of the instance, in the format
|
||
///
|
||
/// 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) -> ProjectLocationInstanceRevertCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationInstanceRevertCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRevertCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationInstanceRevertCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRevertCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationInstanceRevertCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
|
||
///
|
||
/// A builder for the *locations.operations.cancel* 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 google_file1_beta1 as file1_beta1;
|
||
/// use file1_beta1::api::CancelOperationRequest;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
|
||
/// // As the method needs a request, you would usually fill it with the desired information
|
||
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let mut req = CancelOperationRequest::default();
|
||
///
|
||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||
/// // execute the final call using `doit()`.
|
||
/// // Values shown here are possibly random and not representative !
|
||
/// let result = hub.projects().locations_operations_cancel(req, "name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationOperationCancelCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_request: CancelOperationRequest,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationOperationCancelCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationOperationCancelCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.operations.cancel",
|
||
http_method: hyper::Method::POST });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(4 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:cancel";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
let mut json_mime_type = mime::APPLICATION_JSON;
|
||
let mut request_value_reader =
|
||
{
|
||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||
client::remove_json_null_values(&mut value);
|
||
let mut dst = io::Cursor::new(Vec::with_capacity(128));
|
||
json::to_writer(&mut dst, &value).unwrap();
|
||
dst
|
||
};
|
||
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::POST)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.header(CONTENT_TYPE, json_mime_type.to_string())
|
||
.header(CONTENT_LENGTH, request_size as u64)
|
||
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
///
|
||
/// Sets the *request* property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn request(mut self, new_value: CancelOperationRequest) -> ProjectLocationOperationCancelCall<'a, S> {
|
||
self._request = new_value;
|
||
self
|
||
}
|
||
/// The name of the operation resource to be cancelled.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationOperationCancelCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
|
||
///
|
||
/// A builder for the *locations.operations.delete* method supported by a *project* resource.
|
||
/// It is not used directly, but through a [`ProjectMethods`] instance.
|
||
///
|
||
/// # Example
|
||
///
|
||
/// Instantiate a resource method builder
|
||
///
|
||
/// ```test_harness,no_run
|
||
/// # extern crate hyper;
|
||
/// # extern crate hyper_rustls;
|
||
/// # extern crate google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_operations_delete("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationOperationDeleteCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationOperationDeleteCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationOperationDeleteCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.operations.delete",
|
||
http_method: hyper::Method::DELETE });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::DELETE)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The name of the operation resource to be deleted.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationOperationDeleteCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
|
||
///
|
||
/// A builder for the *locations.operations.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_operations_get("name")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationOperationGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationOperationGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationOperationGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Operation)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.operations.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The name of the operation resource.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationOperationGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`. NOTE: the `name` binding allows API services to override the binding to use different resource name schemes, such as `users/*/operations`. To override the binding, API services can add a binding such as `"/v1/{name=users/*}/operations"` to their service configuration. For backwards compatibility, the default name includes the operations collection id, however overriding users must ensure the name binding is the parent resource, without the operations collection id.
|
||
///
|
||
/// A builder for the *locations.operations.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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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_operations_list("name")
|
||
/// .page_token("et")
|
||
/// .page_size(-28)
|
||
/// .filter("amet.")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationOperationListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationOperationListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationOperationListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListOperationsResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.operations.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(6 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/operations";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// The name of the operation's parent resource.
|
||
///
|
||
/// Sets the *name* path property to the given value.
|
||
///
|
||
/// Even though the property as already been set when instantiating this call,
|
||
/// we provide this method for API completeness.
|
||
pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, S> {
|
||
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) -> ProjectLocationOperationListCall<'a, S> {
|
||
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) -> ProjectLocationOperationListCall<'a, S> {
|
||
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) -> ProjectLocationOperationListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationOperationListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|
||
/// Gets 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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationGetCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationGetCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationGetCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Location)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.get",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(3 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// 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, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationGetCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, S> {
|
||
self._scopes.clear();
|
||
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 google_file1_beta1 as file1_beta1;
|
||
/// # async fn dox() {
|
||
/// # use std::default::Default;
|
||
/// # use file1_beta1::{CloudFilestore, oauth2, hyper, hyper_rustls, chrono, FieldMask};
|
||
///
|
||
/// # let secret: oauth2::ApplicationSecret = Default::default();
|
||
/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
|
||
/// # secret,
|
||
/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
||
/// # ).build().await.unwrap();
|
||
/// # let mut hub = CloudFilestore::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), 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("dolor")
|
||
/// .page_size(-18)
|
||
/// .include_unrevealed_locations(false)
|
||
/// .filter("Stet")
|
||
/// .doit().await;
|
||
/// # }
|
||
/// ```
|
||
pub struct ProjectLocationListCall<'a, S>
|
||
where S: 'a {
|
||
|
||
hub: &'a CloudFilestore<S>,
|
||
_name: String,
|
||
_page_token: Option<String>,
|
||
_page_size: Option<i32>,
|
||
_include_unrevealed_locations: Option<bool>,
|
||
_filter: Option<String>,
|
||
_delegate: Option<&'a mut dyn client::Delegate>,
|
||
_additional_params: HashMap<String, String>,
|
||
_scopes: BTreeSet<String>
|
||
}
|
||
|
||
impl<'a, S> client::CallBuilder for ProjectLocationListCall<'a, S> {}
|
||
|
||
impl<'a, S> ProjectLocationListCall<'a, S>
|
||
where
|
||
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
|
||
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
|
||
S::Future: Send + Unpin + 'static,
|
||
S::Error: Into<Box<dyn StdError + Send + Sync>>,
|
||
{
|
||
|
||
|
||
/// Perform the operation you have build so far.
|
||
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListLocationsResponse)> {
|
||
use std::io::{Read, Seek};
|
||
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
|
||
use client::{ToParts, url::Params};
|
||
use std::borrow::Cow;
|
||
|
||
let mut dd = client::DefaultDelegate;
|
||
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
|
||
dlg.begin(client::MethodInfo { id: "file.projects.locations.list",
|
||
http_method: hyper::Method::GET });
|
||
|
||
for &field in ["alt", "name", "pageToken", "pageSize", "includeUnrevealedLocations", "filter"].iter() {
|
||
if self._additional_params.contains_key(field) {
|
||
dlg.finished(false);
|
||
return Err(client::Error::FieldClash(field));
|
||
}
|
||
}
|
||
|
||
let mut params = Params::with_capacity(7 + self._additional_params.len());
|
||
params.push("name", self._name);
|
||
if let Some(value) = self._page_token.as_ref() {
|
||
params.push("pageToken", value);
|
||
}
|
||
if let Some(value) = self._page_size.as_ref() {
|
||
params.push("pageSize", value.to_string());
|
||
}
|
||
if let Some(value) = self._include_unrevealed_locations.as_ref() {
|
||
params.push("includeUnrevealedLocations", value.to_string());
|
||
}
|
||
if let Some(value) = self._filter.as_ref() {
|
||
params.push("filter", value);
|
||
}
|
||
|
||
params.extend(self._additional_params.iter());
|
||
|
||
params.push("alt", "json");
|
||
let mut url = self.hub._base_url.clone() + "v1beta1/{+name}/locations";
|
||
if self._scopes.is_empty() {
|
||
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
|
||
}
|
||
|
||
for &(find_this, param_name) in [("{+name}", "name")].iter() {
|
||
url = params.uri_replacement(url, param_name, find_this, true);
|
||
}
|
||
{
|
||
let to_remove = ["name"];
|
||
params.remove_params(&to_remove);
|
||
}
|
||
|
||
let url = params.parse_with_url(&url);
|
||
|
||
|
||
|
||
loop {
|
||
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
match dlg.token(e) {
|
||
Ok(token) => token,
|
||
Err(e) => {
|
||
dlg.finished(false);
|
||
return Err(client::Error::MissingToken(e));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
let mut req_result = {
|
||
let client = &self.hub.client;
|
||
dlg.pre_request();
|
||
let mut req_builder = hyper::Request::builder()
|
||
.method(hyper::Method::GET)
|
||
.uri(url.as_str())
|
||
.header(USER_AGENT, self.hub._user_agent.clone());
|
||
|
||
if let Some(token) = token.as_ref() {
|
||
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
|
||
}
|
||
|
||
|
||
let request = req_builder
|
||
.body(hyper::body::Body::empty());
|
||
|
||
client.request(request.unwrap()).await
|
||
|
||
};
|
||
|
||
match req_result {
|
||
Err(err) => {
|
||
if let client::Retry::After(d) = dlg.http_error(&err) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
dlg.finished(false);
|
||
return Err(client::Error::HttpError(err))
|
||
}
|
||
Ok(mut res) => {
|
||
if !res.status().is_success() {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
let (parts, _) = res.into_parts();
|
||
let body = hyper::Body::from(res_body_string.clone());
|
||
let restored_response = hyper::Response::from_parts(parts, body);
|
||
|
||
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
|
||
|
||
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
|
||
sleep(d).await;
|
||
continue;
|
||
}
|
||
|
||
dlg.finished(false);
|
||
|
||
return match server_response {
|
||
Some(error_value) => Err(client::Error::BadRequest(error_value)),
|
||
None => Err(client::Error::Failure(restored_response)),
|
||
}
|
||
}
|
||
let result_value = {
|
||
let res_body_string = client::get_body_as_string(res.body_mut()).await;
|
||
|
||
match json::from_str(&res_body_string) {
|
||
Ok(decoded) => (res, decoded),
|
||
Err(err) => {
|
||
dlg.response_json_decode_error(&res_body_string, &err);
|
||
return Err(client::Error::JsonDecodeError(res_body_string, err));
|
||
}
|
||
}
|
||
};
|
||
|
||
dlg.finished(true);
|
||
return Ok(result_value)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// 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, S> {
|
||
self._name = new_value.to_string();
|
||
self
|
||
}
|
||
/// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
|
||
///
|
||
/// Sets the *page token* query property to the given value.
|
||
pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, S> {
|
||
self._page_token = Some(new_value.to_string());
|
||
self
|
||
}
|
||
/// The maximum number of results to return. If not set, the service selects a default.
|
||
///
|
||
/// Sets the *page size* query property to the given value.
|
||
pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, S> {
|
||
self._page_size = Some(new_value);
|
||
self
|
||
}
|
||
/// If true, the returned list will include locations which are not yet revealed.
|
||
///
|
||
/// Sets the *include unrevealed locations* query property to the given value.
|
||
pub fn include_unrevealed_locations(mut self, new_value: bool) -> ProjectLocationListCall<'a, S> {
|
||
self._include_unrevealed_locations = Some(new_value);
|
||
self
|
||
}
|
||
/// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
|
||
///
|
||
/// Sets the *filter* query property to the given value.
|
||
pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, S> {
|
||
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.
|
||
///
|
||
/// ````text
|
||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||
/// ````
|
||
///
|
||
/// Sets the *delegate* property to the given value.
|
||
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectLocationListCall<'a, S> {
|
||
self._delegate = Some(new_value);
|
||
self
|
||
}
|
||
|
||
/// Set any additional parameter of the query string used in the request.
|
||
/// It should be used to set parameters which are not yet available through their own
|
||
/// setters.
|
||
///
|
||
/// Please note that this method must not be used to set any of the known parameters
|
||
/// which have their own setter method. If done anyway, the request will fail.
|
||
///
|
||
/// # Additional Parameters
|
||
///
|
||
/// * *$.xgafv* (query-string) - V1 error format.
|
||
/// * *access_token* (query-string) - OAuth access token.
|
||
/// * *alt* (query-string) - Data format for response.
|
||
/// * *callback* (query-string) - JSONP
|
||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
|
||
/// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
|
||
/// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
|
||
pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, S>
|
||
where T: AsRef<str> {
|
||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||
self
|
||
}
|
||
|
||
/// Identifies the authorization scope for the method you are building.
|
||
///
|
||
/// Use this method to actively specify which scope should be used, instead of 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.
|
||
///
|
||
/// 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<St>(mut self, scope: St) -> ProjectLocationListCall<'a, S>
|
||
where St: AsRef<str> {
|
||
self._scopes.insert(String::from(scope.as_ref()));
|
||
self
|
||
}
|
||
/// Identifies the authorization scope(s) for the method you are building.
|
||
///
|
||
/// See [`Self::add_scope()`] for details.
|
||
pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, S>
|
||
where I: IntoIterator<Item = St>,
|
||
St: AsRef<str> {
|
||
self._scopes
|
||
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
|
||
self
|
||
}
|
||
|
||
/// Removes all scopes, and no default scope will be used either.
|
||
/// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
|
||
/// for details).
|
||
pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, S> {
|
||
self._scopes.clear();
|
||
self
|
||
}
|
||
}
|
||
|
||
|