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};
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
CloudPlatform,
CloudPlatformReadOnly,
CloudUseraccount,
CloudUseraccountReadonly,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
Scope::CloudPlatformReadOnly => "https://www.googleapis.com/auth/cloud-platform.read-only",
Scope::CloudUseraccount => "https://www.googleapis.com/auth/cloud.useraccounts",
Scope::CloudUseraccountReadonly => "https://www.googleapis.com/auth/cloud.useraccounts.readonly",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::CloudUseraccountReadonly
}
}
#[derive(Clone)]
pub struct CloudUserAccounts<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 CloudUserAccounts<S> {}
impl<'a, S> CloudUserAccounts<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> CloudUserAccounts<S> {
CloudUserAccounts {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.4".to_string(),
_base_url: "https://www.googleapis.com/clouduseraccounts/vm_beta/projects/".to_string(),
_root_url: "https://www.googleapis.com/".to_string(),
}
}
pub fn global_accounts_operations(&'a self) -> GlobalAccountsOperationMethods<'a, S> {
GlobalAccountsOperationMethods { hub: &self }
}
pub fn groups(&'a self) -> GroupMethods<'a, S> {
GroupMethods { hub: &self }
}
pub fn linux(&'a self) -> LinuxMethods<'a, S> {
LinuxMethods { hub: &self }
}
pub fn users(&'a self) -> UserMethods<'a, S> {
UserMethods { hub: &self }
}
pub fn user_agent(&mut self, agent_name: String) -> String {
mem::replace(&mut self._user_agent, agent_name)
}
pub fn base_url(&mut self, new_base_url: String) -> String {
mem::replace(&mut self._base_url, new_base_url)
}
pub fn root_url(&mut self, new_root_url: String) -> String {
mem::replace(&mut self._root_url, new_root_url)
}
}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AuthorizedKeysView {
pub keys: Option<Vec<String>>,
pub sudoer: Option<bool>,
}
impl client::Part for AuthorizedKeysView {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Group {
#[serde(rename="creationTimestamp")]
pub creation_timestamp: Option<String>,
pub description: Option<String>,
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
pub kind: Option<String>,
pub members: Option<Vec<String>>,
pub name: Option<String>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
}
impl client::RequestValue for Group {}
impl client::Resource for Group {}
impl client::ResponseResult for Group {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GroupList {
pub id: Option<String>,
pub items: Option<Vec<Group>>,
pub kind: Option<String>,
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
}
impl client::ResponseResult for GroupList {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GroupsAddMemberRequest {
pub users: Option<Vec<String>>,
}
impl client::RequestValue for GroupsAddMemberRequest {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GroupsRemoveMemberRequest {
pub users: Option<Vec<String>>,
}
impl client::RequestValue for GroupsRemoveMemberRequest {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LinuxAccountViews {
#[serde(rename="groupViews")]
pub group_views: Option<Vec<LinuxGroupView>>,
pub kind: Option<String>,
#[serde(rename="userViews")]
pub user_views: Option<Vec<LinuxUserView>>,
}
impl client::Part for LinuxAccountViews {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LinuxGetAuthorizedKeysViewResponse {
pub resource: Option<AuthorizedKeysView>,
}
impl client::ResponseResult for LinuxGetAuthorizedKeysViewResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LinuxGetLinuxAccountViewsResponse {
pub resource: Option<LinuxAccountViews>,
}
impl client::ResponseResult for LinuxGetLinuxAccountViewsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LinuxGroupView {
pub gid: Option<u32>,
#[serde(rename="groupName")]
pub group_name: Option<String>,
pub members: Option<Vec<String>>,
}
impl client::Part for LinuxGroupView {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LinuxUserView {
pub gecos: Option<String>,
pub gid: Option<u32>,
#[serde(rename="homeDirectory")]
pub home_directory: Option<String>,
pub shell: Option<String>,
pub uid: Option<u32>,
pub username: Option<String>,
}
impl client::Part for LinuxUserView {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Operation {
#[serde(rename="clientOperationId")]
pub client_operation_id: Option<String>,
#[serde(rename="creationTimestamp")]
pub creation_timestamp: Option<String>,
pub description: Option<String>,
#[serde(rename="endTime")]
pub end_time: Option<String>,
pub error: Option<OperationError>,
#[serde(rename="httpErrorMessage")]
pub http_error_message: Option<String>,
#[serde(rename="httpErrorStatusCode")]
pub http_error_status_code: Option<i32>,
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
#[serde(rename="insertTime")]
pub insert_time: Option<String>,
pub kind: Option<String>,
pub name: Option<String>,
#[serde(rename="operationType")]
pub operation_type: Option<String>,
pub progress: Option<i32>,
pub region: Option<String>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
#[serde(rename="startTime")]
pub start_time: Option<String>,
pub status: Option<String>,
#[serde(rename="statusMessage")]
pub status_message: Option<String>,
#[serde(rename="targetId")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub target_id: Option<u64>,
#[serde(rename="targetLink")]
pub target_link: Option<String>,
pub user: Option<String>,
pub warnings: Option<Vec<OperationWarnings>>,
pub zone: Option<String>,
}
impl client::ResponseResult for Operation {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OperationList {
pub id: Option<String>,
pub items: Option<Vec<Operation>>,
pub kind: Option<String>,
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
}
impl client::ResponseResult for OperationList {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PublicKey {
#[serde(rename="creationTimestamp")]
pub creation_timestamp: Option<String>,
pub description: Option<String>,
#[serde(rename="expirationTimestamp")]
pub expiration_timestamp: Option<String>,
pub fingerprint: Option<String>,
pub key: Option<String>,
}
impl client::RequestValue for PublicKey {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct User {
#[serde(rename="creationTimestamp")]
pub creation_timestamp: Option<String>,
pub description: Option<String>,
pub groups: Option<Vec<String>>,
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub id: Option<u64>,
pub kind: Option<String>,
pub name: Option<String>,
pub owner: Option<String>,
#[serde(rename="publicKeys")]
pub public_keys: Option<Vec<PublicKey>>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
}
impl client::RequestValue for User {}
impl client::Resource for User {}
impl client::ResponseResult for User {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct UserList {
pub id: Option<String>,
pub items: Option<Vec<User>>,
pub kind: Option<String>,
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
#[serde(rename="selfLink")]
pub self_link: Option<String>,
}
impl client::ResponseResult for UserList {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OperationError {
pub errors: Option<Vec<OperationErrorErrors>>,
}
impl client::NestedType for OperationError {}
impl client::Part for OperationError {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OperationErrorErrors {
pub code: Option<String>,
pub location: Option<String>,
pub message: Option<String>,
}
impl client::NestedType for OperationErrorErrors {}
impl client::Part for OperationErrorErrors {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OperationWarnings {
pub code: Option<String>,
pub data: Option<Vec<OperationWarningsData>>,
pub message: Option<String>,
}
impl client::NestedType for OperationWarnings {}
impl client::Part for OperationWarnings {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct OperationWarningsData {
pub key: Option<String>,
pub value: Option<String>,
}
impl client::NestedType for OperationWarningsData {}
impl client::Part for OperationWarningsData {}
pub struct GlobalAccountsOperationMethods<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
}
impl<'a, S> client::MethodsBuilder for GlobalAccountsOperationMethods<'a, S> {}
impl<'a, S> GlobalAccountsOperationMethods<'a, S> {
pub fn delete(&self, project: &str, operation: &str) -> GlobalAccountsOperationDeleteCall<'a, S> {
GlobalAccountsOperationDeleteCall {
hub: self.hub,
_project: project.to_string(),
_operation: operation.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get(&self, project: &str, operation: &str) -> GlobalAccountsOperationGetCall<'a, S> {
GlobalAccountsOperationGetCall {
hub: self.hub,
_project: project.to_string(),
_operation: operation.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list(&self, project: &str) -> GlobalAccountsOperationListCall<'a, S> {
GlobalAccountsOperationListCall {
hub: self.hub,
_project: project.to_string(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct GroupMethods<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
}
impl<'a, S> client::MethodsBuilder for GroupMethods<'a, S> {}
impl<'a, S> GroupMethods<'a, S> {
pub fn add_member(&self, request: GroupsAddMemberRequest, project: &str, group_name: &str) -> GroupAddMemberCall<'a, S> {
GroupAddMemberCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_group_name: group_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn delete(&self, project: &str, group_name: &str) -> GroupDeleteCall<'a, S> {
GroupDeleteCall {
hub: self.hub,
_project: project.to_string(),
_group_name: group_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get(&self, project: &str, group_name: &str) -> GroupGetCall<'a, S> {
GroupGetCall {
hub: self.hub,
_project: project.to_string(),
_group_name: group_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn insert(&self, request: Group, project: &str) -> GroupInsertCall<'a, S> {
GroupInsertCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list(&self, project: &str) -> GroupListCall<'a, S> {
GroupListCall {
hub: self.hub,
_project: project.to_string(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn remove_member(&self, request: GroupsRemoveMemberRequest, project: &str, group_name: &str) -> GroupRemoveMemberCall<'a, S> {
GroupRemoveMemberCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_group_name: group_name.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct LinuxMethods<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
}
impl<'a, S> client::MethodsBuilder for LinuxMethods<'a, S> {}
impl<'a, S> LinuxMethods<'a, S> {
pub fn get_authorized_keys_view(&self, project: &str, zone: &str, user: &str, instance: &str) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
LinuxGetAuthorizedKeysViewCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_user: user.to_string(),
_instance: instance.to_string(),
_login: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get_linux_account_views(&self, project: &str, zone: &str, instance: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
LinuxGetLinuxAccountViewCall {
hub: self.hub,
_project: project.to_string(),
_zone: zone.to_string(),
_instance: instance.to_string(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct UserMethods<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
}
impl<'a, S> client::MethodsBuilder for UserMethods<'a, S> {}
impl<'a, S> UserMethods<'a, S> {
pub fn add_public_key(&self, request: PublicKey, project: &str, user: &str) -> UserAddPublicKeyCall<'a, S> {
UserAddPublicKeyCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_user: user.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn delete(&self, project: &str, user: &str) -> UserDeleteCall<'a, S> {
UserDeleteCall {
hub: self.hub,
_project: project.to_string(),
_user: user.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get(&self, project: &str, user: &str) -> UserGetCall<'a, S> {
UserGetCall {
hub: self.hub,
_project: project.to_string(),
_user: user.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn insert(&self, request: User, project: &str) -> UserInsertCall<'a, S> {
UserInsertCall {
hub: self.hub,
_request: request,
_project: project.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list(&self, project: &str) -> UserListCall<'a, S> {
UserListCall {
hub: self.hub,
_project: project.to_string(),
_page_token: Default::default(),
_order_by: Default::default(),
_max_results: Default::default(),
_filter: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn remove_public_key(&self, project: &str, user: &str, fingerprint: &str) -> UserRemovePublicKeyCall<'a, S> {
UserRemovePublicKeyCall {
hub: self.hub,
_project: project.to_string(),
_user: user.to_string(),
_fingerprint: fingerprint.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct GlobalAccountsOperationDeleteCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_operation: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GlobalAccountsOperationDeleteCall<'a, S> {}
impl<'a, S> GlobalAccountsOperationDeleteCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
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: "clouduseraccounts.globalAccountsOperations.delete",
http_method: hyper::Method::DELETE });
for &field in ["project", "operation"].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("project", self._project);
params.push("operation", self._operation);
params.extend(self._additional_params.iter());
let mut url = self.hub._base_url.clone() + "{project}/global/operations/{operation}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{operation}", "operation")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["operation", "project"];
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 = res;
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GlobalAccountsOperationDeleteCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn operation(mut self, new_value: &str) -> GlobalAccountsOperationDeleteCall<'a, S> {
self._operation = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GlobalAccountsOperationDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GlobalAccountsOperationDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GlobalAccountsOperationDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GlobalAccountsOperationDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GlobalAccountsOperationDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GlobalAccountsOperationGetCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_operation: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GlobalAccountsOperationGetCall<'a, S> {}
impl<'a, S> GlobalAccountsOperationGetCall<'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>>,
{
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: "clouduseraccounts.globalAccountsOperations.get",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "operation"].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("project", self._project);
params.push("operation", self._operation);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/operations/{operation}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{operation}", "operation")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["operation", "project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GlobalAccountsOperationGetCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn operation(mut self, new_value: &str) -> GlobalAccountsOperationGetCall<'a, S> {
self._operation = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GlobalAccountsOperationGetCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GlobalAccountsOperationGetCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GlobalAccountsOperationGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GlobalAccountsOperationGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GlobalAccountsOperationGetCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GlobalAccountsOperationListCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GlobalAccountsOperationListCall<'a, S> {}
impl<'a, S> GlobalAccountsOperationListCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, OperationList)> {
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: "clouduseraccounts.globalAccountsOperations.list",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "pageToken", "orderBy", "maxResults", "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("project", self._project);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._order_by.as_ref() {
params.push("orderBy", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", 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() + "{project}/global/operations";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GlobalAccountsOperationListCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn page_token(mut self, new_value: &str) -> GlobalAccountsOperationListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn order_by(mut self, new_value: &str) -> GlobalAccountsOperationListCall<'a, S> {
self._order_by = Some(new_value.to_string());
self
}
pub fn max_results(mut self, new_value: u32) -> GlobalAccountsOperationListCall<'a, S> {
self._max_results = Some(new_value);
self
}
pub fn filter(mut self, new_value: &str) -> GlobalAccountsOperationListCall<'a, S> {
self._filter = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GlobalAccountsOperationListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GlobalAccountsOperationListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GlobalAccountsOperationListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GlobalAccountsOperationListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GlobalAccountsOperationListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupAddMemberCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_request: GroupsAddMemberRequest,
_project: String,
_group_name: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupAddMemberCall<'a, S> {}
impl<'a, S> GroupAddMemberCall<'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>>,
{
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: "clouduseraccounts.groups.addMember",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "groupName"].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("project", self._project);
params.push("groupName", self._group_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/groups/{groupName}/addMember";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{groupName}", "groupName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["groupName", "project"];
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)
}
}
}
}
pub fn request(mut self, new_value: GroupsAddMemberRequest) -> GroupAddMemberCall<'a, S> {
self._request = new_value;
self
}
pub fn project(mut self, new_value: &str) -> GroupAddMemberCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn group_name(mut self, new_value: &str) -> GroupAddMemberCall<'a, S> {
self._group_name = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupAddMemberCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupAddMemberCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupAddMemberCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupAddMemberCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupAddMemberCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupDeleteCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_group_name: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupDeleteCall<'a, S> {}
impl<'a, S> GroupDeleteCall<'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>>,
{
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: "clouduseraccounts.groups.delete",
http_method: hyper::Method::DELETE });
for &field in ["alt", "project", "groupName"].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("project", self._project);
params.push("groupName", self._group_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/groups/{groupName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{groupName}", "groupName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["groupName", "project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GroupDeleteCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn group_name(mut self, new_value: &str) -> GroupDeleteCall<'a, S> {
self._group_name = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupGetCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_group_name: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupGetCall<'a, S> {}
impl<'a, S> GroupGetCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Group)> {
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: "clouduseraccounts.groups.get",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "groupName"].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("project", self._project);
params.push("groupName", self._group_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/groups/{groupName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{groupName}", "groupName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["groupName", "project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GroupGetCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn group_name(mut self, new_value: &str) -> GroupGetCall<'a, S> {
self._group_name = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupGetCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupGetCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupGetCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupInsertCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_request: Group,
_project: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupInsertCall<'a, S> {}
impl<'a, S> GroupInsertCall<'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>>,
{
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: "clouduseraccounts.groups.insert",
http_method: hyper::Method::POST });
for &field in ["alt", "project"].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("project", self._project);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/groups";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["project"];
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)
}
}
}
}
pub fn request(mut self, new_value: Group) -> GroupInsertCall<'a, S> {
self._request = new_value;
self
}
pub fn project(mut self, new_value: &str) -> GroupInsertCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupInsertCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupInsertCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupInsertCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupListCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupListCall<'a, S> {}
impl<'a, S> GroupListCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GroupList)> {
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: "clouduseraccounts.groups.list",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "pageToken", "orderBy", "maxResults", "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("project", self._project);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._order_by.as_ref() {
params.push("orderBy", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", 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() + "{project}/global/groups";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> GroupListCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn page_token(mut self, new_value: &str) -> GroupListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn order_by(mut self, new_value: &str) -> GroupListCall<'a, S> {
self._order_by = Some(new_value.to_string());
self
}
pub fn max_results(mut self, new_value: u32) -> GroupListCall<'a, S> {
self._max_results = Some(new_value);
self
}
pub fn filter(mut self, new_value: &str) -> GroupListCall<'a, S> {
self._filter = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct GroupRemoveMemberCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_request: GroupsRemoveMemberRequest,
_project: String,
_group_name: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for GroupRemoveMemberCall<'a, S> {}
impl<'a, S> GroupRemoveMemberCall<'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>>,
{
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: "clouduseraccounts.groups.removeMember",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "groupName"].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("project", self._project);
params.push("groupName", self._group_name);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/groups/{groupName}/removeMember";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{groupName}", "groupName")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["groupName", "project"];
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)
}
}
}
}
pub fn request(mut self, new_value: GroupsRemoveMemberRequest) -> GroupRemoveMemberCall<'a, S> {
self._request = new_value;
self
}
pub fn project(mut self, new_value: &str) -> GroupRemoveMemberCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn group_name(mut self, new_value: &str) -> GroupRemoveMemberCall<'a, S> {
self._group_name = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> GroupRemoveMemberCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> GroupRemoveMemberCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> GroupRemoveMemberCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> GroupRemoveMemberCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> GroupRemoveMemberCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct LinuxGetAuthorizedKeysViewCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_zone: String,
_user: String,
_instance: String,
_login: Option<bool>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for LinuxGetAuthorizedKeysViewCall<'a, S> {}
impl<'a, S> LinuxGetAuthorizedKeysViewCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, LinuxGetAuthorizedKeysViewResponse)> {
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: "clouduseraccounts.linux.getAuthorizedKeysView",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "zone", "user", "instance", "login"].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("project", self._project);
params.push("zone", self._zone);
params.push("user", self._user);
params.push("instance", self._instance);
if let Some(value) = self._login.as_ref() {
params.push("login", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/zones/{zone}/authorizedKeysView/{user}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone"), ("{user}", "user")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["user", "zone", "project"];
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::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
.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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn zone(mut self, new_value: &str) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._zone = new_value.to_string();
self
}
pub fn user(mut self, new_value: &str) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._user = new_value.to_string();
self
}
pub fn instance(mut self, new_value: &str) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._instance = new_value.to_string();
self
}
pub fn login(mut self, new_value: bool) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._login = Some(new_value);
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LinuxGetAuthorizedKeysViewCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> LinuxGetAuthorizedKeysViewCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LinuxGetAuthorizedKeysViewCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> LinuxGetAuthorizedKeysViewCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct LinuxGetLinuxAccountViewCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_zone: String,
_instance: String,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for LinuxGetLinuxAccountViewCall<'a, S> {}
impl<'a, S> LinuxGetLinuxAccountViewCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, LinuxGetLinuxAccountViewsResponse)> {
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: "clouduseraccounts.linux.getLinuxAccountViews",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "zone", "instance", "pageToken", "orderBy", "maxResults", "filter"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
params.push("project", self._project);
params.push("zone", self._zone);
params.push("instance", self._instance);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._order_by.as_ref() {
params.push("orderBy", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", 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() + "{project}/zones/{zone}/linuxAccountViews";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{zone}", "zone")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["zone", "project"];
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::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
.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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn zone(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._zone = new_value.to_string();
self
}
pub fn instance(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._instance = new_value.to_string();
self
}
pub fn page_token(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn order_by(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._order_by = Some(new_value.to_string());
self
}
pub fn max_results(mut self, new_value: u32) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._max_results = Some(new_value);
self
}
pub fn filter(mut self, new_value: &str) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._filter = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LinuxGetLinuxAccountViewCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> LinuxGetLinuxAccountViewCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LinuxGetLinuxAccountViewCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> LinuxGetLinuxAccountViewCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserAddPublicKeyCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_request: PublicKey,
_project: String,
_user: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserAddPublicKeyCall<'a, S> {}
impl<'a, S> UserAddPublicKeyCall<'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>>,
{
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: "clouduseraccounts.users.addPublicKey",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "user"].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("project", self._project);
params.push("user", self._user);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/users/{user}/addPublicKey";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{user}", "user")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["user", "project"];
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)
}
}
}
}
pub fn request(mut self, new_value: PublicKey) -> UserAddPublicKeyCall<'a, S> {
self._request = new_value;
self
}
pub fn project(mut self, new_value: &str) -> UserAddPublicKeyCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn user(mut self, new_value: &str) -> UserAddPublicKeyCall<'a, S> {
self._user = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserAddPublicKeyCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserAddPublicKeyCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserAddPublicKeyCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserAddPublicKeyCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserAddPublicKeyCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserDeleteCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_user: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserDeleteCall<'a, S> {}
impl<'a, S> UserDeleteCall<'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>>,
{
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: "clouduseraccounts.users.delete",
http_method: hyper::Method::DELETE });
for &field in ["alt", "project", "user"].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("project", self._project);
params.push("user", self._user);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/users/{user}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{user}", "user")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["user", "project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> UserDeleteCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn user(mut self, new_value: &str) -> UserDeleteCall<'a, S> {
self._user = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserGetCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_user: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserGetCall<'a, S> {}
impl<'a, S> UserGetCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, User)> {
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: "clouduseraccounts.users.get",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "user"].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("project", self._project);
params.push("user", self._user);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/users/{user}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{user}", "user")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["user", "project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> UserGetCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn user(mut self, new_value: &str) -> UserGetCall<'a, S> {
self._user = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserGetCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserGetCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserGetCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserInsertCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_request: User,
_project: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserInsertCall<'a, S> {}
impl<'a, S> UserInsertCall<'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>>,
{
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: "clouduseraccounts.users.insert",
http_method: hyper::Method::POST });
for &field in ["alt", "project"].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("project", self._project);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/users";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["project"];
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)
}
}
}
}
pub fn request(mut self, new_value: User) -> UserInsertCall<'a, S> {
self._request = new_value;
self
}
pub fn project(mut self, new_value: &str) -> UserInsertCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserInsertCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserInsertCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserInsertCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserInsertCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserInsertCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserListCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_page_token: Option<String>,
_order_by: Option<String>,
_max_results: Option<u32>,
_filter: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserListCall<'a, S> {}
impl<'a, S> UserListCall<'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>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, UserList)> {
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: "clouduseraccounts.users.list",
http_method: hyper::Method::GET });
for &field in ["alt", "project", "pageToken", "orderBy", "maxResults", "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("project", self._project);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._order_by.as_ref() {
params.push("orderBy", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", 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() + "{project}/global/users";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudUseraccountReadonly.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["project"];
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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> UserListCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn page_token(mut self, new_value: &str) -> UserListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn order_by(mut self, new_value: &str) -> UserListCall<'a, S> {
self._order_by = Some(new_value.to_string());
self
}
pub fn max_results(mut self, new_value: u32) -> UserListCall<'a, S> {
self._max_results = Some(new_value);
self
}
pub fn filter(mut self, new_value: &str) -> UserListCall<'a, S> {
self._filter = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct UserRemovePublicKeyCall<'a, S>
where S: 'a {
hub: &'a CloudUserAccounts<S>,
_project: String,
_user: String,
_fingerprint: String,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for UserRemovePublicKeyCall<'a, S> {}
impl<'a, S> UserRemovePublicKeyCall<'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>>,
{
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: "clouduseraccounts.users.removePublicKey",
http_method: hyper::Method::POST });
for &field in ["alt", "project", "user", "fingerprint"].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("project", self._project);
params.push("user", self._user);
params.push("fingerprint", self._fingerprint);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "{project}/global/users/{user}/removePublicKey";
if self._scopes.is_empty() {
self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
}
for &(find_this, param_name) in [("{project}", "project"), ("{user}", "user")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["user", "project"];
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::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
.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)
}
}
}
}
pub fn project(mut self, new_value: &str) -> UserRemovePublicKeyCall<'a, S> {
self._project = new_value.to_string();
self
}
pub fn user(mut self, new_value: &str) -> UserRemovePublicKeyCall<'a, S> {
self._user = new_value.to_string();
self
}
pub fn fingerprint(mut self, new_value: &str) -> UserRemovePublicKeyCall<'a, S> {
self._fingerprint = new_value.to_string();
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> UserRemovePublicKeyCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> UserRemovePublicKeyCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> UserRemovePublicKeyCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> UserRemovePublicKeyCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> UserRemovePublicKeyCall<'a, S> {
self._scopes.clear();
self
}
}